curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject [3/7] git commit: CURATOR-110 - Modified the enum to have an abstract isConnected() method that can be overridden by each enum instance.
Date Mon, 16 Jun 2014 17:40:54 GMT
CURATOR-110 - Modified the enum to have an abstract isConnected() method
that can be overridden by each enum instance.

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

Branch: refs/heads/CURATOR-110
Commit: 2c376b9f51d6eab4340651abce3284f358bedbc7
Parents: 0b7ae7e
Author: Cameron McKenzie <cameron@unico.com.au>
Authored: Wed Jun 4 10:24:31 2014 +1000
Committer: Cameron McKenzie <cameron@unico.com.au>
Committed: Wed Jun 4 10:24:31 2014 +1000

----------------------------------------------------------------------
 .../framework/state/ConnectionState.java        | 45 ++++++++++++++++----
 1 file changed, 36 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/2c376b9f/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionState.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionState.java
b/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionState.java
index 7663e10..2e08b34 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionState.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionState.java
@@ -29,26 +29,50 @@ public enum ConnectionState
      * Sent for the first successful connection to the server. NOTE: You will only
      * get one of these messages for any CuratorFramework instance.
      */
-    CONNECTED,
+    CONNECTED
+    {
+        public boolean isConnected()
+        {
+            return true;
+        }
+    },
 
     /**
      * There has been a loss of connection. Leaders, locks, etc. should suspend
      * until the connection is re-established. If the connection times-out you will
      * receive a {@link #LOST} notice
      */
-    SUSPENDED,
+    SUSPENDED
+    {
+        public boolean isConnected()
+        {
+            return false;
+        }
+    },    
 
     /**
      * A suspended or read-only connection has been re-established
      */
-    RECONNECTED,
+    RECONNECTED
+    {
+        public boolean isConnected()
+        {
+            return true;
+        }
+    },
 
     /**
      * The connection is confirmed to be lost. Close any locks, leaders, etc. and
      * attempt to re-create them. NOTE: it is possible to get a {@link #RECONNECTED}
      * state after this but you should still consider any locks, etc. as dirty/unstable
      */
-    LOST,
+    LOST
+    {
+        public boolean isConnected()
+        {
+            return false;
+        }
+    },
 
     /**
      * The connection has gone into read-only mode. This can only happen if you pass true
@@ -57,15 +81,18 @@ public enum ConnectionState
      * <a href="http://wiki.apache.org/hadoop/ZooKeeper/GSoCReadOnlyMode">http://wiki.apache.org/hadoop/ZooKeeper/GSoCReadOnlyMode</a>.
      * The connection will remain in read only mode until another state change is sent.
      */
-    READ_ONLY;
+    READ_ONLY
+    {
+        public boolean isConnected()
+        {
+            return true;
+        }
+    };
     
     /**
      * Check if this state indicates that Curator has a connection to ZooKeeper
      * 
      * @return True if connected, false otherwise
      */
-    public boolean isConnected()
-    {
-        return this == CONNECTED || this == RECONNECTED || this == READ_ONLY;
-    }
+    public abstract boolean isConnected();
 }


Mime
View raw message