ddanielr commented on code in PR #6065:
URL: https://github.com/apache/accumulo/pull/6065#discussion_r2708967787
##########
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:
Ah I see.
I was trying to reuse the lock validation logic that was in `deleteLock` but
`deleteLocks` is operating at the server location level and not at the per lock
level.
deleteLocks is going to be passed a generic path like
`/accumulo/<ID>/compactors/default/` with a HostAndPort predicate of say
`localhost:9993`.
So it will go through all children of `/accumulo/<ID>/compactors/default/`
looking for any that match the HostAndPort predicate and then recursively
delete any locks held under `/accumulo/<ID>/compactors/default/localhost:9993`
--
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]