keith-turner commented on code in PR #4524:
URL: https://github.com/apache/accumulo/pull/4524#discussion_r1692342340


##########
core/src/main/java/org/apache/accumulo/core/fate/AbstractFateStore.java:
##########
@@ -67,27 +76,36 @@ public FateId fromTypeAndKey(FateInstanceType instanceType, 
FateKey fateKey) {
     }
   };
 
-  protected final Set<FateId> reserved;
+  // The ZooKeeper lock for the process that's running this store instance
+  protected final ZooUtil.LockID lockID;
+  protected final Predicate<ZooUtil.LockID> isLockHeld;
   protected final Map<FateId,NanoTime> deferred;
+  protected final FateIdGenerator fateIdGenerator;
   private final int maxDeferred;
   private final AtomicBoolean deferredOverflow = new AtomicBoolean();
-  private final FateIdGenerator fateIdGenerator;
-
-  // This is incremented each time a transaction was unreserved that was non 
new
-  protected final SignalCount unreservedNonNewCount = new SignalCount();
 
   // This is incremented each time a transaction is unreserved that was 
runnable
-  protected final SignalCount unreservedRunnableCount = new SignalCount();
+  private final SignalCount unreservedRunnableCount = new SignalCount();
+
+  // Keeps track of the number of concurrent callers to waitForStatusChange()
+  private final AtomicInteger concurrentStatusChangeCallers = new 
AtomicInteger(0);
 
   public AbstractFateStore() {
-    this(DEFAULT_MAX_DEFERRED, DEFAULT_FATE_ID_GENERATOR);
+    this(null, null, DEFAULT_MAX_DEFERRED, DEFAULT_FATE_ID_GENERATOR);
   }
 
-  public AbstractFateStore(int maxDeferred, FateIdGenerator fateIdGenerator) {
+  public AbstractFateStore(ZooUtil.LockID lockID, Predicate<ZooUtil.LockID> 
isLockHeld) {
+    this(lockID, isLockHeld, DEFAULT_MAX_DEFERRED, DEFAULT_FATE_ID_GENERATOR);
+  }
+
+  public AbstractFateStore(ZooUtil.LockID lockID, Predicate<ZooUtil.LockID> 
isLockHeld,
+      int maxDeferred, FateIdGenerator fateIdGenerator) {
     this.maxDeferred = maxDeferred;
     this.fateIdGenerator = Objects.requireNonNull(fateIdGenerator);
-    this.reserved = new HashSet<>();
-    this.deferred = new HashMap<>();
+    this.deferred = Collections.synchronizedMap(new HashMap<>());
+    this.lockID = Objects.requireNonNullElseGet(lockID, 
AbstractFateStore::createDummyLockID);

Review Comment:
   I did not know this function existed.  Looked at what other new methods 
exists in Objects and found checkFromIndexSize which could be useful in other 
places in the code base for efficiently checking bounds.  Opened 
https://github.com/apache/accumulo-access/pull/80 as a result of finding these 
new methods. I think we can use these index bounds checking methods in other 
places.



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