curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cammcken...@apache.org
Subject [1/3] curator git commit: TreeCache does not need to use CloseableExecutorService.
Date Thu, 28 Jul 2016 00:51:50 GMT
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 <dragonsinth@apache.org>
Authored: Thu Jul 21 18:19:12 2016 -0400
Committer: Scott Blum <dragonsinth@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();


Mime
View raw message