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 2018/06/28 06:03:44 UTC
[01/14] curator git commit: CURATOR-408 Handle graceful close of
ZookKeeper client waiting for all resources to be released
Repository: curator
Updated Branches:
refs/heads/master 5cb22be3d -> d4547b4f4
CURATOR-408 Handle graceful close of ZookKeeper client waiting for all resources to be released
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/fe2c7c4c
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/fe2c7c4c
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/fe2c7c4c
Branch: refs/heads/master
Commit: fe2c7c4cd606c0cf4bc4fab15deedc0f4c33ea0e
Parents: 9383aa3
Author: Enrico Olivelli <eo...@apache.org>
Authored: Mon Jun 11 21:28:30 2018 +0200
Committer: Enrico Olivelli <eo...@apache.org>
Committed: Mon Jun 11 21:28:30 2018 +0200
----------------------------------------------------------------------
.../java/org/apache/curator/ConnectionState.java | 9 ++++++---
.../apache/curator/CuratorZookeeperClient.java | 19 +++++++++++++++----
.../java/org/apache/curator/HandleHolder.java | 10 +++++-----
.../state/TestConnectionStateManager.java | 18 ++++++++++++++++++
pom.xml | 2 +-
5 files changed, 45 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/fe2c7c4c/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 b5af9f2..24b9948 100644
--- a/curator-client/src/main/java/org/apache/curator/ConnectionState.java
+++ b/curator-client/src/main/java/org/apache/curator/ConnectionState.java
@@ -112,14 +112,17 @@ class ConnectionState implements Watcher, Closeable
}
@Override
- public void close() throws IOException
- {
+ public void close() throws IOException {
+ close(0);
+ }
+
+ public void close(int waitForShutdownTimeoutMs) throws IOException {
log.debug("Closing");
CloseableUtils.closeQuietly(ensembleProvider);
try
{
- zooKeeper.closeAndClear();
+ zooKeeper.closeAndClear(waitForShutdownTimeoutMs);
}
catch ( Exception e )
{
http://git-wip-us.apache.org/repos/asf/curator/blob/fe2c7c4c/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java b/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java
index b7bb33a..dd3ae82 100644
--- a/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java
+++ b/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java
@@ -213,18 +213,29 @@ public class CuratorZookeeperClient implements Closeable
state.start();
}
-
+
/**
* Close the client
*/
- public void close()
+ public void close() {
+ close(0);
+ }
+
+ /**
+ * Close this client object as the {@link #close() } method.
+ * This method will wait for internal resources to be released.
+ *
+ * @param waitForShutdownTimeoutMs timeout (in milliseconds) to wait for resources to be released.
+ * Use zero or a negative value to skip the wait.
+ */
+ public void close(int waitForShutdownTimeoutMs)
{
- log.debug("Closing");
+ log.debug("Closing, waitForShutdownTimeoutMs {}", waitForShutdownTimeoutMs);
started.set(false);
try
{
- state.close();
+ state.close(waitForShutdownTimeoutMs);
}
catch ( IOException e )
{
http://git-wip-us.apache.org/repos/asf/curator/blob/fe2c7c4c/curator-client/src/main/java/org/apache/curator/HandleHolder.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/HandleHolder.java b/curator-client/src/main/java/org/apache/curator/HandleHolder.java
index 98b39ce..33250d8 100644
--- a/curator-client/src/main/java/org/apache/curator/HandleHolder.java
+++ b/curator-client/src/main/java/org/apache/curator/HandleHolder.java
@@ -73,15 +73,15 @@ class HandleHolder
return ((helperConnectionString != null) && !ensembleProvider.getConnectionString().equals(helperConnectionString)) ? helperConnectionString : null;
}
- void closeAndClear() throws Exception
+ void closeAndClear(int timeout) throws Exception
{
- internalClose();
+ internalClose(timeout);
helper = null;
}
void closeAndReset() throws Exception
{
- internalClose();
+ internalClose(0);
// first helper is synchronized when getZooKeeper is called. Subsequent calls
// are not synchronized.
@@ -140,7 +140,7 @@ class HandleHolder
};
}
- private void internalClose() throws Exception
+ private void internalClose(int waitForShutdownTimeoutMs) throws Exception
{
try
{
@@ -155,7 +155,7 @@ class HandleHolder
}
};
zooKeeper.register(dummyWatcher); // clear the default watcher so that no new events get processed by mistake
- zooKeeper.close();
+ zooKeeper.close(waitForShutdownTimeoutMs);
}
}
catch ( InterruptedException dummy )
http://git-wip-us.apache.org/repos/asf/curator/blob/fe2c7c4c/curator-framework/src/test/java/org/apache/curator/framework/state/TestConnectionStateManager.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/state/TestConnectionStateManager.java b/curator-framework/src/test/java/org/apache/curator/framework/state/TestConnectionStateManager.java
index e313c56..97ea941 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/state/TestConnectionStateManager.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/state/TestConnectionStateManager.java
@@ -1,3 +1,21 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.curator.framework.state;
import com.google.common.collect.Queues;
http://git-wip-us.apache.org/repos/asf/curator/blob/fe2c7c4c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index c75912b..dd4abdd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -59,7 +59,7 @@
<jdk-version>1.7</jdk-version>
<!-- versions -->
- <zookeeper-version>3.5.3-beta</zookeeper-version>
+ <zookeeper-version>3.5.4-beta</zookeeper-version>
<maven-project-info-reports-plugin-version>2.9</maven-project-info-reports-plugin-version>
<maven-bundle-plugin-version>3.2.0</maven-bundle-plugin-version>
<maven-javadoc-plugin-version>2.10.4</maven-javadoc-plugin-version>
[06/14] curator git commit: rename property
Posted by ra...@apache.org.
rename property
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/633db98c
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/633db98c
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/633db98c
Branch: refs/heads/master
Commit: 633db98c4f0b35f532dbee4f16575449ced9f2cb
Parents: aec1347
Author: Enrico Olivelli <eo...@apache.org>
Authored: Sun Jun 24 18:14:23 2018 +0200
Committer: Enrico Olivelli <eo...@apache.org>
Committed: Sun Jun 24 18:14:23 2018 +0200
----------------------------------------------------------------------
.../main/java/org/apache/curator/CuratorZookeeperClient.java | 8 ++++----
.../apache/curator/framework/CuratorFrameworkFactory.java | 8 ++++----
.../apache/curator/framework/imps/CuratorFrameworkImpl.java | 2 +-
3 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/633db98c/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java b/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java
index 065743b..1981c90 100644
--- a/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java
+++ b/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java
@@ -52,7 +52,7 @@ public class CuratorZookeeperClient implements Closeable
private final ConnectionState state;
private final AtomicReference<RetryPolicy> retryPolicy = new AtomicReference<RetryPolicy>();
private final int connectionTimeoutMs;
- private final int defaultWaitForShutdownTimeoutMs;
+ private final int waitForShutdownTimeoutMs;
private final AtomicBoolean started = new AtomicBoolean(false);
private final AtomicReference<TracerDriver> tracer = new AtomicReference<TracerDriver>(new DefaultTracerDriver());
private final ConnectionHandlingPolicy connectionHandlingPolicy;
@@ -146,7 +146,7 @@ public class CuratorZookeeperClient implements Closeable
ensembleProvider = Preconditions.checkNotNull(ensembleProvider, "ensembleProvider cannot be null");
this.connectionTimeoutMs = connectionTimeoutMs;
- this.defaultWaitForShutdownTimeoutMs = defaultWaitForShutdownTimeoutMs;
+ this.waitForShutdownTimeoutMs = defaultWaitForShutdownTimeoutMs;
state = new ConnectionState(zookeeperFactory, ensembleProvider, sessionTimeoutMs, connectionTimeoutMs, watcher, tracer, canBeReadOnly, connectionHandlingPolicy);
setRetryPolicy(retryPolicy);
}
@@ -240,13 +240,13 @@ public class CuratorZookeeperClient implements Closeable
/**
* Close the client.
*
- * Same as {@link #close(int) } using the default timeout set at construction time.
+ * Same as {@link #close(int) } using the timeout set at construction time.
*
* @see #close(int)
*/
@Override
public void close() {
- close(defaultWaitForShutdownTimeoutMs);
+ close(waitForShutdownTimeoutMs);
}
/**
http://git-wip-us.apache.org/repos/asf/curator/blob/633db98c/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
index dad164e..c1615c5 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
@@ -148,7 +148,7 @@ public class CuratorFrameworkFactory
private ConnectionHandlingPolicy connectionHandlingPolicy = new StandardConnectionHandlingPolicy();
private SchemaSet schemaSet = SchemaSet.getDefaultSchemaSet();
private boolean zk34CompatibilityMode = isZK34();
- private int defaultWaitForShutdownTimeoutMs = 0;
+ private int waitForShutdownTimeoutMs = 0;
/**
* Apply the current values and build a new CuratorFramework
*
@@ -412,7 +412,7 @@ public class CuratorFrameworkFactory
*/
public Builder defaultWaitForShutdownTimeoutMs(int defaultWaitForShutdownTimeoutMs)
{
- this.defaultWaitForShutdownTimeoutMs = defaultWaitForShutdownTimeoutMs;
+ this.waitForShutdownTimeoutMs = defaultWaitForShutdownTimeoutMs;
return this;
}
@@ -509,9 +509,9 @@ public class CuratorFrameworkFactory
return connectionTimeoutMs;
}
- public int getDefaultWaitForShutdownTimeoutMs()
+ public int getWaitForShutdownTimeoutMs()
{
- return defaultWaitForShutdownTimeoutMs;
+ return waitForShutdownTimeoutMs;
}
public int getMaxCloseWaitMs()
http://git-wip-us.apache.org/repos/asf/curator/blob/633db98c/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
index 80a7b56..63809ff 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
@@ -122,7 +122,7 @@ public class CuratorFrameworkImpl implements CuratorFramework
builder.getEnsembleProvider(),
builder.getSessionTimeoutMs(),
builder.getConnectionTimeoutMs(),
- builder.getDefaultWaitForShutdownTimeoutMs(),
+ builder.getWaitForShutdownTimeoutMs(),
new Watcher()
{
@Override
[08/14] curator git commit: Merge branch
'fix/CURATOR-408-close-with-timeout' of github.com:eolivelli/curator into
CURATOR-408
Posted by ra...@apache.org.
Merge branch 'fix/CURATOR-408-close-with-timeout' of github.com:eolivelli/curator into CURATOR-408
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/4d87380a
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/4d87380a
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/4d87380a
Branch: refs/heads/master
Commit: 4d87380a3cb6d321a67b1363655267ed5fc1b57d
Parents: 6f5c5f3 5ad566e
Author: randgalt <ra...@apache.org>
Authored: Sun Jun 24 11:16:07 2018 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sun Jun 24 11:16:07 2018 -0500
----------------------------------------------------------------------
.../main/java/org/apache/curator/CuratorZookeeperClient.java | 8 ++++----
.../apache/curator/framework/CuratorFrameworkFactory.java | 8 ++++----
.../apache/curator/framework/imps/CuratorFrameworkImpl.java | 2 +-
3 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
[03/14] curator git commit: renamed arg
Posted by ra...@apache.org.
renamed arg
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/b6c9420a
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/b6c9420a
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/b6c9420a
Branch: refs/heads/master
Commit: b6c9420a06611c64561cea2c930bd8e51ef440a6
Parents: cfea1fb
Author: randgalt <ra...@apache.org>
Authored: Sun Jun 24 09:16:03 2018 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sun Jun 24 09:16:03 2018 -0500
----------------------------------------------------------------------
.../src/main/java/org/apache/curator/HandleHolder.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/b6c9420a/curator-client/src/main/java/org/apache/curator/HandleHolder.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/HandleHolder.java b/curator-client/src/main/java/org/apache/curator/HandleHolder.java
index 33250d8..6c588cf 100644
--- a/curator-client/src/main/java/org/apache/curator/HandleHolder.java
+++ b/curator-client/src/main/java/org/apache/curator/HandleHolder.java
@@ -73,9 +73,9 @@ class HandleHolder
return ((helperConnectionString != null) && !ensembleProvider.getConnectionString().equals(helperConnectionString)) ? helperConnectionString : null;
}
- void closeAndClear(int timeout) throws Exception
+ void closeAndClear(int waitForShutdownTimeoutMs) throws Exception
{
- internalClose(timeout);
+ internalClose(waitForShutdownTimeoutMs);
helper = null;
}
[09/14] curator git commit: another rename
Posted by ra...@apache.org.
another rename
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/f686ec96
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/f686ec96
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/f686ec96
Branch: refs/heads/master
Commit: f686ec96d1925e1e9462d8082fe685a1462af172
Parents: 5ad566e
Author: Enrico Olivelli <eo...@apache.org>
Authored: Sun Jun 24 18:17:09 2018 +0200
Committer: Enrico Olivelli <eo...@apache.org>
Committed: Sun Jun 24 18:17:09 2018 +0200
----------------------------------------------------------------------
.../org/apache/curator/framework/CuratorFrameworkFactory.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/f686ec96/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
index c1615c5..9979fd6 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
@@ -407,12 +407,12 @@ public class CuratorFrameworkFactory
* The default is 0, which means that this feature is disabled.
*
* @since 4.0.2
- * @param defaultWaitForShutdownTimeoutMs default timeout
+ * @param waitForShutdownTimeoutMs default timeout
* @return this
*/
- public Builder defaultWaitForShutdownTimeoutMs(int defaultWaitForShutdownTimeoutMs)
+ public Builder waitForShutdownTimeoutMs(int waitForShutdownTimeoutMs)
{
- this.waitForShutdownTimeoutMs = defaultWaitForShutdownTimeoutMs;
+ this.waitForShutdownTimeoutMs = waitForShutdownTimeoutMs;
return this;
}
[02/14] curator git commit: Merge branch
'fix/CURATOR-408-close-with-timeout' of github.com:eolivelli/curator into
CURATOR-408
Posted by ra...@apache.org.
Merge branch 'fix/CURATOR-408-close-with-timeout' of github.com:eolivelli/curator into CURATOR-408
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/cfea1fb0
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/cfea1fb0
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/cfea1fb0
Branch: refs/heads/master
Commit: cfea1fb07bba7d367edd4a30fac35d31d9a1dd6d
Parents: ba8ade0 fe2c7c4
Author: randgalt <ra...@apache.org>
Authored: Sun Jun 24 09:13:19 2018 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sun Jun 24 09:13:19 2018 -0500
----------------------------------------------------------------------
.../java/org/apache/curator/ConnectionState.java | 9 ++++++---
.../apache/curator/CuratorZookeeperClient.java | 19 +++++++++++++++----
.../java/org/apache/curator/HandleHolder.java | 10 +++++-----
.../state/TestConnectionStateManager.java | 18 ++++++++++++++++++
pom.xml | 2 +-
5 files changed, 45 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
[11/14] curator git commit: rename method for clarity
Posted by ra...@apache.org.
rename method for clarity
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/586efb5e
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/586efb5e
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/586efb5e
Branch: refs/heads/master
Commit: 586efb5edf2aebd7e50ada51bea53bc60f227f5b
Parents: 4d87380
Author: randgalt <ra...@apache.org>
Authored: Sun Jun 24 11:19:48 2018 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sun Jun 24 11:19:48 2018 -0500
----------------------------------------------------------------------
.../apache/curator/framework/CuratorFrameworkFactory.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/586efb5e/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
index c1615c5..f3daeab 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
@@ -403,16 +403,16 @@ public class CuratorFrameworkFactory
}
/**
- * Set a default timeout for {@link CuratorZookeeperClient#close() }.
+ * Set a timeout for {@link CuratorZookeeperClient#close(int)} }.
* The default is 0, which means that this feature is disabled.
*
* @since 4.0.2
- * @param defaultWaitForShutdownTimeoutMs default timeout
+ * @param waitForShutdownTimeoutMs default timeout
* @return this
*/
- public Builder defaultWaitForShutdownTimeoutMs(int defaultWaitForShutdownTimeoutMs)
+ public Builder waitForShutdownTimeoutMs(int waitForShutdownTimeoutMs)
{
- this.waitForShutdownTimeoutMs = defaultWaitForShutdownTimeoutMs;
+ this.waitForShutdownTimeoutMs = waitForShutdownTimeoutMs;
return this;
}
[10/14] curator git commit: last rename
Posted by ra...@apache.org.
last rename
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/d1d00bc7
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/d1d00bc7
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/d1d00bc7
Branch: refs/heads/master
Commit: d1d00bc7e1cf7f6253c3ce5cb0031ae22791bbf3
Parents: f686ec9
Author: Enrico Olivelli <eo...@apache.org>
Authored: Sun Jun 24 18:18:31 2018 +0200
Committer: Enrico Olivelli <eo...@apache.org>
Committed: Sun Jun 24 18:18:31 2018 +0200
----------------------------------------------------------------------
.../main/java/org/apache/curator/CuratorZookeeperClient.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/d1d00bc7/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java b/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java
index 1981c90..5032117 100644
--- a/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java
+++ b/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java
@@ -122,7 +122,7 @@ public class CuratorZookeeperClient implements Closeable
* @param ensembleProvider the ensemble provider
* @param sessionTimeoutMs session timeout
* @param connectionTimeoutMs connection timeout
- * @param defaultWaitForShutdownTimeoutMs default timeout fo close operation
+ * @param waitForShutdownTimeoutMs default timeout fo close operation
* @param watcher default watcher or null
* @param retryPolicy the retry policy to use
* @param canBeReadOnly if true, allow ZooKeeper client to enter
@@ -133,7 +133,7 @@ public class CuratorZookeeperClient implements Closeable
* @since 4.0.2
*/
public CuratorZookeeperClient(ZookeeperFactory zookeeperFactory, EnsembleProvider ensembleProvider,
- int sessionTimeoutMs, int connectionTimeoutMs, int defaultWaitForShutdownTimeoutMs, Watcher watcher,
+ int sessionTimeoutMs, int connectionTimeoutMs, int waitForShutdownTimeoutMs, Watcher watcher,
RetryPolicy retryPolicy, boolean canBeReadOnly, ConnectionHandlingPolicy connectionHandlingPolicy)
{
this.connectionHandlingPolicy = connectionHandlingPolicy;
@@ -146,7 +146,7 @@ public class CuratorZookeeperClient implements Closeable
ensembleProvider = Preconditions.checkNotNull(ensembleProvider, "ensembleProvider cannot be null");
this.connectionTimeoutMs = connectionTimeoutMs;
- this.waitForShutdownTimeoutMs = defaultWaitForShutdownTimeoutMs;
+ this.waitForShutdownTimeoutMs = waitForShutdownTimeoutMs;
state = new ConnectionState(zookeeperFactory, ensembleProvider, sessionTimeoutMs, connectionTimeoutMs, watcher, tracer, canBeReadOnly, connectionHandlingPolicy);
setRetryPolicy(retryPolicy);
}
[14/14] curator git commit: Merge branch 'master' into CURATOR-408
Posted by ra...@apache.org.
Merge branch 'master' into CURATOR-408
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/d4547b4f
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/d4547b4f
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/d4547b4f
Branch: refs/heads/master
Commit: d4547b4f49bd4599ad89c26998b3391c270587b3
Parents: 1fa4bf6 5cb22be
Author: randgalt <ra...@apache.org>
Authored: Thu Jun 28 01:03:22 2018 -0500
Committer: randgalt <ra...@apache.org>
Committed: Thu Jun 28 01:03:22 2018 -0500
----------------------------------------------------------------------
.../framework/imps/CuratorFrameworkImpl.java | 44 +++++++++-----------
curator-x-async/pom.xml | 12 ------
.../discovery/details/TestServiceCacheRace.java | 18 ++++++++
src/site/site.xml | 2 +-
4 files changed, 38 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/d4547b4f/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
----------------------------------------------------------------------
[05/14] curator git commit: Merge branch
'fix/CURATOR-408-close-with-timeout' of github.com:eolivelli/curator into
CURATOR-408
Posted by ra...@apache.org.
Merge branch 'fix/CURATOR-408-close-with-timeout' of github.com:eolivelli/curator into CURATOR-408
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/6f5c5f3f
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/6f5c5f3f
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/6f5c5f3f
Branch: refs/heads/master
Commit: 6f5c5f3f6760df70e0fa9c1a0f77e2708150c5eb
Parents: b6c9420 aec1347
Author: randgalt <ra...@apache.org>
Authored: Sun Jun 24 11:12:06 2018 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sun Jun 24 11:12:06 2018 -0500
----------------------------------------------------------------------
.../apache/curator/CuratorZookeeperClient.java | 34 ++++++++++++++++++--
.../framework/CuratorFrameworkFactory.java | 22 ++++++++++++-
.../framework/imps/CuratorFrameworkImpl.java | 1 +
3 files changed, 53 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
[07/14] curator git commit: rename to waitForShutdownTimeoutMs
Posted by ra...@apache.org.
rename to waitForShutdownTimeoutMs
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/5ad566ed
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/5ad566ed
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/5ad566ed
Branch: refs/heads/master
Commit: 5ad566ed5d34749d5b37f5fd041d5da939d171db
Parents: 633db98
Author: Enrico Olivelli <eo...@apache.org>
Authored: Sun Jun 24 18:15:29 2018 +0200
Committer: Enrico Olivelli <eo...@apache.org>
Committed: Sun Jun 24 18:15:29 2018 +0200
----------------------------------------------------------------------
.../src/main/java/org/apache/curator/HandleHolder.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/5ad566ed/curator-client/src/main/java/org/apache/curator/HandleHolder.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/HandleHolder.java b/curator-client/src/main/java/org/apache/curator/HandleHolder.java
index 33250d8..6c588cf 100644
--- a/curator-client/src/main/java/org/apache/curator/HandleHolder.java
+++ b/curator-client/src/main/java/org/apache/curator/HandleHolder.java
@@ -73,9 +73,9 @@ class HandleHolder
return ((helperConnectionString != null) && !ensembleProvider.getConnectionString().equals(helperConnectionString)) ? helperConnectionString : null;
}
- void closeAndClear(int timeout) throws Exception
+ void closeAndClear(int waitForShutdownTimeoutMs) throws Exception
{
- internalClose(timeout);
+ internalClose(waitForShutdownTimeoutMs);
helper = null;
}
[13/14] curator git commit: Added a test and moved to Java 8 - needed
by ZK 3.5.4
Posted by ra...@apache.org.
Added a test and moved to Java 8 - needed by ZK 3.5.4
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/1fa4bf6e
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/1fa4bf6e
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/1fa4bf6e
Branch: refs/heads/master
Commit: 1fa4bf6e5a3fedb996609154b3449fb916617b55
Parents: c097e4b
Author: randgalt <ra...@apache.org>
Authored: Sun Jun 24 11:32:46 2018 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sun Jun 24 11:32:46 2018 -0500
----------------------------------------------------------------------
.../curator/framework/imps/TestFramework.java | 46 ++++++++++++++++++++
pom.xml | 2 +-
2 files changed, 47 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/1fa4bf6e/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java
index 0539dbf..0a01679 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java
@@ -35,19 +35,23 @@ import org.apache.curator.test.compatibility.Timing2;
import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.utils.EnsurePath;
import org.apache.curator.utils.ZKPaths;
+import org.apache.curator.utils.ZookeeperFactory;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooDefs;
+import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.ACL;
import org.apache.zookeeper.data.Stat;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingQueue;
@@ -71,6 +75,48 @@ public class TestFramework extends BaseClassForTests
System.clearProperty("znode.container.checkIntervalMs");
super.teardown();
}
+
+ @Test
+ public void testWaitForShutdownTimeoutMs() throws Exception
+ {
+ final BlockingQueue<Integer> timeoutQueue = new ArrayBlockingQueue<>(1);
+ ZookeeperFactory zookeeperFactory = new ZookeeperFactory()
+ {
+ @Override
+ public ZooKeeper newZooKeeper(String connectString, int sessionTimeout, Watcher watcher, boolean canBeReadOnly) throws IOException
+ {
+ return new ZooKeeper(connectString, sessionTimeout, watcher, canBeReadOnly)
+ {
+ @Override
+ public boolean close(int waitForShutdownTimeoutMs) throws InterruptedException
+ {
+ timeoutQueue.add(waitForShutdownTimeoutMs);
+ return super.close(waitForShutdownTimeoutMs);
+ }
+ };
+ }
+ };
+
+ CuratorFramework client = CuratorFrameworkFactory.builder()
+ .connectString(server.getConnectString())
+ .retryPolicy(new RetryOneTime(1))
+ .zookeeperFactory(zookeeperFactory)
+ .waitForShutdownTimeoutMs(10064)
+ .build();
+ try
+ {
+ client.start();
+ client.checkExists().forPath("/foo");
+ }
+ finally
+ {
+ CloseableUtils.closeQuietly(client);
+ }
+
+ Integer polledValue = timeoutQueue.poll(new Timing().milliseconds(), TimeUnit.MILLISECONDS);
+ Assert.assertNotNull(polledValue);
+ Assert.assertEquals(10064, polledValue.intValue());
+ }
@Test
public void testSessionLossWithLongTimeout() throws Exception
http://git-wip-us.apache.org/repos/asf/curator/blob/1fa4bf6e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index dd4abdd..74d015d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -56,7 +56,7 @@
<project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <jdk-version>1.7</jdk-version>
+ <jdk-version>1.8</jdk-version>
<!-- versions -->
<zookeeper-version>3.5.4-beta</zookeeper-version>
[04/14] curator git commit: add defaultWaitForShutdownTimeoutMs
Posted by ra...@apache.org.
add defaultWaitForShutdownTimeoutMs
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/aec13472
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/aec13472
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/aec13472
Branch: refs/heads/master
Commit: aec134724a500120a11542d43659a676562b03a1
Parents: fe2c7c4
Author: Enrico Olivelli <eo...@apache.org>
Authored: Sun Jun 24 18:05:11 2018 +0200
Committer: Enrico Olivelli <eo...@apache.org>
Committed: Sun Jun 24 18:05:11 2018 +0200
----------------------------------------------------------------------
.../apache/curator/CuratorZookeeperClient.java | 34 ++++++++++++++++++--
.../framework/CuratorFrameworkFactory.java | 22 ++++++++++++-
.../framework/imps/CuratorFrameworkImpl.java | 1 +
3 files changed, 53 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/aec13472/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java b/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java
index dd3ae82..065743b 100644
--- a/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java
+++ b/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java
@@ -52,6 +52,7 @@ public class CuratorZookeeperClient implements Closeable
private final ConnectionState state;
private final AtomicReference<RetryPolicy> retryPolicy = new AtomicReference<RetryPolicy>();
private final int connectionTimeoutMs;
+ private final int defaultWaitForShutdownTimeoutMs;
private final AtomicBoolean started = new AtomicBoolean(false);
private final AtomicReference<TracerDriver> tracer = new AtomicReference<TracerDriver>(new DefaultTracerDriver());
private final ConnectionHandlingPolicy connectionHandlingPolicy;
@@ -112,7 +113,28 @@ public class CuratorZookeeperClient implements Closeable
* @param connectionHandlingPolicy connection handling policy - use one of the pre-defined policies or write your own
* @since 3.0.0
*/
- public CuratorZookeeperClient(ZookeeperFactory zookeeperFactory, EnsembleProvider ensembleProvider, int sessionTimeoutMs, int connectionTimeoutMs, Watcher watcher, RetryPolicy retryPolicy, boolean canBeReadOnly, ConnectionHandlingPolicy connectionHandlingPolicy)
+ public CuratorZookeeperClient(ZookeeperFactory zookeeperFactory, EnsembleProvider ensembleProvider, int sessionTimeoutMs, int connectionTimeoutMs, Watcher watcher, RetryPolicy retryPolicy, boolean canBeReadOnly, ConnectionHandlingPolicy connectionHandlingPolicy) {
+ this(zookeeperFactory, ensembleProvider, sessionTimeoutMs, connectionTimeoutMs, 0,
+ watcher, retryPolicy, canBeReadOnly, connectionHandlingPolicy);
+ }
+ /**
+ * @param zookeeperFactory factory for creating {@link ZooKeeper} instances
+ * @param ensembleProvider the ensemble provider
+ * @param sessionTimeoutMs session timeout
+ * @param connectionTimeoutMs connection timeout
+ * @param defaultWaitForShutdownTimeoutMs default timeout fo close operation
+ * @param watcher default watcher or null
+ * @param retryPolicy the retry policy to use
+ * @param canBeReadOnly if true, allow ZooKeeper client to enter
+ * read only mode in case of a network partition. See
+ * {@link ZooKeeper#ZooKeeper(String, int, Watcher, long, byte[], boolean)}
+ * for details
+ * @param connectionHandlingPolicy connection handling policy - use one of the pre-defined policies or write your own
+ * @since 4.0.2
+ */
+ public CuratorZookeeperClient(ZookeeperFactory zookeeperFactory, EnsembleProvider ensembleProvider,
+ int sessionTimeoutMs, int connectionTimeoutMs, int defaultWaitForShutdownTimeoutMs, Watcher watcher,
+ RetryPolicy retryPolicy, boolean canBeReadOnly, ConnectionHandlingPolicy connectionHandlingPolicy)
{
this.connectionHandlingPolicy = connectionHandlingPolicy;
if ( sessionTimeoutMs < connectionTimeoutMs )
@@ -124,6 +146,7 @@ public class CuratorZookeeperClient implements Closeable
ensembleProvider = Preconditions.checkNotNull(ensembleProvider, "ensembleProvider cannot be null");
this.connectionTimeoutMs = connectionTimeoutMs;
+ this.defaultWaitForShutdownTimeoutMs = defaultWaitForShutdownTimeoutMs;
state = new ConnectionState(zookeeperFactory, ensembleProvider, sessionTimeoutMs, connectionTimeoutMs, watcher, tracer, canBeReadOnly, connectionHandlingPolicy);
setRetryPolicy(retryPolicy);
}
@@ -215,10 +238,15 @@ public class CuratorZookeeperClient implements Closeable
}
/**
- * Close the client
+ * Close the client.
+ *
+ * Same as {@link #close(int) } using the default timeout set at construction time.
+ *
+ * @see #close(int)
*/
+ @Override
public void close() {
- close(0);
+ close(defaultWaitForShutdownTimeoutMs);
}
/**
http://git-wip-us.apache.org/repos/asf/curator/blob/aec13472/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
index a617198..dad164e 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
@@ -49,6 +49,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
+import org.apache.curator.CuratorZookeeperClient;
import static org.apache.curator.utils.Compatibility.isZK34;
@@ -147,7 +148,7 @@ public class CuratorFrameworkFactory
private ConnectionHandlingPolicy connectionHandlingPolicy = new StandardConnectionHandlingPolicy();
private SchemaSet schemaSet = SchemaSet.getDefaultSchemaSet();
private boolean zk34CompatibilityMode = isZK34();
-
+ private int defaultWaitForShutdownTimeoutMs = 0;
/**
* Apply the current values and build a new CuratorFramework
*
@@ -402,6 +403,20 @@ public class CuratorFrameworkFactory
}
/**
+ * Set a default timeout for {@link CuratorZookeeperClient#close() }.
+ * The default is 0, which means that this feature is disabled.
+ *
+ * @since 4.0.2
+ * @param defaultWaitForShutdownTimeoutMs default timeout
+ * @return this
+ */
+ public Builder defaultWaitForShutdownTimeoutMs(int defaultWaitForShutdownTimeoutMs)
+ {
+ this.defaultWaitForShutdownTimeoutMs = defaultWaitForShutdownTimeoutMs;
+ return this;
+ }
+
+ /**
* <p>
* Change the connection handling policy. The default policy is {@link StandardConnectionHandlingPolicy}.
* </p>
@@ -494,6 +509,11 @@ public class CuratorFrameworkFactory
return connectionTimeoutMs;
}
+ public int getDefaultWaitForShutdownTimeoutMs()
+ {
+ return defaultWaitForShutdownTimeoutMs;
+ }
+
public int getMaxCloseWaitMs()
{
return maxCloseWaitMs;
http://git-wip-us.apache.org/repos/asf/curator/blob/aec13472/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
index 2bd5c7c..80a7b56 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
@@ -122,6 +122,7 @@ public class CuratorFrameworkImpl implements CuratorFramework
builder.getEnsembleProvider(),
builder.getSessionTimeoutMs(),
builder.getConnectionTimeoutMs(),
+ builder.getDefaultWaitForShutdownTimeoutMs(),
new Watcher()
{
@Override
[12/14] curator git commit: Merge branch
'fix/CURATOR-408-close-with-timeout' of github.com:eolivelli/curator into
CURATOR-408
Posted by ra...@apache.org.
Merge branch 'fix/CURATOR-408-close-with-timeout' of github.com:eolivelli/curator into CURATOR-408
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/c097e4b3
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/c097e4b3
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/c097e4b3
Branch: refs/heads/master
Commit: c097e4b3f591c22b72c28a9c28d4e8d97d45e037
Parents: 586efb5 d1d00bc
Author: randgalt <ra...@apache.org>
Authored: Sun Jun 24 11:20:07 2018 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sun Jun 24 11:20:07 2018 -0500
----------------------------------------------------------------------
.../main/java/org/apache/curator/CuratorZookeeperClient.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------