Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.accumulo.core.fate.zookeeper;

import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Objects.requireNonNull;

import java.util.ArrayList;
Expand Down Expand Up @@ -783,6 +784,22 @@ public static void deleteLock(ZooReaderWriter zk, ServiceLockPath path)

}

public static void removeGCLock(ZooReaderWriter zoo, String path,
Predicate<HostAndPort> hostPortPredicate, Consumer<String> messageOutput, Boolean dryRun)
throws KeeperException, InterruptedException {
var lockData = ServiceLock.getLockData(zoo.getZooKeeper(), ServiceLock.path(path));
if (lockData != null) {
String lockContent = new String(lockData, UTF_8);
Comment thread
ddanielr marked this conversation as resolved.
Outdated
String[] parts = lockContent.split("=");
if (parts.length == 2 && hostPortPredicate.test(HostAndPort.fromString(parts[1]))) {
messageOutput.accept("Deleting " + path + " from zookeeper");
if (!dryRun) {
zoo.recursiveDelete(path, NodeMissingPolicy.SKIP);
Comment thread
ddanielr marked this conversation as resolved.
}
}
}
}

/**
* Checks that the lock still exists in ZooKeeper. The typical mechanism for determining if a lock
* is lost depends on a Watcher set on the lock node. There exists a case where the Watcher may
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,10 @@ public void zap(SiteConfiguration siteConf, String... args) {
if (opts.zapGc) {
String gcLockPath = Constants.ZROOT + "/" + iid + Constants.ZGC_LOCK;
try {
removeSingletonLock(zoo, gcLockPath, hostPortPredicate, opts);
ServiceLock.removeGCLock(zoo, gcLockPath, hostPortPredicate, m -> message(m, opts),
opts.dryRun);
} catch (KeeperException | InterruptedException e) {
log.error("Error deleting manager lock", e);
log.error("Error deleting gc lock", e);
}
}

Expand Down