Skip to content

Commit 9af3f87

Browse files
author
chengyitian
committed
AJ-539: code review; optimize deprecated log info; retain origin method;
1 parent 1413a5a commit 9af3f87

File tree

1 file changed

+69
-7
lines changed

1 file changed

+69
-7
lines changed

src/com/xxdb/DBConnection.java

Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ public DBConnection(boolean asynchronousTask, boolean useSSL, boolean compress,
622622
}
623623

624624
/**
625-
* This method has been deprecated since 'Java API 1.30.22.4' and will be privated in the next version: 'Java API xxx'.
625+
* This method has been deprecated since 'Java API 1.30.22.4'.
626626
* @param asynchronousTask
627627
* @param useSSL
628628
* @param compress
@@ -1031,7 +1031,7 @@ public Entity tryRun(String script, int priority, int parallelism,int fetchSize,
10311031
}
10321032

10331033
public Entity run(String script, String tableName) throws IOException{
1034-
return run(script, (ProgressListener) null, DEFAULT_PRIORITY, DEFAULT_PARALLELISM, 0, false, tableName, true);
1034+
return run(script, (ProgressListener) null, DEFAULT_PRIORITY, DEFAULT_PARALLELISM, 0, false, tableName);
10351035
}
10361036

10371037
public Entity run(String script) throws IOException {
@@ -1089,7 +1089,7 @@ public Entity run(String script, boolean clearSessionMemory) throws IOException
10891089
}
10901090

10911091
public Entity run(String script, ProgressListener listener, int priority, int parallelism, int fetchSize, boolean clearSessionMemory) throws IOException{
1092-
return run(script, listener, priority, parallelism, fetchSize, clearSessionMemory, "", true);
1092+
return run(script, listener, priority, parallelism, fetchSize, clearSessionMemory, "");
10931093
}
10941094

10951095
public Entity run(String script, ProgressListener listener, int priority, int parallelism, int fetchSize, boolean clearSessionMemory, String tableName, boolean enableSeqNo) throws IOException{
@@ -1130,7 +1130,38 @@ else if (type == ExceptionType.ET_UNKNOW)
11301130
}
11311131
}
11321132

1133-
1133+
public Entity run(String script, ProgressListener listener, int priority, int parallelism, int fetchSize, boolean clearSessionMemory, String tableName) throws IOException{
1134+
mutex_.lock();
1135+
try {
1136+
if (!nodes_.isEmpty()) {
1137+
long curSeqNo = newSeqNo();
1138+
while (!closed_) {
1139+
try {
1140+
return conn_.run(script, listener, priority, parallelism, fetchSize, clearSessionMemory, tableName, curSeqNo);
1141+
} catch (IOException e) {
1142+
if(curSeqNo>0)
1143+
curSeqNo = -curSeqNo;
1144+
Node node = new Node();
1145+
if (connected()) {
1146+
ExceptionType type = parseException(e.getMessage(), node);
1147+
if (type == ExceptionType.ET_IGNORE)
1148+
return new Void();
1149+
else if (type == ExceptionType.ET_UNKNOW)
1150+
throw e;
1151+
}else {
1152+
parseException(e.getMessage(), node);
1153+
}
1154+
switchDataNode(node);
1155+
}
1156+
}
1157+
return null;
1158+
} else {
1159+
return conn_.run(script, listener, priority, parallelism, fetchSize, clearSessionMemory, tableName, 0);
1160+
}
1161+
} finally {
1162+
mutex_.unlock();
1163+
}
1164+
}
11341165

11351166
public Entity tryRun(String function, List<Entity> arguments) throws IOException {
11361167
return tryRun(function, arguments, DEFAULT_PRIORITY, DEFAULT_PARALLELISM);
@@ -1143,7 +1174,7 @@ public Entity tryRun(String function, List<Entity> arguments, int priority, int
11431174
if (!mutex_.tryLock())
11441175
return null;
11451176
try {
1146-
return run(function, arguments, priority, parallelism, fetchSize, true);
1177+
return run(function, arguments, priority, parallelism, fetchSize);
11471178
} finally {
11481179
mutex_.unlock();
11491180
}
@@ -1158,7 +1189,7 @@ public Entity run(String function, List<Entity> arguments, int priority) throws
11581189
}
11591190

11601191
public Entity run(String function, List<Entity> arguments, int priority, int parallelism) throws IOException {
1161-
return run(function, arguments, priority, parallelism, 0, true);
1192+
return run(function, arguments, priority, parallelism, 0);
11621193
}
11631194
private long newSeqNo(){
11641195
mutex_.lock();
@@ -1209,7 +1240,38 @@ else if (type == ExceptionType.ET_UNKNOW)
12091240
}
12101241
}
12111242

1212-
1243+
public Entity run(String function, List<Entity> arguments, int priority, int parallelism, int fetchSize) throws IOException {
1244+
mutex_.lock();
1245+
try {
1246+
if (!nodes_.isEmpty()){
1247+
long seqNo = newSeqNo();
1248+
while (!closed_){
1249+
try {
1250+
return conn_.run(function, (ProgressListener)null, arguments, priority, parallelism, fetchSize, false,seqNo);
1251+
}catch (IOException e){
1252+
if(seqNo > 0)
1253+
seqNo = -seqNo;
1254+
Node node = new Node();
1255+
if (connected()){
1256+
ExceptionType type = parseException(e.getMessage(), node);
1257+
if (type == ExceptionType.ET_IGNORE)
1258+
return new Void();
1259+
else if (type == ExceptionType.ET_UNKNOW)
1260+
throw e;
1261+
}else {
1262+
parseException(e.getMessage(), node);
1263+
}
1264+
switchDataNode(node);
1265+
}
1266+
}
1267+
return null;
1268+
}else {
1269+
return conn_.run(function, (ProgressListener)null, arguments, priority, parallelism, fetchSize, false, 0);
1270+
}
1271+
}finally {
1272+
mutex_.unlock();
1273+
}
1274+
}
12131275

12141276
public void tryUpload(final Map<String, Entity> variableObjectMap) throws IOException {
12151277
if (!mutex_.tryLock())

0 commit comments

Comments
 (0)