EdColeman commented on code in PR #4306:
URL: https://github.com/apache/accumulo/pull/4306#discussion_r1504594985


##########
core/src/main/java/org/apache/accumulo/core/rpc/clients/ShellAuthenticatorThriftClient.java:
##########
@@ -58,16 +58,26 @@ public Pair<String,Client> getTabletServerConnection(Logger 
LOG, ThriftClientTyp
     checkArgument(context != null, "context is null");
     final long rpcTimeout = context.getClientTimeoutInMillis();
 
-    List<String> tservers = new ArrayList<>();
     final ZooCache zc = context.getZooCache();
-    for (String tserver : zc.getChildren(context.getZooKeeperRoot() + 
Constants.ZTSERVERS)) {
-      tservers.add(tserver);
-    }
-    if (tservers.isEmpty() && !warnedAboutTServersBeingDown.get()) {
-      LOG.warn("There are no tablet servers: check that zookeeper and accumulo 
are running.");
-      warnedAboutTServersBeingDown.set(true);
-      Collections.shuffle(tservers);
+    final List<String> tservers = new ArrayList<>();
+
+    for (int retries = 0; retries < 10; retries++) {
+      // Cluster may not be up, wait for tservers to come online
+      while (true) {
+        for (String tserver : zc.getChildren(context.getZooKeeperRoot() + 
Constants.ZTSERVERS)) {
+          tservers.add(tserver);
+        }
+        if (!tservers.isEmpty()) {
+          break;
+        }
+        if (!tservers.isEmpty() && !warnedAboutTServersBeingDown.get()) {
+          LOG.warn("There are no tablet servers: check that zookeeper and 
accumulo are running.");
+          warnedAboutTServersBeingDown.set(true);
+        }
+      }

Review Comment:
   Would there be a benefit of some delay between retries, thinking along the 
lines of 50ms or so so that ZooKeeper has a change to breath between 
getChildren() attempts? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to