curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject curator git commit: ExhibitorEnsembleProvider is not compatible with updateServerList()
Date Sat, 26 Sep 2015 23:03:19 GMT
Repository: curator
Updated Branches:
  refs/heads/CURATOR-266 56d9ba665 -> 6e56e8ae9


ExhibitorEnsembleProvider is not compatible with updateServerList()


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/6e56e8ae
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/6e56e8ae
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/6e56e8ae

Branch: refs/heads/CURATOR-266
Commit: 6e56e8ae9f04ffdd76505858dbbe5b1ff04dbd49
Parents: 56d9ba6
Author: randgalt <randgalt@apache.org>
Authored: Sat Sep 26 18:03:06 2015 -0500
Committer: randgalt <randgalt@apache.org>
Committed: Sat Sep 26 18:03:06 2015 -0500

----------------------------------------------------------------------
 .../org/apache/curator/ConnectionState.java     |  9 +++++-
 .../curator/ensemble/EnsembleProvider.java      | 12 ++++++++
 .../exhibitor/ExhibitorEnsembleProvider.java    | 30 ++++++++++++--------
 .../ensemble/fixed/FixedEnsembleProvider.java   |  6 ++++
 4 files changed, 44 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/6e56e8ae/curator-client/src/main/java/org/apache/curator/ConnectionState.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/ConnectionState.java b/curator-client/src/main/java/org/apache/curator/ConnectionState.java
index 4c1e6ad..0b21643 100644
--- a/curator-client/src/main/java/org/apache/curator/ConnectionState.java
+++ b/curator-client/src/main/java/org/apache/curator/ConnectionState.java
@@ -326,7 +326,14 @@ class ConnectionState implements Watcher, Closeable
             }
             else
             {
-                zooKeeper.updateServerList(newConnectionString);
+                if ( ensembleProvider.updateServerListEnabled() )
+                {
+                    zooKeeper.updateServerList(newConnectionString);
+                }
+                else
+                {
+                    reset();
+                }
             }
         }
         catch ( Exception e )

http://git-wip-us.apache.org/repos/asf/curator/blob/6e56e8ae/curator-client/src/main/java/org/apache/curator/ensemble/EnsembleProvider.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/ensemble/EnsembleProvider.java
b/curator-client/src/main/java/org/apache/curator/ensemble/EnsembleProvider.java
index c03726f..4db8348 100644
--- a/curator-client/src/main/java/org/apache/curator/ensemble/EnsembleProvider.java
+++ b/curator-client/src/main/java/org/apache/curator/ensemble/EnsembleProvider.java
@@ -52,5 +52,17 @@ public interface EnsembleProvider extends Closeable
      */
     public void         close() throws IOException;
 
+    /**
+     * A new connection string event was received
+     *
+     * @param connectionString the new connection string
+     */
     public void setConnectionString(String connectionString);
+
+    /**
+     * Return true if this ensemble provider supports {@link ZooKeeper#updateServerList(String)}
+     *
+     * @return true/false
+     */
+    public boolean updateServerListEnabled();
 }

http://git-wip-us.apache.org/repos/asf/curator/blob/6e56e8ae/curator-client/src/main/java/org/apache/curator/ensemble/exhibitor/ExhibitorEnsembleProvider.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/ensemble/exhibitor/ExhibitorEnsembleProvider.java
b/curator-client/src/main/java/org/apache/curator/ensemble/exhibitor/ExhibitorEnsembleProvider.java
index 4cbf5ee..4573724 100644
--- a/curator-client/src/main/java/org/apache/curator/ensemble/exhibitor/ExhibitorEnsembleProvider.java
+++ b/curator-client/src/main/java/org/apache/curator/ensemble/exhibitor/ExhibitorEnsembleProvider.java
@@ -116,19 +116,19 @@ public class ExhibitorEnsembleProvider implements EnsembleProvider
         Preconditions.checkState(state.compareAndSet(State.LATENT, State.STARTED), "Cannot
be started more than once");
 
         service.scheduleWithFixedDelay
-        (
-            new Runnable()
-            {
-                @Override
-                public void run()
+            (
+                new Runnable()
                 {
-                    poll();
-                }
-            },
-            pollingMs,
-            pollingMs,
-            TimeUnit.MILLISECONDS
-        );
+                    @Override
+                    public void run()
+                    {
+                        poll();
+                    }
+                },
+                pollingMs,
+                pollingMs,
+                TimeUnit.MILLISECONDS
+            );
     }
 
     @Override
@@ -151,6 +151,12 @@ public class ExhibitorEnsembleProvider implements EnsembleProvider
         log.info("setConnectionString received. Ignoring. " + connectionString);
     }
 
+    @Override
+    public boolean updateServerListEnabled()
+    {
+        return false;
+    }
+
     @VisibleForTesting
     protected void poll()
     {

http://git-wip-us.apache.org/repos/asf/curator/blob/6e56e8ae/curator-client/src/main/java/org/apache/curator/ensemble/fixed/FixedEnsembleProvider.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/ensemble/fixed/FixedEnsembleProvider.java
b/curator-client/src/main/java/org/apache/curator/ensemble/fixed/FixedEnsembleProvider.java
index 159497d..28ad1b6 100644
--- a/curator-client/src/main/java/org/apache/curator/ensemble/fixed/FixedEnsembleProvider.java
+++ b/curator-client/src/main/java/org/apache/curator/ensemble/fixed/FixedEnsembleProvider.java
@@ -63,4 +63,10 @@ public class FixedEnsembleProvider implements EnsembleProvider
     {
         return connectionString.get();
     }
+
+    @Override
+    public boolean updateServerListEnabled()
+    {
+        return true;
+    }
 }


Mime
View raw message