curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject [3/4] curator git commit: added an enum method to indicate if a ServiceType.isDynamic()
Date Mon, 28 Mar 2016 22:39:57 GMT
added an enum method to indicate if a ServiceType.isDynamic()


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

Branch: refs/heads/master
Commit: 0b088ffba5288da07332ac6df4be89e9b6d6dd36
Parents: b75f92b
Author: nirdothan <nir.dothan@gmail.com>
Authored: Tue Mar 22 12:36:05 2016 +0200
Committer: nirdothan <nir.dothan@gmail.com>
Committed: Tue Mar 22 12:36:05 2016 +0200

----------------------------------------------------------------------
 .../server/rest/DiscoveryResource.java          |  2 +-
 .../apache/curator/x/discovery/ServiceType.java |  6 ++++-
 .../discovery/details/ServiceDiscoveryImpl.java | 24 ++++++++++----------
 3 files changed, 18 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/0b088ffb/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/rest/DiscoveryResource.java
----------------------------------------------------------------------
diff --git a/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/rest/DiscoveryResource.java
b/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/rest/DiscoveryResource.java
index 49c550b..f84a333 100644
--- a/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/rest/DiscoveryResource.java
+++ b/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/rest/DiscoveryResource.java
@@ -90,7 +90,7 @@ public abstract class DiscoveryResource<T>
             return Response.status(Response.Status.BAD_REQUEST).build();
         }
         
-        if ( instance.getServiceType() == ServiceType.DYNAMIC || instance.getServiceType()
== ServiceType.DYNAMIC_SEQUENTIAL )
+        if ( instance.getServiceType().isDynamic() )
         {
             log.info("Service type cannot be dynamic");
             return Response.status(Response.Status.BAD_REQUEST).build();

http://git-wip-us.apache.org/repos/asf/curator/blob/0b088ffb/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/ServiceType.java
----------------------------------------------------------------------
diff --git a/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/ServiceType.java
b/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/ServiceType.java
index 3268e62..d076cdc 100644
--- a/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/ServiceType.java
+++ b/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/ServiceType.java
@@ -23,5 +23,9 @@ public enum ServiceType
     DYNAMIC,
     STATIC,
     PERMANENT, 
-    DYNAMIC_SEQUENTIAL
+    DYNAMIC_SEQUENTIAL;
+
+	public boolean isDynamic() {
+		return this == DYNAMIC || this == DYNAMIC_SEQUENTIAL;
+	}
 }

http://git-wip-us.apache.org/repos/asf/curator/blob/0b088ffb/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java
----------------------------------------------------------------------
diff --git a/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java
b/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java
index d0f21d4..762c9a8 100644
--- a/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java
+++ b/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java
@@ -220,18 +220,18 @@ public class ServiceDiscoveryImpl<T> implements ServiceDiscovery<T>
         {
             try
             {
-            	CreateMode mode;
-            	switch (service.getServiceType()){
-            	case DYNAMIC:
-            		mode =  CreateMode.EPHEMERAL;
-            		break; 
-            	case  DYNAMIC_SEQUENTIAL:
-            		mode =  CreateMode.EPHEMERAL_SEQUENTIAL;
-            		break; 
-            	default:
-            		mode = CreateMode.PERSISTENT;
-            		break; 
-            	}
+				CreateMode mode;
+				switch (service.getServiceType()) {
+				case DYNAMIC:
+					mode = CreateMode.EPHEMERAL;
+					break;
+				case DYNAMIC_SEQUENTIAL:
+					mode = CreateMode.EPHEMERAL_SEQUENTIAL;
+					break;
+				default:
+					mode = CreateMode.PERSISTENT;
+					break;
+				}
                 client.create().creatingParentContainersIfNeeded().withMode(mode).forPath(path,
bytes);
                 isDone = true;
             }


Mime
View raw message