This is an automated email from the ASF dual-hosted git repository.

dlmarion pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git

commit b900be0aa69f382ab724e219a6dd899768abf8ff
Merge: aa1f30aa64 d6900d8e65
Author: Dave Marion <dlmar...@apache.org>
AuthorDate: Wed Jan 29 13:16:59 2025 +0000

    Merge branch '3.1'

 .../org/apache/accumulo/core/lock/ServiceLock.java | 28 ----------------------
 .../org/apache/accumulo/server/util/ZooZap.java    |  4 +++-
 2 files changed, 3 insertions(+), 29 deletions(-)

diff --cc core/src/main/java/org/apache/accumulo/core/lock/ServiceLock.java
index 3c7d72bd0f,e695ac9c00..18aeda770a
--- a/core/src/main/java/org/apache/accumulo/core/lock/ServiceLock.java
+++ b/core/src/main/java/org/apache/accumulo/core/lock/ServiceLock.java
@@@ -18,9 -18,7 +18,8 @@@
   */
  package org.apache.accumulo.core.lock;
  
- import static java.nio.charset.StandardCharsets.UTF_8;
  import static java.util.Objects.requireNonNull;
 +import static java.util.concurrent.TimeUnit.SECONDS;
  
  import java.util.ArrayList;
  import java.util.List;
diff --cc server/base/src/main/java/org/apache/accumulo/server/util/ZooZap.java
index 17706c1c9c,4d16127b37..c97892a4c0
--- a/server/base/src/main/java/org/apache/accumulo/server/util/ZooZap.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/ZooZap.java
@@@ -114,39 -115,37 +114,41 @@@ public class ZooZap implements KeywordE
          SecurityUtil.serverLogin(siteConf);
        }
  
 -      String volDir = 
VolumeConfiguration.getVolumeUris(siteConf).iterator().next();
 -      Path instanceDir = new Path(volDir, "instance_id");
 -      InstanceId iid = VolumeManager.getInstanceIDFromHdfs(instanceDir, new 
Configuration());
 -      var zrw = zk.asReaderWriter();
 -
 -      if (opts.zapManager) {
 -        String managerLockPath = ZooUtil.getRoot(iid) + 
Constants.ZMANAGER_LOCK;
 +      try (var context = new ServerContext(siteConf)) {
 +        final ZooReaderWriter zrw = context.getZooSession().asReaderWriter();
 +        if (opts.zapManager) {
 +          ServiceLockPath managerLockPath = 
context.getServerPaths().createManagerPath();
 +          try {
 +            zapDirectory(zrw, managerLockPath, opts);
 +          } catch (KeeperException | InterruptedException e) {
 +            e.printStackTrace();
 +          }
 +        }
  
 -        try {
 -          zapDirectory(zrw, managerLockPath, opts);
 -        } catch (KeeperException | InterruptedException e) {
 -          e.printStackTrace();
 +        ResourceGroupPredicate rgp;
 +        if (!opts.resourceGroup.isEmpty()) {
 +          rgp = rg -> rg.equals(opts.resourceGroup);
 +        } else {
 +          rgp = rg -> true;
          }
 -      }
  
 -      if (opts.zapTservers) {
 -        String tserversPath = ZooUtil.getRoot(iid) + Constants.ZTSERVERS;
 -        try {
 -          List<String> children = zrw.getChildren(tserversPath);
 -          for (String child : children) {
 -            message("Deleting " + tserversPath + "/" + child + " from 
zookeeper", opts);
 -
 -            if (opts.zapManager) {
 -              zrw.recursiveDelete(tserversPath + "/" + child, 
NodeMissingPolicy.SKIP);
 -            } else {
 -              var zLockPath = ServiceLock.path(tserversPath + "/" + child);
 -              if (!zrw.getChildren(zLockPath.toString()).isEmpty()) {
 -                try {
 -                  ServiceLock.deleteLock(zrw, zLockPath);
 -                } catch (RuntimeException e) {
 -                  message("Did not delete " + tserversPath + "/" + child, 
opts);
 +        if (opts.zapTservers) {
 +          try {
 +            Set<ServiceLockPath> tserverLockPaths =
 +                context.getServerPaths().getTabletServer(rgp, 
AddressSelector.all(), false);
 +            for (ServiceLockPath tserverPath : tserverLockPaths) {
 +
 +              message("Deleting " + tserverPath + " from zookeeper", opts);
 +
 +              if (opts.zapManager) {
 +                zrw.recursiveDelete(tserverPath.toString(), 
NodeMissingPolicy.SKIP);
 +              } else {
 +                if (!zrw.getChildren(tserverPath.toString()).isEmpty()) {
-                   if (!ServiceLock.deleteLock(zrw, tserverPath, "tserver")) {
++                  try {
++                    ServiceLock.deleteLock(zrw, tserverPath);
++                  } catch (RuntimeException e) {
 +                    message("Did not delete " + tserverPath, opts);
 +                  }
                  }
                }
              }

Reply via email to