camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [1/4] git commit: CAMEL-7086 Allow multiple Zookeeper servers in endpoint with thanks to Klaus
Date Fri, 20 Dec 2013 11:34:31 GMT
Updated Branches:
  refs/heads/camel-2.11.x 3a2dabb0e -> 30786f549
  refs/heads/camel-2.12.x fdbdedd34 -> f421a7069


CAMEL-7086 Allow multiple Zookeeper servers in endpoint with thanks to Klaus


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

Branch: refs/heads/camel-2.12.x
Commit: 5e387177b06b7036dba24ba52ae86f0ead20bbfb
Parents: fdbdedd
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Fri Dec 20 19:29:59 2013 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Fri Dec 20 19:31:27 2013 +0800

----------------------------------------------------------------------
 .../apache/camel/component/zookeeper/ConnectionHolder.java  | 4 +++-
 .../camel/component/zookeeper/ZooKeeperComponent.java       | 9 ++++++---
 .../camel/component/zookeeper/ZooKeeperEndpointTest.java    | 8 ++++++++
 3 files changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5e387177/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ConnectionHolder.java
----------------------------------------------------------------------
diff --git a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ConnectionHolder.java
b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ConnectionHolder.java
index 68acadc..2e69e31 100644
--- a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ConnectionHolder.java
+++ b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ConnectionHolder.java
@@ -85,7 +85,9 @@ public class ConnectionHolder implements Watcher {
 
     public void closeConnection() {
         try {
-            zookeeper.close();
+            if (zookeeper != null) {
+                zookeeper.close();
+            }
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Shutting down connection to Zookeeper cluster {}", configuration.getConnectString());
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/5e387177/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperComponent.java
b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperComponent.java
index a35020e..c1f014e 100644
--- a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperComponent.java
+++ b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperComponent.java
@@ -56,9 +56,12 @@ public class ZooKeeperComponent extends DefaultComponent {
     }
 
     private void extractConfigFromUri(String remaining, ZooKeeperConfiguration config) throws
URISyntaxException {
-        URI u = new URI(remaining);
-        config.addZookeeperServer(u.getHost() + (u.getPort() != -1 ? ":" + u.getPort() :
""));
-        config.setPath(u.getPath());
+        URI fullUri = new URI(remaining);
+        String[] hosts = fullUri.getAuthority().split(",");
+        for (String host : hosts) {
+            config.addZookeeperServer(host.trim());
+        }
+        config.setPath(fullUri.getPath());
     }
 
     public ZooKeeperConfiguration getConfiguration() {

http://git-wip-us.apache.org/repos/asf/camel/blob/5e387177/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperEndpointTest.java
b/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperEndpointTest.java
index 7e59de2..83db2a4 100644
--- a/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperEndpointTest.java
+++ b/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperEndpointTest.java
@@ -32,5 +32,13 @@ public class ZooKeeperEndpointTest extends CamelTestSupport {
         endpoint = context.getEndpoint("zookeeper:someserver/zoo?awaitExistence=false", ZooKeeperEndpoint.class);
         assertFalse("The awaitExistence option should be false", endpoint.getAwaitExistence());
     }
+    
+    public void multipleZooKeeperServers() {
+        ZooKeeperEndpoint endpoint = context.getEndpoint("zookeeper:someserver1,someserver2:1234/zoo",
ZooKeeperEndpoint.class);
+        assertEquals("Get wrong number of servers", 2, endpoint.getConfiguration().getServers().size());
+        assertEquals("The first server address is wrong", "someserver1", endpoint.getConfiguration().getServers().get(0));
+        assertEquals("The second server address is wrong", "someserver2:1234", endpoint.getConfiguration().getServers().get(0));
+        
+    }
 
 }


Mime
View raw message