You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2013/12/20 12:34:31 UTC

[1/4] git commit: CAMEL-7086 Allow multiple Zookeeper servers in endpoint with thanks to Klaus

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 <wi...@gmail.com>
Authored: Fri Dec 20 19:29:59 2013 +0800
Committer: Willem Jiang <wi...@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));
+        
+    }
 
 }


[2/4] git commit: CAMEL-7085 ZooKeeperProducer should shutdown the ConnectionManager when it is closed with thanks to Klaus

Posted by ni...@apache.org.
CAMEL-7085 ZooKeeperProducer should shutdown the ConnectionManager when it is closed 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/f421a706
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f421a706
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f421a706

Branch: refs/heads/camel-2.12.x
Commit: f421a7069ed4a95a1d64f827925355de3e981fb0
Parents: 5e38717
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri Dec 20 19:26:02 2013 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri Dec 20 19:33:36 2013 +0800

----------------------------------------------------------------------
 .../apache/camel/component/zookeeper/ZookeeperProducer.java | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f421a706/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZookeeperProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZookeeperProducer.java b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZookeeperProducer.java
index 4edc98e..f3e77d9 100644
--- a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZookeeperProducer.java
+++ b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZookeeperProducer.java
@@ -101,6 +101,15 @@ public class ZookeeperProducer extends DefaultProducer {
         }
     }
 
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+        if (log.isTraceEnabled()) {
+            log.trace(String.format("Shutting down zookeeper producer of '%s'", configuration.getPath()));
+        }
+        zkm.shutdown();
+    }
+
     private void asynchronouslyDeleteNode(ZooKeeper connection, ProductionContext context) {
         if (log.isDebugEnabled()) {
             log.debug(format("Deleting node '%s', not waiting for confirmation", context.node));


[3/4] git commit: CAMEL-7086 Allow multiple Zookeeper servers in endpoint with thanks to Klaus

Posted by ni...@apache.org.
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/1e2fd8c0
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1e2fd8c0
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1e2fd8c0

Branch: refs/heads/camel-2.11.x
Commit: 1e2fd8c0ad128d8d4fa5dde99eb35a9dbef60f02
Parents: 3a2dabb
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri Dec 20 19:29:59 2013 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri Dec 20 19:34:10 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/1e2fd8c0/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 b9fd907..29de485 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
@@ -89,7 +89,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/1e2fd8c0/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/1e2fd8c0/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));
+        
+    }
 
 }


[4/4] git commit: CAMEL-7085 ZooKeeperProducer should shutdown the ConnectionManager when it is closed with thanks to Klaus

Posted by ni...@apache.org.
CAMEL-7085 ZooKeeperProducer should shutdown the ConnectionManager when it is closed 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/30786f54
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/30786f54
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/30786f54

Branch: refs/heads/camel-2.11.x
Commit: 30786f549f9206dcb46465c9510032b16d4d298a
Parents: 1e2fd8c
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri Dec 20 19:26:02 2013 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri Dec 20 19:34:10 2013 +0800

----------------------------------------------------------------------
 .../apache/camel/component/zookeeper/ZookeeperProducer.java | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/30786f54/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZookeeperProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZookeeperProducer.java b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZookeeperProducer.java
index 78fb86a..e7cdb1d 100644
--- a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZookeeperProducer.java
+++ b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZookeeperProducer.java
@@ -101,6 +101,15 @@ public class ZookeeperProducer extends DefaultProducer {
         }
     }
 
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+        if (log.isTraceEnabled()) {
+            log.trace(String.format("Shutting down zookeeper producer of '%s'", configuration.getPath()));
+        }
+        zkm.shutdown();
+    }
+
     private void asynchronouslyDeleteNode(ZooKeeper connection, ProductionContext context) {
         if (log.isDebugEnabled()) {
             log.debug(format("Deleting node '%s', not waiting for confirmation", context.node));