curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ioca...@apache.org
Subject git commit: [CURATOR-27] Align LeaderSelector with the new CloseableExecutorService behavior
Date Sun, 06 Oct 2013 14:52:29 GMT
Updated Branches:
  refs/heads/master 8853de392 -> ce1d8ee06


[CURATOR-27] Align LeaderSelector with the new CloseableExecutorService behavior


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

Branch: refs/heads/master
Commit: ce1d8ee06b14845ea49f9f9b8549100d63a4f8c3
Parents: 8853de3
Author: Ioannis Canellos <iocanel@apache.org>
Authored: Sun Oct 6 17:50:34 2013 +0300
Committer: Ioannis Canellos <iocanel@apache.org>
Committed: Sun Oct 6 17:50:34 2013 +0300

----------------------------------------------------------------------
 .../framework/recipes/leader/LeaderSelector.java  | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/ce1d8ee0/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 ffbb0da..6a15f23 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
@@ -98,7 +98,7 @@ public class LeaderSelector implements Closeable
      */
     public LeaderSelector(CuratorFramework client, String leaderPath, LeaderSelectorListener
listener)
     {
-        this(client, leaderPath, Executors.newSingleThreadExecutor(defaultThreadFactory),
listener);
+        this(client, leaderPath, new CloseableExecutorService(Executors.newSingleThreadExecutor(defaultThreadFactory),
true), listener);
     }
 
     /**
@@ -113,7 +113,7 @@ public class LeaderSelector implements Closeable
     @Deprecated
     public LeaderSelector(CuratorFramework client, String leaderPath, ThreadFactory threadFactory,
Executor executor, LeaderSelectorListener listener)
     {
-        this(client, leaderPath, wrapExecutor(executor), listener);
+        this(client, leaderPath, new CloseableExecutorService(wrapExecutor(executor), true),
listener);
     }
 
     /**
@@ -122,7 +122,17 @@ public class LeaderSelector implements Closeable
      * @param executorService thread pool to use
      * @param listener listener
      */
-    public LeaderSelector(CuratorFramework client, String leaderPath, ExecutorService executorService,
LeaderSelectorListener listener)
+    public LeaderSelector(CuratorFramework client, String leaderPath, ExecutorService executorService,
LeaderSelectorListener listener) {
+        this(client, leaderPath, new CloseableExecutorService(executorService), listener);
+    }
+
+    /**
+     * @param client the client
+     * @param leaderPath the path for this leadership group
+     * @param executorService thread pool to use
+     * @param listener listener
+     */
+    public LeaderSelector(CuratorFramework client, String leaderPath, CloseableExecutorService
executorService, LeaderSelectorListener listener)
     {
         Preconditions.checkNotNull(client, "client cannot be null");
         Preconditions.checkNotNull(leaderPath, "leaderPath cannot be null");
@@ -132,7 +142,7 @@ public class LeaderSelector implements Closeable
         this.listener = new WrappedListener(this, listener);
         hasLeadership = false;
 
-        this.executorService = new CloseableExecutorService(executorService);
+        this.executorService = executorService;
         mutex = new InterProcessMutex(client, leaderPath)
         {
             @Override


Mime
View raw message