storm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject [1/3] storm git commit: STORM-913:Use Curator's delete().deletingChildrenIfNeeded() instead of zk/delete-recursive
Date Wed, 05 Aug 2015 20:46:45 GMT
Repository: storm
Updated Branches:
  refs/heads/master 7f181188b -> 938f03d83


STORM-913:Use Curator's delete().deletingChildrenIfNeeded() instead of zk/delete-recursive


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

Branch: refs/heads/master
Commit: fa370b540cdc91cefea6ccda166525ba4e6aa15c
Parents: 30df970
Author: caofangkun <caofangkun@gmail.com>
Authored: Fri Jul 3 14:29:57 2015 +0800
Committer: caofangkun <caofangkun@gmail.com>
Committed: Fri Jul 3 14:29:57 2015 +0800

----------------------------------------------------------------------
 storm-core/src/clj/backtype/storm/cluster.clj   |  2 +-
 storm-core/src/clj/backtype/storm/zookeeper.clj | 25 +++++++-------------
 2 files changed, 9 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/fa370b54/storm-core/src/clj/backtype/storm/cluster.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/cluster.clj b/storm-core/src/clj/backtype/storm/cluster.clj
index 1a13f7b..63e385f 100644
--- a/storm-core/src/clj/backtype/storm/cluster.clj
+++ b/storm-core/src/clj/backtype/storm/cluster.clj
@@ -107,7 +107,7 @@
 
      (delete-node
        [this path]
-       (zk/delete-recursive zk path))
+       (zk/delete-node zk path))
 
      (get-data
        [this path watch?]

http://git-wip-us.apache.org/repos/asf/storm/blob/fa370b54/storm-core/src/clj/backtype/storm/zookeeper.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/zookeeper.clj b/storm-core/src/clj/backtype/storm/zookeeper.clj
index eea71be..390b20b 100644
--- a/storm-core/src/clj/backtype/storm/zookeeper.clj
+++ b/storm-core/src/clj/backtype/storm/zookeeper.clj
@@ -88,7 +88,7 @@
   ([^CuratorFramework zk ^String path ^bytes data mode acls]
     (let [mode  (zk-create-modes mode)]
       (try
-        (.. zk (create) (withMode mode) (withACL acls) (forPath (normalize-path path) data))
+        (.. zk (create) (creatingParentsIfNeeded) (withMode mode) (withACL acls) (forPath
(normalize-path path) data))
         (catch Exception e (throw (wrap-in-runtime e))))))
   ([^CuratorFramework zk ^String path ^bytes data acls]
     (create-node zk path data :persistent acls)))
@@ -103,11 +103,13 @@
      (catch Exception e (throw (wrap-in-runtime e))))))
 
 (defnk delete-node
-  [^CuratorFramework zk ^String path :force false]
-  (try-cause  (.. zk (delete) (forPath (normalize-path path)))
-             (catch KeeperException$NoNodeException e
-               (when-not force (throw e)))
-             (catch Exception e (throw (wrap-in-runtime e)))))
+  [^CuratorFramework zk ^String path]
+  (let [path (normalize-path path)]
+    (when (exists-node? zk path false)
+      (try-cause  (.. zk (delete) (deletingChildrenIfNeeded) (forPath (normalize-path path)))
+                  (catch KeeperException$NoNodeException e
+                    ;; do nothing)
+                  (catch Exception e (throw (wrap-in-runtime e)))))))
 
 (defn mkdirs
   [^CuratorFramework zk ^String path acls]
@@ -177,17 +179,6 @@
   [^CuratorFramework zk ^String path watch?]
   (exists-node? zk path watch?))
 
-(defn delete-recursive
-  [^CuratorFramework zk ^String path]
-  (let [path (normalize-path path)]
-    (when (exists-node? zk path false)
-      (let [children (try-cause
-                       (get-children zk path false)
-                       (catch KeeperException$NoNodeException e []))]
-        (doseq [c children]
-          (delete-recursive zk (full-path path c)))
-        (delete-node zk path :force true)))))
-
 (defnk mk-inprocess-zookeeper
   [localdir :port nil]
   (let [localfile (File. localdir)


Mime
View raw message