trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arvi...@apache.org
Subject [1/4] incubator-trafodion git commit: useless to sleep 30s after disconnecting
Date Mon, 07 Dec 2015 18:46:40 GMT
Repository: incubator-trafodion
Updated Branches:
  refs/heads/master fbfab1e8f -> 4e8bc1bb6


useless to sleep 30s after disconnecting


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/f68df24b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/f68df24b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/f68df24b

Branch: refs/heads/master
Commit: f68df24bc4ba9d06a466e247d92315bca3040bf2
Parents: e54c732
Author: Kevin Xu <kaihua.xu@esgyn.cn>
Authored: Thu Dec 3 15:17:15 2015 +0800
Committer: Kevin Xu <kaihua.xu@esgyn.cn>
Committed: Thu Dec 3 15:17:15 2015 +0800

----------------------------------------------------------------------
 .../dcs/master/listener/ConnectReply.java       | 72 ++++++++------------
 .../org/trafodion/dcs/servermt/ServerUtils.java |  2 +-
 2 files changed, 30 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f68df24b/dcs/src/main/java/org/trafodion/dcs/master/listener/ConnectReply.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/master/listener/ConnectReply.java b/dcs/src/main/java/org/trafodion/dcs/master/listener/ConnectReply.java
index f0880b6..704c9a7 100644
--- a/dcs/src/main/java/org/trafodion/dcs/master/listener/ConnectReply.java
+++ b/dcs/src/main/java/org/trafodion/dcs/master/listener/ConnectReply.java
@@ -163,29 +163,20 @@ class ConnectReply {
             for(int i=0; i < randomPicks; i++){
                 while(true){
                     index = random.nextInt();
-                    index = index > 0? index : -index;
+                    index = Math.abs(index);
                     index %= length;
                     if (indexArr[index] != index) break;
                 }
                 indexArr[index] = index;
-                maxIndex = index > maxIndex ? index : maxIndex;
+                maxIndex = Math.max(maxIndex, index);
                 server = servers.get(index);
                 if(LOG.isDebugEnabled())
-                    LOG.debug(clientSocketAddress + ": " + " index " + index + " server picked
" + server );
-                
-                nodeRegisteredPath = registeredPath + "/" + server;
-                stat = zkc.exists(nodeRegisteredPath,false);
-                if(stat != null){
-                    data = zkc.getData(nodeRegisteredPath, false, stat);
-                    if (false == (new String(data)).startsWith("AVAILABLE:"))
-                        continue;
-                    else {
-                        found = true;
-                        break;
-                    }
-                }
-                else
-                    continue;
+                    LOG.debug(clientSocketAddress + ": " + "server selected in search 1 "
+ server );
+                data = isServerAvalible(registeredPath + "/" + server);
+                if(data != null){
+                	found = true;
+                	break;
+                }else continue;
             }
 //
 // search sequentially for AVAILABLE server starting from highest random index + 1 to length
@@ -197,19 +188,11 @@ class ConnectReply {
                         if(LOG.isDebugEnabled())
                             LOG.debug(clientSocketAddress + ": " + "server selected in search
1 " + server );
                             
-                        nodeRegisteredPath = registeredPath + "/" + server;
-                        stat = zkc.exists(nodeRegisteredPath,false);
-                        if(stat != null){
-                            data = zkc.getData(nodeRegisteredPath, false, stat);
-                            if (false == (new String(data)).startsWith("AVAILABLE:"))
-                                continue;
-                            else {
-                                found = true;
-                                break;
-                            }
-                        }
-                        else
-                            continue;
+                        data = isServerAvalible(registeredPath + "/" + server);
+                        if(data != null){
+                        	found = true;
+                        	break;
+                        }else continue;
                     }
                 }
             }
@@ -223,19 +206,11 @@ class ConnectReply {
                         if(LOG.isDebugEnabled())
                             LOG.debug(clientSocketAddress + ": " + "server selected in search
2 " + server );
                             
-                        nodeRegisteredPath = registeredPath + "/" + server;
-                        stat = zkc.exists(nodeRegisteredPath,false);
-                        if(stat != null){
-                            data = zkc.getData(nodeRegisteredPath, false, stat);
-                            if (false == (new String(data)).startsWith("AVAILABLE:"))
-                                continue;
-                            else {
-                                found = true;
-                                break;
-                            }
-                        }
-                        else
-                            continue;
+                        data = isServerAvalible(registeredPath + "/" + server);
+                        if(data != null){
+                        	found = true;
+                        	break;
+                        }else continue;
                     }
                 }
             }
@@ -335,4 +310,15 @@ class ConnectReply {
         }
     return replyException;
     }
+    
+	private byte[] isServerAvalible(String serverPath) throws KeeperException, InterruptedException
{
+        Stat stat = zkc.exists(serverPath,false);
+        if(stat != null){
+            byte[] data = zkc.getData(serverPath, false, stat);
+            if(data != null && new String(data).startsWith("AVAILABLE:")){
+            	return data;
+            }
+        }
+		return null;
+	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f68df24b/dcs/src/main/java/org/trafodion/dcs/servermt/ServerUtils.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/servermt/ServerUtils.java b/dcs/src/main/java/org/trafodion/dcs/servermt/ServerUtils.java
index 8fc93d0..2962e74 100644
--- a/dcs/src/main/java/org/trafodion/dcs/servermt/ServerUtils.java
+++ b/dcs/src/main/java/org/trafodion/dcs/servermt/ServerUtils.java
@@ -209,7 +209,7 @@ public final class ServerUtils  {
                 updateStateToConnected();
             }
             else if (serverState == ServerConstants.SERVER_STATE_DISCONNECTED){
-                updateStateDisconnected();
+                //updateStateDisconnected();
                 updateServerStateAvailable();
             }
             else if (serverState == ServerConstants.SERVER_STATE_CONNECT_FAILED){


Mime
View raw message