Skip to content

Commit c31e41d

Browse files
author
chengyitian
committed
AJ-768: optimize single conn run reconnect issue and log;
1 parent d65e51c commit c31e41d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/com/xxdb/DBConnection.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ private enum ExceptionType{
6868
ET_NEWLEADER(2),
6969
ET_NODENOTAVAIL(3),
7070
ET_NOINITIALIZED(4),
71-
ET_NOTLEADER(5);
71+
ET_NOTLEADER(5),
72+
ET_READTIMEDOUT(6);
7273

7374
public int value;
7475
ExceptionType(int value){
@@ -989,7 +990,8 @@ public void switchDataNode(Node node) throws IOException{
989990
attempt ++;
990991
if (node.hostName != null && node.hostName.length() > 0) {
991992
if (connectNode(node)) {
992-
log.info("Switch to node: " + node.hostName + ":" + node.port + " successfully.");
993+
if (nodes_.size() > 1)
994+
log.info("Switch to node: " + node.hostName + ":" + node.port + " successfully.");
993995
isConnected = true;
994996
break;
995997
}
@@ -1093,7 +1095,10 @@ public ExceptionType parseException(String msg, Node node){
10931095
node.hostName = "";
10941096
node.port = 0;
10951097
return ExceptionType.ET_NOINITIALIZED;
1096-
}else {
1098+
} else if (msg.contains("Failed to read response header from the socket with IO error Read timed out")) {
1099+
conn_.getNode(node);
1100+
return ExceptionType.ET_READTIMEDOUT;
1101+
} else {
10971102
node.hostName = "";
10981103
node.port = 0;
10991104
return ExceptionType.ET_UNKNOW;

0 commit comments

Comments
 (0)