Github user arvind-narain commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/202#discussion_r46635336
--- Diff:
dcs/src/main/java/org/trafodion/dcs/master/listener/ConnectReply.java ---
@@ -163,29 +163,21 @@ boolean buildConnectReply (Header hdr,
ConnectionContext cc, SocketAddress clie
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;
+ if(LOG.isDebugEnabled())
+ LOG.debug(clientSocketAddress + ": " + "server
selected in search 1 " + server );
+ data = isServerAvalible(nodeRegisteredPath);
--- End diff --
Thanks for the refactor Kevin. Code looks good now.
Question - Doesn't seem to be a difference between the new log message
(175) for this case and the next case (191) - intentional ? I think earlier the
index was being printed.
Code is good to be checked in. The next set of change (for disconnect) will
allow tests to pass without holding onto the connections - thanks for that.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---