You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2017/01/09 16:25:11 UTC

[1/4] curator git commit: Introduced hostname to InstanceSpec so that the TestingServer can be bound to other interfaces in a machine other than localhost (127.0.01)

Repository: curator
Updated Branches:
  refs/heads/master b4cbe4ba1 -> 144977f8b


Introduced hostname to InstanceSpec so that the TestingServer can be bound to other interfaces in a machine other than localhost (127.0.01)


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

Branch: refs/heads/master
Commit: a8a5d46cca4a6257d7f8edce9f3d21af3526847b
Parents: ee5d654
Author: Imesha <im...@gmail.com>
Authored: Tue Nov 29 15:24:37 2016 +0530
Committer: Imesha <im...@gmail.com>
Committed: Tue Nov 29 15:24:37 2016 +0530

----------------------------------------------------------------------
 .../org/apache/curator/test/InstanceSpec.java   | 34 +++++++++++++++++---
 .../curator/test/QuorumConfigBuilder.java       |  2 +-
 2 files changed, 30 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/a8a5d46c/curator-test/src/main/java/org/apache/curator/test/InstanceSpec.java
----------------------------------------------------------------------
diff --git a/curator-test/src/main/java/org/apache/curator/test/InstanceSpec.java b/curator-test/src/main/java/org/apache/curator/test/InstanceSpec.java
index 32b1738..bc0272c 100644
--- a/curator-test/src/main/java/org/apache/curator/test/InstanceSpec.java
+++ b/curator-test/src/main/java/org/apache/curator/test/InstanceSpec.java
@@ -72,6 +72,7 @@ public class InstanceSpec
     private final int tickTime;
     private final int maxClientCnxns;
     private final Map<String,Object> customProperties;
+    private final String hostname;
 
     public static InstanceSpec newInstanceSpec()
     {
@@ -116,7 +117,7 @@ public class InstanceSpec
      */
     public InstanceSpec(File dataDirectory, int port, int electionPort, int quorumPort, boolean deleteDataDirectoryOnClose, int serverId)
     {
-        this(dataDirectory, port, electionPort, quorumPort, deleteDataDirectoryOnClose, serverId, -1, -1, null);
+        this(dataDirectory, port, electionPort, quorumPort, deleteDataDirectoryOnClose, serverId, -1, -1, null, null);
     }
 
     /**
@@ -130,7 +131,7 @@ public class InstanceSpec
      * @param maxClientCnxns             max number of client connections from the same IP. Set -1 to use default server configuration
      */
     public InstanceSpec(File dataDirectory, int port, int electionPort, int quorumPort, boolean deleteDataDirectoryOnClose, int serverId, int tickTime, int maxClientCnxns) {
-        this(dataDirectory, port, electionPort, quorumPort, deleteDataDirectoryOnClose, serverId, tickTime, maxClientCnxns, null);
+        this(dataDirectory, port, electionPort, quorumPort, deleteDataDirectoryOnClose, serverId, tickTime, maxClientCnxns, null, null);
     }
 
     /**
@@ -146,6 +147,23 @@ public class InstanceSpec
      */
     public InstanceSpec(File dataDirectory, int port, int electionPort, int quorumPort, boolean deleteDataDirectoryOnClose, int serverId, int tickTime, int maxClientCnxns, Map<String,Object> customProperties)
     {
+        this(dataDirectory, port, electionPort, quorumPort, deleteDataDirectoryOnClose, serverId, tickTime, maxClientCnxns, customProperties, null);
+    }
+
+    /**
+     * @param dataDirectory              where to store data/logs/etc.
+     * @param port                       the port to listen on - each server in the ensemble must use a unique port
+     * @param electionPort               the electionPort to listen on - each server in the ensemble must use a unique electionPort
+     * @param quorumPort                 the quorumPort to listen on - each server in the ensemble must use a unique quorumPort
+     * @param deleteDataDirectoryOnClose if true, the data directory will be deleted when {@link TestingCluster#close()} is called
+     * @param serverId                   the server ID for the instance
+     * @param tickTime                   tickTime. Set -1 to used fault server configuration
+     * @param maxClientCnxns             max number of client connections from the same IP. Set -1 to use default server configuration
+     * @param customProperties           other properties to be passed to the server
+     * @param hostname                   Hostname or IP if the cluster is intending to be bounded into external interfaces
+     */
+    public InstanceSpec(File dataDirectory, int port, int electionPort, int quorumPort, boolean deleteDataDirectoryOnClose, int serverId, int tickTime, int maxClientCnxns, Map<String,Object> customProperties,String hostname)
+    {
         this.dataDirectory = (dataDirectory != null) ? dataDirectory : Files.createTempDir();
         this.port = (port >= 0) ? port : getRandomPort();
         this.electionPort = (electionPort >= 0) ? electionPort : getRandomPort();
@@ -155,6 +173,7 @@ public class InstanceSpec
         this.tickTime = (tickTime > 0 ? tickTime : -1); // -1 to set default value
         this.maxClientCnxns = (maxClientCnxns >= 0 ? maxClientCnxns : -1); // -1 to set default value
         this.customProperties = customProperties != null ? Collections.<String,Object>unmodifiableMap(customProperties) : Collections.<String,Object>emptyMap();
+        this.hostname = hostname == null ? localhost : hostname;
     }
 
     public int getServerId()
@@ -184,7 +203,7 @@ public class InstanceSpec
 
     public String getConnectString()
     {
-        return localhost + ":" + port;
+        return hostname + ":" + port;
     }
 
     public int getTickTime()
@@ -206,6 +225,10 @@ public class InstanceSpec
         return customProperties;
     }
 
