cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r910929 - in /cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper: EndpointListenerFactory.java InterfaceMonitor.java ZooKeeperDiscovery.java
Date Wed, 17 Feb 2010 11:51:57 GMT
Author: davidb
Date: Wed Feb 17 11:51:57 2010
New Revision: 910929

URL: http://svn.apache.org/viewvc?rev=910929&view=rev
Log:
Fix for DOSGI-63 applied on behalf of Marc Schaaf.

Modified:
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/EndpointListenerFactory.java
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/InterfaceMonitor.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/EndpointListenerFactory.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/EndpointListenerFactory.java?rev=910929&r1=910928&r2=910929&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/EndpointListenerFactory.java
(original)
+++ cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/EndpointListenerFactory.java
Wed Feb 17 11:51:57 2010
@@ -66,7 +66,7 @@
 
     }
 
-    public void start() {
+    public synchronized void start() {
         serviceRegistartion = bctx.registerService(EndpointListener.class.getName(), this,
null);
         updateServiceRegistration();
     }
@@ -77,7 +77,7 @@
         serviceRegistartion.setProperties(props);
     }
 
-    public void stop() {
+    public synchronized void stop() {
         if (serviceRegistartion != null)
             serviceRegistartion.unregister();
         

Modified: cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/InterfaceMonitor.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/InterfaceMonitor.java?rev=910929&r1=910928&r2=910929&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/InterfaceMonitor.java
(original)
+++ cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/InterfaceMonitor.java
Wed Feb 17 11:51:57 2010
@@ -61,13 +61,14 @@
         
         switch (rc) {
         case Code.Ok:
-            break;
         case Code.NoNode:
             break;
+
         case Code.SessionExpired:
-            return;
         case Code.NoAuth:
+        case Code.ConnectionLoss:
             return;
+        
         default:
             process();
             return;
@@ -78,6 +79,12 @@
 
     private void processDelta() {
         if(closed) return;
+        
+        if(zookeeper.getState() != ZooKeeper.States.CONNECTED){
+            LOG.info("zookeeper connection was already closed! Not processing changed event.");
+            return;
+        }
+        
         try {
             if (zookeeper.exists(znode, false) != null) {
                 listener.change();

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=910929&r1=910928&r2=910929&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
Wed Feb 17 11:51:57 2010
@@ -60,6 +60,25 @@
         if(started) return;
         started = true;
         createZooKeeper(properties);
+        
+        // Wait up to 10 seconds for the connection to be established and only register 
+        // the listeners once the connection is established
+        int loops = 100;
+        
+        while(loops>0){
+            if(zooKeeper.getState()==ZooKeeper.States.CONNECTED){
+                break;
+            }
+            --loops;
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException e) {}
+        }
+        
+        if(zooKeeper.getState()!=ZooKeeper.States.CONNECTED){
+            throw new IOException("Connection to ZookeeperServer failed !");
+        }
+        
         endpointListenerFactory.start();
         endpointListenerTracker.open();
     }
@@ -78,7 +97,6 @@
         zkTimeout = Integer.parseInt(getProp(props, "zookeeper.timeout", "3000"));
 
         zooKeeper = createZooKeeper();
-
     }
 
     // separated for testing



Mime
View raw message