EdColeman commented on code in PR #4562:
URL: https://github.com/apache/accumulo/pull/4562#discussion_r1602240425


##########
server/manager/src/main/java/org/apache/accumulo/manager/Manager.java:
##########
@@ -740,6 +741,48 @@ private void cleanupOfflineMigrations() {
     }
   }
 
+  private class ScanServerZKCleaner implements Runnable {
+
+    @Override
+    public void run() {
+
+      final ZooReaderWriter zrw = getContext().getZooReaderWriter();
+      final String sserverZNodePath = getContext().getZooKeeperRoot() + 
Constants.ZSSERVERS;
+
+      while (stillManager()) {
+        try {
+          for (String sserverClientAddress : 
zrw.getChildren(sserverZNodePath)) {
+
+            final String sServerZPath = sserverZNodePath + "/" + 
sserverClientAddress;
+            final var zLockPath = ServiceLock.path(sServerZPath);
+            ZcStat stat = new ZcStat();
+            byte[] lockData = 
ServiceLock.getLockData(getContext().getZooCache(), zLockPath, stat);
+
+            if (lockData == null) {
+              try {
+                log.debug("Deleting empty ScanServer ZK node {}", 
sServerZPath);
+                zrw.delete(sServerZPath);
+              } catch (KeeperException.NotEmptyException e) {
+                log.debug(
+                    "Failed to delete ScanServer ZK node {} its not empty, 
likely an expected race condition.",
+                    sServerZPath);
+              }
+            }
+          }
+        } catch (KeeperException e) {
+          log.error("Exception trying to delete empty scan server ZNodes, will 
retry", e);
+        } catch (InterruptedException e) {
+          Thread.interrupted();
+          log.error("Interrupted trying to delete empty scan server ZNodes, 
will retry", e);
+        } finally {
+          // sleep for 5 mins
+          sleepUninterruptibly(TIME_BETWEEN_MIGRATION_CLEANUPS, MILLISECONDS);

Review Comment:
   Maybe rename the constant to `TIME_BETWEEN_CLEANUPS` because it is now used 
in multiple places?  
   
   Another change, but would be more confusing unless the other time constants 
were changed. Change the constant to just be minutes, along the lines of 
calling it something like 'TIME_BETWEEN_CLEANUPS_MINUTES`  and then 
   ```
   sleepUninterruptibly(TIME_BETWEEN_CLEANUPS_MINUTES, MINUTES);
   ```
   Basically I needed to lookup the constant and decode what `* ONE_SECOND` was 
to see that the MILLISECONDS are the correct units.  Just saying that the wait 
was 5 minutes more directly could improve clarity?   Probably more of a 
personal preference and can be ignored.



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