You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by sm...@apache.org on 2015/04/13 22:49:55 UTC

[2/2] drill git commit: DRILL-2512: Shuffle the list of Drill endpoints before connecting

DRILL-2512: Shuffle the list of Drill endpoints before connecting


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

Branch: refs/heads/master
Commit: a6df26ac030068239ad63335f871f0aefe735ef7
Parents: 49042bc
Author: AdamPD <ad...@pharmadata.net.au>
Authored: Mon Apr 13 16:25:29 2015 +1000
Committer: Steven Phillips <sm...@apache.org>
Committed: Mon Apr 13 11:37:08 2015 -0700

----------------------------------------------------------------------
 .../java/org/apache/drill/exec/client/DrillClient.java    | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/a6df26ac/exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillClient.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillClient.java b/exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillClient.java
index 9a948fb..579cf7d 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillClient.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillClient.java
@@ -24,7 +24,9 @@ import io.netty.buffer.DrillBuf;
 
 import java.io.Closeable;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
 import java.util.Vector;
@@ -165,9 +167,10 @@ public class DrillClient implements Closeable, ConnectionThrottle {
       this.props = upBuilder.build();
     }
 
-    Collection<DrillbitEndpoint> endpoints = clusterCoordinator.getAvailableEndpoints();
+    ArrayList<DrillbitEndpoint> endpoints = new ArrayList<>(clusterCoordinator.getAvailableEndpoints());
     checkState(!endpoints.isEmpty(), "No DrillbitEndpoint can be found");
-    // just use the first endpoint for now
+    // shuffle the collection then get the first endpoint
+    Collections.shuffle(endpoints);
     DrillbitEndpoint endpoint = endpoints.iterator().next();
 
     eventLoopGroup = createEventLoop(config.getInt(ExecConstants.CLIENT_RPC_THREADS), "Client-");
@@ -190,11 +193,12 @@ public class DrillClient implements Closeable, ConnectionThrottle {
       retry--;
       try {
         Thread.sleep(this.reconnectDelay);
-        Collection<DrillbitEndpoint> endpoints = clusterCoordinator.getAvailableEndpoints();
+        ArrayList<DrillbitEndpoint> endpoints = new ArrayList<>(clusterCoordinator.getAvailableEndpoints());
         if (endpoints.isEmpty()) {
           continue;
         }
         client.close();
+        Collections.shuffle(endpoints);
         connect(endpoints.iterator().next());
         return true;
       } catch (Exception e) {