-
Notifications
You must be signed in to change notification settings - Fork 478
Added ZooZap and ServiceLock methods to delete ScanServer locks #6073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.1
Are you sure you want to change the base?
Changes from all commits
859cda2
809f3bc
5a33208
49a9d1c
be8d7de
1ca9803
e56a531
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -754,6 +755,43 @@ public static void deleteLocks(ZooReaderWriter zk, String zPath, | |
| } | ||
| } | ||
|
|
||
| public static void deleteScanServerLocks(ZooReaderWriter zk, String zPath, | ||
| Predicate<HostAndPort> hostPortPredicate, Predicate<String> groupPredicate, | ||
| Consumer<String> messageOutput, Boolean dryRun) throws KeeperException, InterruptedException { | ||
|
|
||
| Objects.requireNonNull(zPath, "Lock path cannot be null"); | ||
| Objects.requireNonNull(groupPredicate, "group predicate cannot be null"); | ||
| if (!zk.exists(zPath)) { | ||
| throw new IllegalStateException("Path " + zPath + " does not exist"); | ||
| } | ||
|
|
||
| List<String> servers = zk.getChildren(zPath); | ||
| if (servers.isEmpty()) { | ||
| throw new IllegalStateException("No server locks are held at " + zPath); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this cause a failure if there are no scan servers? If so attempting to delete some scan servers when there are no scan servers seems like it should not fail.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This follows the same pattern as |
||
| } | ||
|
|
||
| ZooKeeper z = zk.getZooKeeper(); | ||
| for (String server : servers) { | ||
| if (hostPortPredicate.test(HostAndPort.fromString(server))) { | ||
| final String serverPath = zPath + "/" + server; | ||
| byte[] lockData = ServiceLock.getLockData(z, path(serverPath)); | ||
| if (lockData == null) { | ||
| messageOutput.accept("Skipping server " + server + " as it's lock content is empty."); | ||
| continue; | ||
| } | ||
| String lockContent = new String(lockData, UTF_8); | ||
| String[] parts = lockContent.split(","); | ||
| if (parts.length == 2 && groupPredicate.test(parts[1])) { | ||
| messageOutput.accept("Deleting " + serverPath + " from zookeeper"); | ||
| if (!dryRun) { | ||
| LOG.debug("Deleting all locks at path {} due to lock deletion", serverPath); | ||
| zk.recursiveDelete(serverPath, NodeMissingPolicy.SKIP); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * This method will delete the top server lock for a given lock path | ||
| * | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.