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

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

commit a42c4315061548e8edc03d45e8bfd4d6c141fd11
Merge: 220cdc54da 4b5234bd87
Author: Ed Coleman <edcole...@apache.org>
AuthorDate: Thu May 16 20:52:34 2024 +0000

    Merge remote-tracking branch 'upstream/2.1'

 .../java/org/apache/accumulo/manager/Manager.java  | 51 +++++++++++++++++++++-
 1 file changed, 49 insertions(+), 2 deletions(-)

diff --cc server/manager/src/main/java/org/apache/accumulo/manager/Manager.java
index ded6d62f83,84e8e68519..a778744c0f
--- a/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java
+++ b/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java
@@@ -39,6 -38,6 +39,7 @@@ import java.util.Iterator
  import java.util.List;
  import java.util.Map;
  import java.util.Map.Entry;
++import java.util.Optional;
  import java.util.Set;
  import java.util.SortedMap;
  import java.util.TreeMap;
@@@ -71,6 -69,10 +72,7 @@@ import org.apache.accumulo.core.data.Va
  import org.apache.accumulo.core.dataImpl.KeyExtent;
  import org.apache.accumulo.core.fate.AgeOffStore;
  import org.apache.accumulo.core.fate.Fate;
 -import org.apache.accumulo.core.fate.zookeeper.ServiceLock;
 -import org.apache.accumulo.core.fate.zookeeper.ServiceLock.LockLossReason;
 -import org.apache.accumulo.core.fate.zookeeper.ServiceLock.ServiceLockPath;
+ import org.apache.accumulo.core.fate.zookeeper.ZooCache.ZcStat;
  import org.apache.accumulo.core.fate.zookeeper.ZooReaderWriter;
  import org.apache.accumulo.core.fate.zookeeper.ZooUtil;
  import org.apache.accumulo.core.fate.zookeeper.ZooUtil.NodeExistsPolicy;
@@@ -737,6 -741,48 +739,49 @@@ public class Manager extends AbstractSe
      }
    }
  
+   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);
++            Optional<ServiceLockData> lockData =
++                ServiceLock.getLockData(getContext().getZooCache(), 
zLockPath, stat);
+ 
 -            if (lockData == null) {
++            if (lockData.isEmpty()) {
+               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(CLEANUP_INTERVAL_MINUTES, MINUTES);
+         }
+       }
+     }
+ 
+   }
+ 
    private class StatusThread implements Runnable {
  
      private boolean goodStats() {

Reply via email to