+    public String getHostname() {
+        return hostname;
+    }
+
     @Override
     public String toString()
     {
@@ -219,6 +242,7 @@ public class InstanceSpec
             ", tickTime=" + tickTime +
             ", maxClientCnxns=" + maxClientCnxns +
             ", customProperties=" + customProperties +
+            ", hostname=" + hostname +
             "} " + super.toString();
     }
 
@@ -236,13 +260,13 @@ public class InstanceSpec
 
         InstanceSpec that = (InstanceSpec)o;
 
-        return port == that.port;
+        return hostname.equals(that.getHostname()) && port == that.port;
 
     }
 
     @Override
     public int hashCode()
     {
-        return port;
+        return hostname.hashCode() + port;
     }
 }

http://git-wip-us.apache.org/repos/asf/curator/blob/a8a5d46c/curator-test/src/main/java/org/apache/curator/test/QuorumConfigBuilder.java
----------------------------------------------------------------------
diff --git a/curator-test/src/main/java/org/apache/curator/test/QuorumConfigBuilder.java b/curator-test/src/main/java/org/apache/curator/test/QuorumConfigBuilder.java
index 4e20163..fb4039d 100644
--- a/curator-test/src/main/java/org/apache/curator/test/QuorumConfigBuilder.java
+++ b/curator-test/src/main/java/org/apache/curator/test/QuorumConfigBuilder.java
@@ -100,7 +100,7 @@ public class QuorumConfigBuilder
         {
             for ( InstanceSpec thisSpec : instanceSpecs )
             {
-                properties.setProperty("server." + thisSpec.getServerId(), String.format("localhost:%d:%d", thisSpec.getQuorumPort(), thisSpec.getElectionPort()));
+                properties.setProperty("server." + thisSpec.getServerId(), String.format("%s:%d:%d", thisSpec.getHostname(), thisSpec.getQuorumPort(), thisSpec.getElectionPort()));
             }
         }
         Map<String,Object> customProperties = spec.getCustomProperties();


[4/4] curator git commit: Merge branch 'CURATOR-364' of github.com:IMS94/curator into CURATOR-364

Posted by ra...@apache.org.
Merge branch 'CURATOR-364' of github.com:IMS94/curator into CURATOR-364


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

Branch: refs/heads/master
Commit: 144977f8bc94115fac53163f81310aff0d50c78d
Parents: b4cbe4b ea710f4
Author: randgalt <ra...@apache.org>
Authored: Mon Jan 9 11:23:48 2017 -0500
Committer: randgalt <ra...@apache.org>
Committed: Mon Jan 9 11:23:48 2017 -0500

----------------------------------------------------------------------
 .../apache/curator/framework/recipes/nodes/PersistentNode.java  | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------



[2/4] curator git commit: Merge branch 'master' of https://github.com/apache/curator

Posted by ra...@apache.org.
Merge branch 'master' of https://github.com/apache/curator


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

Branch: refs/heads/master
Commit: 140342045e15876e610d5adee5eda5723d00f09d
Parents: a8a5d46 82a8906
Author: Imesha <im...@gmail.com>
Authored: Tue Dec 13 08:24:00 2016 +0530
Committer: Imesha <im...@gmail.com>
Committed: Tue Dec 13 08:24:00 2016 +0530

----------------------------------------------------------------------
 .../org/apache/curator/framework/imps/NamespaceImpl.java  |  2 +-
 .../curator/framework/imps/TestNamespaceFacade.java       | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------



[3/4] curator git commit: CURATOR-364 - Moved createMode=client.create() segment to createNode() method

Posted by ra...@apache.org.
CURATOR-364 - Moved createMode=client.create() segment to createNode() method


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

Branch: refs/heads/master
Commit: ea710f4ed62aed1a3a8f324280d1592a7c23b8e0
Parents: 1403420
Author: Imesha <im...@gmail.com>
Authored: Thu Dec 15 12:48:15 2016 +0530
Committer: Imesha <im...@gmail.com>
Committed: Thu Dec 15 12:48:15 2016 +0530

----------------------------------------------------------------------
 .../apache/curator/framework/recipes/nodes/PersistentNode.java  | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/ea710f4e/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentNode.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentNode.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentNode.java
index 5f94ea1..45f74ca 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentNode.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentNode.java
@@ -60,7 +60,6 @@ public class PersistentNode implements Closeable
     private final AtomicReference<CountDownLatch> initialCreateLatch = new AtomicReference<CountDownLatch>(new CountDownLatch(1));
     private final Logger log = LoggerFactory.getLogger(getClass());
     private final CuratorFramework client;
-    private final CreateModable<ACLBackgroundPathAndBytesable<String>> createMethod;
     private final AtomicReference<String> nodePath = new AtomicReference<String>(null);
     private final String basePath;
     private final CreateMode mode;
@@ -170,7 +169,6 @@ public class PersistentNode implements Closeable
             }
         };
 
-        createMethod = useProtection ? client.create().creatingParentContainersIfNeeded().withProtection() : client.create().creatingParentContainersIfNeeded();
         this.data.set(Arrays.copyOf(data, data.length));
     }
 
@@ -365,6 +363,9 @@ public class PersistentNode implements Closeable
         {
             String existingPath = nodePath.get();
             String createPath = (existingPath != null && !useProtection) ? existingPath : basePath;
+
+            CreateModable<ACLBackgroundPathAndBytesable<String>> createMethod = useProtection ?
+                    client.create().creatingParentContainersIfNeeded().withProtection() : client.create().creatingParentContainersIfNeeded();
             createMethod.withMode(getCreateMode(existingPath != null)).inBackground(backgroundCallback).forPath(createPath, data.get());
         }
         catch ( Exception e )