ctubbsii commented on code in PR #5246:
URL: https://github.com/apache/accumulo/pull/5246#discussion_r1915564121


##########
minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java:
##########
@@ -824,9 +825,46 @@ public synchronized void stop() throws IOException, 
InterruptedException {
 
     control.stop(ServerType.GARBAGE_COLLECTOR, null);
     control.stop(ServerType.MANAGER, null);
+    control.stop(ServerType.COMPACTION_COORDINATOR);
     control.stop(ServerType.TABLET_SERVER, null);
+    control.stop(ServerType.COMPACTOR, null);
+    control.stop(ServerType.SCAN_SERVER, null);
+
+    // The method calls above kill the server
+    // Clean up the locks in ZooKeeper fo that if the cluster
+    // 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) {
+      log.error("Error zapping zookeeper locks", e);
+    }
     control.stop(ServerType.ZOOKEEPER, null);
 
+    // Clear the location of the servers in ZooCache.
+    // When ZooKeeper was stopped in the previous method call,
+    // the local ZooKeeper watcher did not fire. If MAC is
+    // restarted, then ZooKeeper will start on the same port with
+    // the same data, but no Watchers will fire.
+    boolean startCalled = true;
+    try {
+      getServerContext();
+    } catch (RuntimeException e) {
+      if (e.getMessage().startsWith("Accumulo not initialized")) {
+        startCalled = false;
+      }
+    }
+    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));

Review Comment:
   > Wouldn't it create the Stream for every key?
   
   Yeah, I would avoid the second variant. I was just offering inspiration for 
a possibly more readable version. That second one would perform badly, though. 
The first variant is slightly less readable, but would perform much better, as 
there's only a one time cost to set up the chained predicate, especially if the 
predicate is saved outside the method in some static final.



-- 
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]

Reply via email to