dlmarion commented on code in PR #6065:
URL: https://github.com/apache/accumulo/pull/6065#discussion_r2708196003


##########
core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ServiceLock.java:
##########
@@ -716,6 +719,32 @@ public long getSessionId() throws KeeperException, 
InterruptedException {
     }
   }
 
+  /**
+   * This method will delete multiple server locks for a given path according 
the predicate
+   * conditions.
+   *
+   * @param hostPortPredicate conditional predicate for determining if the 
lock should be removed.
+   * @param messageOutput function for setting where the output from the 
lockPath goes
+   * @param dryRun allows lock format validation and the messageOutput to be 
sent without actually
+   *        deleting the lock
+   *
+   */
+  public static void deleteLocks(ZooReaderWriter zk, String zPath,
+      Predicate<HostAndPort> hostPortPredicate, Consumer<String> 
messageOutput, Boolean dryRun)
+      throws KeeperException, InterruptedException {
+    if (zk.exists(zPath)) {
+      List<String> children = zk.getChildren(zPath);
+      for (String child : children) {
+        if (hostPortPredicate.test(HostAndPort.fromString(child))) {
+          messageOutput.accept("Deleting " + zPath + "/" + child + " from 
zookeeper");
+          if (!dryRun) {
+            deleteLock(zk, path(child));

Review Comment:
   I think there is a difference in the `ZooZap.removeLocks` and the 
`deleteLock` call here. The ZooZap.removeLocks call would delete everything 
under a given path, and the deleteLock call here will only remove the first 
child.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to