cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amic...@apache.org
Subject svn commit: r1492793 - in /cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper: Activator.java ZooKeeperDiscovery.java
Date Thu, 13 Jun 2013 18:11:51 GMT
Author: amichai
Date: Thu Jun 13 18:11:51 2013
New Revision: 1492793

URL: http://svn.apache.org/r1492793
Log:
DOSGI-191 Fix ZooKeeperDiscovery instance reconnects to ZooKeeper after bundle is stopped

Modified:
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/Activator.java
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/ZooKeeperDiscovery.java

Modified: cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/Activator.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/Activator.java?rev=1492793&r1=1492792&r2=1492793&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/Activator.java
(original)
+++ cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/Activator.java
Thu Jun 13 18:11:51 2013
@@ -38,6 +38,6 @@ public class Activator implements Bundle
     }
 
     public synchronized void stop(BundleContext bc) throws Exception {
-        zkd.stop();
+        zkd.stop(true);
     }
 }

Modified: cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/ZooKeeperDiscovery.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/ZooKeeperDiscovery.java?rev=1492793&r1=1492792&r2=1492793&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/ZooKeeperDiscovery.java
(original)
+++ cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/ZooKeeperDiscovery.java
Thu Jun 13 18:11:51 2013
@@ -41,10 +41,9 @@ public class ZooKeeperDiscovery implemen
 
     private PublishingEndpointListenerFactory endpointListenerFactory;
     private ServiceTracker endpointListenerTracker;
-
     private InterfaceMonitorManager imManager;
-
     private ZooKeeper zooKeeper;
+    private boolean closed;
 
     @SuppressWarnings("rawtypes")
     private Dictionary curConfiguration;
@@ -58,7 +57,7 @@ public class ZooKeeperDiscovery implemen
     public synchronized void updated(Dictionary configuration) throws ConfigurationException
{
         LOG.debug("Received configuration update for Zookeeper Discovery: {}", configuration);
 
-        stop();
+        stop(false);
 
         if (configuration == null) {
             return;
@@ -68,6 +67,9 @@ public class ZooKeeperDiscovery implemen
     }
 
     private synchronized void start() {
+        if (closed) {
+            return;
+        }
         LOG.debug("starting ZookeeperDiscovery");
         endpointListenerFactory = new PublishingEndpointListenerFactory(zooKeeper, bctx);
         endpointListenerFactory.start();
@@ -77,7 +79,8 @@ public class ZooKeeperDiscovery implemen
         endpointListenerTracker.open();
     }
 
-    public synchronized void stop() {
+    public synchronized void stop(boolean close) {
+        closed |= close;
         if (endpointListenerFactory != null) {
             LOG.debug("stopping ZookeeperDiscovery");
             endpointListenerFactory.stop();
@@ -99,6 +102,9 @@ public class ZooKeeperDiscovery implemen
 
     @SuppressWarnings("rawtypes")
     private synchronized void createZooKeeper(Dictionary props) {
+        if (closed) {
+            return;
+        }
         String host = Utils.getProp(props, "zookeeper.host", "localhost");
         String port = Utils.getProp(props, "zookeeper.port", "2181");
         int timeout = Utils.getProp(props, "zookeeper.timeout", 3000);
@@ -121,7 +127,7 @@ public class ZooKeeperDiscovery implemen
 
         case Expired:
             LOG.info("Connection to zookeeper expired. Trying to create a new connection");
-            stop();
+            stop(false);
             createZooKeeper(curConfiguration);
             break;
 



Mime
View raw message