Skip to content

Commit 98b395c

Browse files
author
chengyitian
committed
AJ-539: optimize code;
1 parent 2bb9ab6 commit 98b395c

File tree

1 file changed

+2
-60
lines changed

1 file changed

+2
-60
lines changed

src/com/xxdb/DBConnection.java

Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,36 +1131,7 @@ else if (type == ExceptionType.ET_UNKNOW)
11311131
}
11321132

11331133
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-
}
1134+
return run(script, listener, priority, parallelism, fetchSize, clearSessionMemory, tableName, true);
11641135
}
11651136

11661137
public Entity tryRun(String function, List<Entity> arguments) throws IOException {
@@ -1241,36 +1212,7 @@ else if (type == ExceptionType.ET_UNKNOW)
12411212
}
12421213

12431214
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-
}
1215+
return run(function, arguments, priority, parallelism, fetchSize, true);
12741216
}
12751217

12761218
public void tryUpload(final Map<String, Entity> variableObjectMap) throws IOException {

0 commit comments

Comments
 (0)