You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ca...@apache.org on 2016/07/28 00:51:50 UTC
[1/3] curator git commit: TreeCache does not need to use
CloseableExecutorService.
Repository: curator
Updated Branches:
refs/heads/CURATOR-3.0 25ddaeb0d -> ff169d6e8
TreeCache does not need to use CloseableExecutorService.
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/ba85368e
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/ba85368e
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/ba85368e
Branch: refs/heads/CURATOR-3.0
Commit: ba85368e9aa461320071fb872f02b5c3b6619c14
Parents: 1f411fc
Author: Scott Blum <dr...@apache.org>
Authored: Thu Jul 21 18:19:12 2016 -0400
Committer: Scott Blum <dr...@apache.org>
Committed: Thu Jul 21 18:19:12 2016 -0400
----------------------------------------------------------------------
.../framework/recipes/cache/TreeCache.java | 32 +++++---------------
1 file changed, 8 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/ba85368e/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
index 95b8b99..906d23d 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
@@ -32,7 +32,6 @@ import org.apache.curator.framework.listen.Listenable;
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.CloseableExecutorService;
import org.apache.curator.utils.PathUtils;
import org.apache.curator.utils.ThreadUtils;
import org.apache.curator.utils.ZKPaths;
@@ -80,7 +79,7 @@ public class TreeCache implements Closeable
private final String path;
private boolean cacheData = true;
private boolean dataIsCompressed = false;
- private CloseableExecutorService executorService = null;
+ private ExecutorService executorService = null;
private int maxDepth = Integer.MAX_VALUE;
private boolean createParentNodes = false;
private TreeCacheSelector selector = new DefaultTreeCacheSelector();
@@ -96,10 +95,10 @@ public class TreeCache implements Closeable
*/
public TreeCache build()
{
- CloseableExecutorService executor = executorService;
+ ExecutorService executor = executorService;
if ( executor == null )
{
- executor = new CloseableExecutorService(Executors.newSingleThreadExecutor(defaultThreadFactory));
+ executor = Executors.newSingleThreadExecutor(defaultThreadFactory);
}
return new TreeCache(client, path, cacheData, dataIsCompressed, maxDepth, executor, createParentNodes, selector);
}
@@ -127,7 +126,7 @@ public class TreeCache implements Closeable
*/
public Builder setExecutor(ThreadFactory threadFactory)
{
- return setExecutor(new CloseableExecutorService(Executors.newSingleThreadExecutor(threadFactory)));
+ return setExecutor(Executors.newSingleThreadExecutor(threadFactory));
}
/**
@@ -135,21 +134,6 @@ public class TreeCache implements Closeable
*/
public Builder setExecutor(ExecutorService executorService)
{
- if ( executorService instanceof CloseableExecutorService )
- {
- return setExecutor((CloseableExecutorService)executorService);
- }
- else
- {
- return setExecutor(new CloseableExecutorService(executorService));
- }
- }
-
- /**
- * Sets the executor to publish events; a default executor will be created if not specified.
- */
- public Builder setExecutor(CloseableExecutorService executorService)
- {
this.executorService = checkNotNull(executorService);
return this;
}
@@ -515,7 +499,7 @@ public class TreeCache implements Closeable
private final TreeNode root;
private final CuratorFramework client;
- private final CloseableExecutorService executorService;
+ private final ExecutorService executorService;
private final boolean cacheData;
private final boolean dataIsCompressed;
private final int maxDepth;
@@ -549,7 +533,7 @@ public class TreeCache implements Closeable
*/
public TreeCache(CuratorFramework client, String path)
{
- this(client, path, true, false, Integer.MAX_VALUE, new CloseableExecutorService(Executors.newSingleThreadExecutor(defaultThreadFactory), true), false, new DefaultTreeCacheSelector());
+ this(client, path, true, false, Integer.MAX_VALUE, Executors.newSingleThreadExecutor(defaultThreadFactory), false, new DefaultTreeCacheSelector());
}
/**
@@ -561,7 +545,7 @@ public class TreeCache implements Closeable
* @param createParentNodes true to create parent nodes as containers
* @param selector the selector to use
*/
- TreeCache(CuratorFramework client, String path, boolean cacheData, boolean dataIsCompressed, int maxDepth, final CloseableExecutorService executorService, boolean createParentNodes, TreeCacheSelector selector)
+ TreeCache(CuratorFramework client, String path, boolean cacheData, boolean dataIsCompressed, int maxDepth, final ExecutorService executorService, boolean createParentNodes, TreeCacheSelector selector)
{
this.createParentNodes = createParentNodes;
this.selector = Preconditions.checkNotNull(selector, "selector cannot be null");
@@ -604,7 +588,7 @@ public class TreeCache implements Closeable
{
client.getConnectionStateListenable().removeListener(connectionStateListener);
listeners.clear();
- executorService.close();
+ executorService.shutdown();
try
{
root.wasDeleted();
[2/3] curator git commit: CURATOR-337: Do not attempt to release a
mutex unless it has actually been acquired
Posted by ca...@apache.org.
CURATOR-337: Do not attempt to release a mutex unless it has actually been acquired
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/6cebfc13
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/6cebfc13
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/6cebfc13
Branch: refs/heads/CURATOR-3.0
Commit: 6cebfc13ccdcd9cb2a5b576fa369b957e651752a
Parents: ba85368
Author: Mark Payne <ma...@hotmail.com>
Authored: Wed Jul 27 20:23:13 2016 -0400
Committer: Mark Payne <ma...@hotmail.com>
Committed: Wed Jul 27 20:23:13 2016 -0400
----------------------------------------------------------------------
.../recipes/leader/LeaderSelector.java | 21 +++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/6cebfc13/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderSelector.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderSelector.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderSelector.java
index ec33533..c177302 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderSelector.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderSelector.java
@@ -419,16 +419,19 @@ public class LeaderSelector implements Closeable
}
finally
{
- hasLeadership = false;
- try
- {
- mutex.release();
- }
- catch ( Exception e )
+ if ( hasLeadership )
{
- ThreadUtils.checkInterrupted(e);
- log.error("The leader threw an exception", e);
- // ignore errors - this is just a safety
+ hasLeadership = false;
+ try
+ {
+ mutex.release();
+ }
+ catch ( Exception e )
+ {
+ ThreadUtils.checkInterrupted(e);
+ log.error("The leader threw an exception", e);
+ // ignore errors - this is just a safety
+ }
}
}
}
[3/3] curator git commit: Merge branch 'master' into CURATOR-3.0
Posted by ca...@apache.org.
Merge branch 'master' into CURATOR-3.0
Conflicts:
curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/ff169d6e
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/ff169d6e
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/ff169d6e
Branch: refs/heads/CURATOR-3.0
Commit: ff169d6e8da4740c254fb18a742f90ab012c3b4b
Parents: 25ddaeb 6cebfc1
Author: Cam McKenzie <ca...@apache.org>
Authored: Thu Jul 28 10:51:07 2016 +1000
Committer: Cam McKenzie <ca...@apache.org>
Committed: Thu Jul 28 10:51:07 2016 +1000
----------------------------------------------------------------------
.../framework/recipes/cache/TreeCache.java | 34 ++++++--------------
.../recipes/leader/LeaderSelector.java | 21 ++++++------
2 files changed, 21 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/ff169d6e/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
----------------------------------------------------------------------
diff --cc curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
index a69a810,906d23d..95b173e
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
@@@ -609,10 -586,9 +593,10 @@@ public class TreeCache implements Close
{
if ( treeState.compareAndSet(TreeState.STARTED, TreeState.CLOSED) )
{
+ client.removeWatchers();
client.getConnectionStateListenable().removeListener(connectionStateListener);
listeners.clear();
- executorService.close();
+ executorService.shutdown();
try
{
root.wasDeleted();