incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cr...@apache.org
Subject [35/45] git commit: Starting fix the client issue with leaking ZK Clients.
Date Sun, 26 Oct 2014 17:55:33 GMT
Starting fix the client issue with leaking ZK Clients.


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

Branch: refs/heads/blur-384-random-port-cleanup
Commit: 63504e50badc69a27570195cec595ee46f75aeed
Parents: ff227c3
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Thu Oct 16 14:24:25 2014 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Thu Oct 16 14:24:25 2014 -0400

----------------------------------------------------------------------
 .../java/org/apache/blur/thrift/BlurClient.java | 24 ++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/63504e50/blur-thrift/src/main/java/org/apache/blur/thrift/BlurClient.java
----------------------------------------------------------------------
diff --git a/blur-thrift/src/main/java/org/apache/blur/thrift/BlurClient.java b/blur-thrift/src/main/java/org/apache/blur/thrift/BlurClient.java
index 407b039..8ba12f9 100644
--- a/blur-thrift/src/main/java/org/apache/blur/thrift/BlurClient.java
+++ b/blur-thrift/src/main/java/org/apache/blur/thrift/BlurClient.java
@@ -28,6 +28,7 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.util.Arrays;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
 
 import org.apache.blur.BlurConfiguration;
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
@@ -95,15 +96,24 @@ public class BlurClient {
 
   public static Iface getClient() {
     try {
-      return getClient(new BlurConfiguration());
+      return getClient(getBlurConfiguration());
     } catch (IOException e) {
       throw new RuntimeException("Unable to load configurations.", e);
     }
   }
 
+  private static volatile BlurConfiguration _blurConfiguration;
+  private static final AtomicReference<List<Connection>> _connections = new AtomicReference<List<Connection>>();
+
+  private static synchronized BlurConfiguration getBlurConfiguration() throws IOException
{
+    if (_blurConfiguration == null) {
+      _blurConfiguration = new BlurConfiguration();
+    }
+    return _blurConfiguration;
+  }
+
   public static Iface getClient(BlurConfiguration conf) {
-    List<String> onlineControllers = getOnlineControllers(conf);
-    return getClient(StringUtils.join(onlineControllers, ","));
+    return getClient(getOnlineControllers(conf));
   }
 
   /**
@@ -152,7 +162,13 @@ public class BlurClient {
         new BlurClientInvocationHandler(connections, maxRetries, backOffTime, maxBackOffTime));
   }
 
-  private static List<String> getOnlineControllers(BlurConfiguration conf) {
+  private static List<Connection> getOnlineControllers(BlurConfiguration conf) {
+setupZooKeeper(conf);
+
+
+  }
+
+  private static void setupZooKeeper(BlurConfiguration conf) {
     String zkConn = conf.getExpected(BLUR_ZOOKEEPER_CONNECTION);
     int zkSessionTimeout = conf.getInt(BLUR_ZOOKEEPER_TIMEOUT, BLUR_ZOOKEEPER_TIMEOUT_DEFAULT);
     ZooKeeper zkClient = null;


Mime
View raw message