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 2015/08/31 16:20:03 UTC
[1/8] curator git commit: CURATOR-239 - Adding RetryForever retry
policy
Repository: curator
Updated Branches:
refs/heads/CURATOR-3.0 fed0bee84 -> d01eabe5b
CURATOR-239 - Adding RetryForever retry policy
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/6e8c1084
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/6e8c1084
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/6e8c1084
Branch: refs/heads/CURATOR-3.0
Commit: 6e8c10847d4b453a1a1aeafcb6c58f51889f2d1f
Parents: 870b4d5
Author: Leandro Nunes <le...@blip.pt>
Authored: Fri Jul 24 00:06:26 2015 +0100
Committer: Leandro Nunes <le...@blip.pt>
Committed: Fri Jul 24 00:06:26 2015 +0100
----------------------------------------------------------------------
.../org/apache/curator/retry/RetryForever.java | 58 ++++++++++++++++++++
.../java/org/apache/curator/TestRetryLoop.java | 20 +++++++
2 files changed, 78 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/6e8c1084/curator-client/src/main/java/org/apache/curator/retry/RetryForever.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/retry/RetryForever.java b/curator-client/src/main/java/org/apache/curator/retry/RetryForever.java
new file mode 100644
index 0000000..27444b9
--- /dev/null
+++ b/curator-client/src/main/java/org/apache/curator/retry/RetryForever.java
@@ -0,0 +1,58 @@
+/**
+ * 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.retry;
+
+import org.apache.curator.RetryPolicy;
+import org.apache.curator.RetrySleeper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.TimeUnit;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ * {@link RetryPolicy} implementation that always <i>allowsRetry</i>.
+ */
+public class RetryForever implements RetryPolicy
+{
+ private static final Logger log = LoggerFactory.getLogger(RetryForever.class);
+
+ private final int retryIntervalMs;
+
+ public RetryForever(int retryIntervalMs)
+ {
+ checkArgument(retryIntervalMs > 0);
+ this.retryIntervalMs = retryIntervalMs;
+ }
+
+ @Override
+ public boolean allowRetry(int retryCount, long elapsedTimeMs, RetrySleeper sleeper)
+ {
+ try
+ {
+ sleeper.sleepFor(retryIntervalMs, TimeUnit.MILLISECONDS);
+ }
+ catch (InterruptedException e)
+ {
+ log.warn("Error occurred while sleeping", e);
+ }
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/6e8c1084/curator-client/src/test/java/org/apache/curator/TestRetryLoop.java
----------------------------------------------------------------------
diff --git a/curator-client/src/test/java/org/apache/curator/TestRetryLoop.java b/curator-client/src/test/java/org/apache/curator/TestRetryLoop.java
index 0fa9020..17bb91e 100644
--- a/curator-client/src/test/java/org/apache/curator/TestRetryLoop.java
+++ b/curator-client/src/test/java/org/apache/curator/TestRetryLoop.java
@@ -19,14 +19,19 @@
package org.apache.curator;
import org.apache.curator.retry.ExponentialBackoffRetry;
+import org.apache.curator.retry.RetryForever;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.BaseClassForTests;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.ZooDefs;
+import org.mockito.Mockito;
import org.testng.Assert;
import org.testng.annotations.Test;
+
import java.util.concurrent.TimeUnit;
+import static org.mockito.Mockito.times;
+
public class TestRetryLoop extends BaseClassForTests
{
@Test
@@ -142,4 +147,19 @@ public class TestRetryLoop extends BaseClassForTests
client.close();
}
}
+
+ @Test
+ public void testRetryForever() throws Exception
+ {
+ int retryIntervalMs = 1;
+ RetrySleeper sleeper = Mockito.mock(RetrySleeper.class);
+ RetryForever retryForever = new RetryForever(retryIntervalMs);
+
+ for (int i = 0; i < 10; i++)
+ {
+ boolean allowed = retryForever.allowRetry(i, 0, sleeper);
+ Assert.assertTrue(allowed);
+ Mockito.verify(sleeper, times(i + 1)).sleepFor(retryIntervalMs, TimeUnit.MILLISECONDS);
+ }
+ }
}
[7/8] curator git commit: return false if interrupted
Posted by ra...@apache.org.
return false if interrupted
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/38011678
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/38011678
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/38011678
Branch: refs/heads/CURATOR-3.0
Commit: 38011678c4faebb1cd9388e56f0d13d29862c609
Parents: 35b2063
Author: randgalt <ra...@apache.org>
Authored: Mon Aug 31 07:19:21 2015 -0700
Committer: randgalt <ra...@apache.org>
Committed: Mon Aug 31 07:19:21 2015 -0700
----------------------------------------------------------------------
.../src/main/java/org/apache/curator/retry/RetryForever.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/38011678/curator-client/src/main/java/org/apache/curator/retry/RetryForever.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/retry/RetryForever.java b/curator-client/src/main/java/org/apache/curator/retry/RetryForever.java
index 89f0276..59f3d0d 100644
--- a/curator-client/src/main/java/org/apache/curator/retry/RetryForever.java
+++ b/curator-client/src/main/java/org/apache/curator/retry/RetryForever.java
@@ -51,8 +51,9 @@ public class RetryForever implements RetryPolicy
}
catch (InterruptedException e)
{
- log.warn("Error occurred while sleeping", e);
Thread.currentThread().interrupt();
+ log.warn("Error occurred while sleeping", e);
+ return false;
}
return true;
}
[8/8] curator git commit: Merge branch 'master' into CURATOR-3.0
Posted by ra...@apache.org.
Merge branch 'master' into CURATOR-3.0
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/d01eabe5
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/d01eabe5
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/d01eabe5
Branch: refs/heads/CURATOR-3.0
Commit: d01eabe5b3ff7624fa2bd423179316931d94c1e5
Parents: fed0bee 3801167
Author: randgalt <ra...@apache.org>
Authored: Mon Aug 31 07:19:53 2015 -0700
Committer: randgalt <ra...@apache.org>
Committed: Mon Aug 31 07:19:53 2015 -0700
----------------------------------------------------------------------
.../org/apache/curator/retry/RetryForever.java | 60 ++++++++++++++++++++
.../java/org/apache/curator/TestRetryLoop.java | 20 +++++++
.../framework/recipes/cache/NodeCache.java | 41 ++++++++++---
curator-x-discovery-server/pom.xml | 6 ++
curator-x-discovery/pom.xml | 6 ++
curator-x-rpc/pom.xml | 6 ++
6 files changed, 132 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/d01eabe5/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/NodeCache.java
----------------------------------------------------------------------
diff --cc curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/NodeCache.java
index 49b9a3f,bfc27d8..8b70db1
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/NodeCache.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/NodeCache.java
@@@ -22,11 -22,10 +22,11 @@@ import com.google.common.annotations.Vi
import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
+
import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.WatcherRemoveCuratorFramework;
import org.apache.curator.framework.api.BackgroundCallback;
import org.apache.curator.framework.api.CuratorEvent;
- import org.apache.curator.framework.api.CuratorWatcher;
import org.apache.curator.framework.listen.ListenerContainer;
import org.apache.curator.framework.state.ConnectionState;
import org.apache.curator.framework.state.ConnectionStateListener;
@@@ -170,10 -178,17 +179,18 @@@ public class NodeCache implements Close
{
if ( state.compareAndSet(State.STARTED, State.CLOSED) )
{
+ client.removeWatchers();
listeners.clear();
- }
- client.getConnectionStateListenable().removeListener(connectionStateListener);
+ client.clearWatcherReferences(watcher);
+ client.getConnectionStateListenable().removeListener(connectionStateListener);
+
+ // TODO
+ // From PathChildrenCache
+ // This seems to enable even more GC - I'm not sure why yet - it
+ // has something to do with Guava's cache and circular references
+ connectionStateListener = null;
+ watcher = null;
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/curator/blob/d01eabe5/curator-x-discovery-server/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/d01eabe5/curator-x-discovery/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/d01eabe5/curator-x-rpc/pom.xml
----------------------------------------------------------------------
[4/8] curator git commit: Merge branch 'CURATOR-234'
Posted by ra...@apache.org.
Merge branch 'CURATOR-234'
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/5dc27c1f
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/5dc27c1f
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/5dc27c1f
Branch: refs/heads/CURATOR-3.0
Commit: 5dc27c1fa9b8e3bc6ed3e1b198bb1eca6b378c9a
Parents: 061ed0a b177ed7
Author: Mike Drob <md...@apache.org>
Authored: Mon Aug 24 10:41:39 2015 -0500
Committer: Mike Drob <md...@apache.org>
Committed: Mon Aug 24 10:41:39 2015 -0500
----------------------------------------------------------------------
curator-x-discovery-server/pom.xml | 6 ++++++
curator-x-discovery/pom.xml | 6 ++++++
curator-x-rpc/pom.xml | 6 ++++++
3 files changed, 18 insertions(+)
----------------------------------------------------------------------
[3/8] curator git commit: CURATOR-234 Add remaining slf4j-log4j12
test deps
Posted by ra...@apache.org.
CURATOR-234 Add remaining slf4j-log4j12 test deps
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/b177ed70
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/b177ed70
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/b177ed70
Branch: refs/heads/CURATOR-3.0
Commit: b177ed709a422f0b06f3a4a3683e5488d038fbb9
Parents: 9a444fa
Author: Mike Drob <md...@apache.org>
Authored: Mon Aug 24 10:40:12 2015 -0500
Committer: Mike Drob <md...@apache.org>
Committed: Mon Aug 24 10:41:09 2015 -0500
----------------------------------------------------------------------
curator-x-discovery-server/pom.xml | 6 ++++++
curator-x-discovery/pom.xml | 6 ++++++
curator-x-rpc/pom.xml | 6 ++++++
3 files changed, 18 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/b177ed70/curator-x-discovery-server/pom.xml
----------------------------------------------------------------------
diff --git a/curator-x-discovery-server/pom.xml b/curator-x-discovery-server/pom.xml
index 2728ce5..4ed7e25 100644
--- a/curator-x-discovery-server/pom.xml
+++ b/curator-x-discovery-server/pom.xml
@@ -108,6 +108,12 @@
<artifactId>resteasy-jaxrs</artifactId>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/curator/blob/b177ed70/curator-x-discovery/pom.xml
----------------------------------------------------------------------
diff --git a/curator-x-discovery/pom.xml b/curator-x-discovery/pom.xml
index 015fea7..9043533 100644
--- a/curator-x-discovery/pom.xml
+++ b/curator-x-discovery/pom.xml
@@ -66,5 +66,11 @@
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/curator/blob/b177ed70/curator-x-rpc/pom.xml
----------------------------------------------------------------------
diff --git a/curator-x-rpc/pom.xml b/curator-x-rpc/pom.xml
index 299ef9f..519e8fb 100644
--- a/curator-x-rpc/pom.xml
+++ b/curator-x-rpc/pom.xml
@@ -118,6 +118,12 @@
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
[5/8] curator git commit: CURATOR-167 - Partial fix to clean up
Curator managed watch objects when the cache closes. A full fix requires the
ability to cancel watches in ZK which is not available until ZK 3.5
Posted by ra...@apache.org.
CURATOR-167 - Partial fix to clean up Curator managed watch objects when
the cache closes. A full fix requires the ability to cancel watches in
ZK which is not available until ZK 3.5
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/8fae7856
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/8fae7856
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/8fae7856
Branch: refs/heads/CURATOR-3.0
Commit: 8fae7856edc1a5269fd012c683860e0b150e13b3
Parents: 5dc27c1
Author: Cameron McKenzie <ca...@unico.com.au>
Authored: Wed Nov 19 14:23:24 2014 +1100
Committer: Cam McKenzie <ca...@apache.org>
Committed: Tue Aug 25 14:06:35 2015 +1000
----------------------------------------------------------------------
.../framework/recipes/cache/NodeCache.java | 41 ++++++++++++++++----
1 file changed, 34 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/8fae7856/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/NodeCache.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/NodeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/NodeCache.java
index 72ee5ff..bfc27d8 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/NodeCache.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/NodeCache.java
@@ -22,19 +22,21 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.api.BackgroundCallback;
import org.apache.curator.framework.api.CuratorEvent;
-import org.apache.curator.framework.api.CuratorWatcher;
import org.apache.curator.framework.listen.ListenerContainer;
import org.apache.curator.framework.state.ConnectionState;
import org.apache.curator.framework.state.ConnectionStateListener;
import org.apache.curator.utils.PathUtils;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.data.Stat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
import java.io.Closeable;
import java.io.IOException;
import java.util.concurrent.Exchanger;
@@ -60,7 +62,7 @@ public class NodeCache implements Closeable
private final AtomicReference<State> state = new AtomicReference<State>(State.LATENT);
private final ListenerContainer<NodeCacheListener> listeners = new ListenerContainer<NodeCacheListener>();
private final AtomicBoolean isConnected = new AtomicBoolean(true);
- private final ConnectionStateListener connectionStateListener = new ConnectionStateListener()
+ private ConnectionStateListener connectionStateListener = new ConnectionStateListener()
{
@Override
public void stateChanged(CuratorFramework client, ConnectionState newState)
@@ -86,12 +88,19 @@ public class NodeCache implements Closeable
}
};
- private final CuratorWatcher watcher = new CuratorWatcher()
+ private Watcher watcher = new Watcher()
{
@Override
- public void process(WatchedEvent event) throws Exception
+ public void process(WatchedEvent event)
{
- reset();
+ try
+ {
+ reset();
+ }
+ catch(Exception e)
+ {
+ handleException(e);
+ }
}
};
@@ -170,8 +179,16 @@ public class NodeCache implements Closeable
if ( state.compareAndSet(State.STARTED, State.CLOSED) )
{
listeners.clear();
- }
- client.getConnectionStateListenable().removeListener(connectionStateListener);
+ client.clearWatcherReferences(watcher);
+ client.getConnectionStateListenable().removeListener(connectionStateListener);
+
+ // TODO
+ // From PathChildrenCache
+ // This seems to enable even more GC - I'm not sure why yet - it
+ // has something to do with Guava's cache and circular references
+ connectionStateListener = null;
+ watcher = null;
+ }
}
/**
@@ -312,4 +329,14 @@ public class NodeCache implements Closeable
}
}
}
+
+ /**
+ * Default behavior is just to log the exception
+ *
+ * @param e the exception
+ */
+ protected void handleException(Throwable e)
+ {
+ log.error("", e);
+ }
}
[6/8] curator git commit: Merge branch 'CURATOR-239' of
github.com:leandronunes85/curator into CURATOR-239
Posted by ra...@apache.org.
Merge branch 'CURATOR-239' of github.com:leandronunes85/curator into CURATOR-239
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/35b20630
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/35b20630
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/35b20630
Branch: refs/heads/CURATOR-3.0
Commit: 35b206307447d9dcc8465c941f644ee9697e4723
Parents: 8fae785 3e3a810
Author: randgalt <ra...@apache.org>
Authored: Mon Aug 31 07:17:23 2015 -0700
Committer: randgalt <ra...@apache.org>
Committed: Mon Aug 31 07:17:23 2015 -0700
----------------------------------------------------------------------
.../org/apache/curator/retry/RetryForever.java | 59 ++++++++++++++++++++
.../java/org/apache/curator/TestRetryLoop.java | 20 +++++++
2 files changed, 79 insertions(+)
----------------------------------------------------------------------
[2/8] curator git commit: CURATOR-239 - Interrupting current thread
after catching InterruptedException
Posted by ra...@apache.org.
CURATOR-239 - Interrupting current thread after catching InterruptedException
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/3e3a8103
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/3e3a8103
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/3e3a8103
Branch: refs/heads/CURATOR-3.0
Commit: 3e3a810312f996874c327f42c24aa5b10a91161a
Parents: 6e8c108
Author: Leandro Nunes <le...@blip.pt>
Authored: Fri Jul 24 00:18:18 2015 +0100
Committer: Leandro Nunes <le...@blip.pt>
Committed: Fri Jul 24 00:18:18 2015 +0100
----------------------------------------------------------------------
.../src/main/java/org/apache/curator/retry/RetryForever.java | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/3e3a8103/curator-client/src/main/java/org/apache/curator/retry/RetryForever.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/retry/RetryForever.java b/curator-client/src/main/java/org/apache/curator/retry/RetryForever.java
index 27444b9..89f0276 100644
--- a/curator-client/src/main/java/org/apache/curator/retry/RetryForever.java
+++ b/curator-client/src/main/java/org/apache/curator/retry/RetryForever.java
@@ -52,6 +52,7 @@ public class RetryForever implements RetryPolicy
catch (InterruptedException e)
{
log.warn("Error occurred while sleeping", e);
+ Thread.currentThread().interrupt();
}
return true;
}