DomGarguilo commented on code in PR #5786: URL: https://github.com/apache/accumulo/pull/5786#discussion_r2305057151
########## core/src/main/java/org/apache/accumulo/core/fate/zookeeper/FateLock.java: ########## @@ -251,7 +264,7 @@ public void removeEntry(FateLockEntry data, long entry) { public static SortedSet<NodeName> validateAndWarn(FateLockPath path, List<String> children) { log.trace("validating and sorting children at path {}", path); - SortedSet<NodeName> validChildren = new TreeSet<>(); + SortedSet<NodeName> validChildren = new TreeSet<>(Comparator.comparingLong(nn -> nn.sequence)); Review Comment: Should we refactor this comparator into a constant for reuse? ########## core/src/main/java/org/apache/accumulo/core/fate/AdminUtil.java: ########## @@ -282,36 +293,42 @@ private void findLocks(ZooSession zk, final ServiceLockPath lockPath, SortedSet<FateLock.NodeName> lockNodes = FateLock.validateAndWarn(fLockPath, zr.getChildren(fLockPath.toString())); - int pos = 0; - boolean sawWriteLock = false; + ArrayList<FateLock.FateLockEntry> previous = new ArrayList<>(lockNodes.size()); for (FateLock.NodeName node : lockNodes) { try { FateLock.FateLockEntry fateLockEntry = node.fateLockEntry.get(); var fateId = fateLockEntry.getFateId(); var lockType = fateLockEntry.getLockType(); - if (lockType == LockType.WRITE) { - sawWriteLock = true; - } + lockRanges.put(fateId, fateLockEntry.getRange()); - Map<FateId,List<String>> locks; + Map<FateId,List<String>> locks = heldLocks; - if (pos == 0) { - locks = heldLocks; - } else if (lockType == LockType.READ && !sawWriteLock) { - locks = heldLocks; + if (lockType == LockType.WRITE) { + for (var prev : Lists.reverse(previous)) { Review Comment: `Lists.reverse()` might add a small amount of overhead. Its definitely more simple and readable but indexed iteration might be slightly more performant. -- 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: notifications-unsubscr...@accumulo.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org