From a358031818f3f5017882f499c0c839f04be297f3 Mon Sep 17 00:00:00 2001 From: Dave Marion Date: Wed, 15 Jan 2025 15:41:21 +0000 Subject: [PATCH] Implemented PR suggestions --- .../MiniAccumuloClusterControl.java | 6 ++---- .../MiniAccumuloClusterImpl.java | 18 ++++++++++-------- .../apache/accumulo/server/util/ZooZap.java | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterControl.java b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterControl.java index 2a54809c698..b0c46aadf97 100644 --- a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterControl.java +++ b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterControl.java @@ -280,12 +280,10 @@ public synchronized void stop(ServerType server, String hostname) throws IOExcep try { cluster.stopProcessWithTimeout(managerProcess, 30, TimeUnit.SECONDS); try { - new ZooZap().zap(cluster.getServerContext().getSiteConfiguration(), - new String[] {"-manager"}); - } catch (Exception e) { + new ZooZap().zap(cluster.getServerContext().getSiteConfiguration(), "-manager"); + } catch (RuntimeException e) { log.error("Error zapping Manager zookeeper lock", e); } - } catch (ExecutionException | TimeoutException e) { log.warn("Manager did not fully stop after 30 seconds", e); } catch (InterruptedException e) { diff --git a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java index 91eefdb9239..95f8a4ca2b1 100644 --- a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java +++ b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java @@ -56,6 +56,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Function; +import java.util.function.Predicate; import java.util.function.Supplier; import java.util.stream.Stream; @@ -835,9 +836,9 @@ public synchronized void stop() throws IOException, InterruptedException { // is restarted, then the processes will start right away // and not wait for the old locks to be cleaned up. try { - new ZooZap().zap(getServerContext().getSiteConfiguration(), new String[] {"-manager", - "-compaction-coordinators", "-tservers", "-compactors", "-sservers"}); - } catch (Exception e) { + new ZooZap().zap(getServerContext().getSiteConfiguration(), "-manager", + "-compaction-coordinators", "-tservers", "-compactors", "-sservers"); + } catch (RuntimeException e) { log.error("Error zapping zookeeper locks", e); } control.stop(ServerType.ZOOKEEPER, null); @@ -858,11 +859,12 @@ public synchronized void stop() throws IOException, InterruptedException { if (startCalled) { final ServerContext ctx = getServerContext(); final String zRoot = getServerContext().getZooKeeperRoot(); - ctx.getZooCache().clear((path) -> path.startsWith(zRoot + Constants.ZMANAGER_LOCK)); - ctx.getZooCache().clear((path) -> path.startsWith(zRoot + Constants.ZGC_LOCK)); - ctx.getZooCache().clear((path) -> path.startsWith(zRoot + Constants.ZCOMPACTORS)); - ctx.getZooCache().clear((path) -> path.startsWith(zRoot + Constants.ZSSERVERS)); - ctx.getZooCache().clear((path) -> path.startsWith(zRoot + Constants.ZTSERVERS)); + Predicate pred = path -> false; + for (String lockPath : Set.of(Constants.ZMANAGER_LOCK, Constants.ZGC_LOCK, + Constants.ZCOMPACTORS, Constants.ZSSERVERS, Constants.ZTSERVERS)) { + pred = pred.or(path -> path.startsWith(zRoot + lockPath)); + } + ctx.getZooCache().clear(pred); } // ACCUMULO-2985 stop the ExecutorService after we finished using it to stop accumulo procs diff --git 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 index 3dfcd459a03..d16b9fe9843 100644 --- 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 @@ -102,7 +102,7 @@ public void execute(String[] args) throws Exception { } } - public void zap(SiteConfiguration siteConf, String[] args) { + public void zap(SiteConfiguration siteConf, String... args) { Opts opts = new Opts(); opts.parseArgs(keyword(), args);