xyuanlu commented on code in PR #2994:
URL: https://github.com/apache/helix/pull/2994#discussion_r1919620772


##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java:
##########
@@ -1820,6 +1826,61 @@ public void deleteRecursively(String path) throws 
ZkClientException {
     }
   }
 
+  /**
+   * Delete the path as well as all its children. This operation is atomic and 
will either delete all nodes or none.
+   * This operation may fail if another agent is concurrently creating or 
deleting nodes under the path.
+   * @param path ZK path to delete
+   */
+  public void deleteRecursivelyAtomic(String path) {
+    deleteRecursivelyAtomic(Arrays.asList(path));
+  }
+
+  /**
+   * Delete the paths as well as all their children. This operation is atomic 
and will either delete all nodes or none.
+   * This operation may fail if another agent is concurrently creating or 
deleting nodes under any of the paths.
+   * @param paths ZK paths to delete
+   */
+  public void deleteRecursivelyAtomic(List<String> paths) {
+    List<Op> ops = new ArrayList<>();
+    for (String path : paths) {
+      ops.addAll(getOpsForRecursiveDelete(path));
+    }
+    try {
+      multi(ops);
+    }
+    catch (Exception e) {

Review Comment:
   1. I feel like we should check the multi result. Even if there are exception 
thrown, multi may or may not succeeded.
   2. I think having specific exception class might be better comparing to do a 
global catch here, and log corresponding error messages . For example, if we 
get a `InterruptedException`, we know there is concurrent edit of the paths. 
   
   related doc:
   OpResult: 
https://www.javadoc.io/static/org.apache.zookeeper/zookeeper/3.7.1/org/apache/zookeeper/OpResult.DeleteResult.html
   Multi(): 
https://www.javadoc.io/doc/org.apache.zookeeper/zookeeper/3.7.1/org/apache/zookeeper/ZooKeeper.html#multi-java.lang.Iterable-



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscr...@helix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@helix.apache.org
For additional commands, e-mail: reviews-h...@helix.apache.org

Reply via email to