-
Notifications
You must be signed in to change notification settings - Fork 445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
admin fate
improvements, LockID
s use for fate stores improved/fixed
#5028
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,10 +85,6 @@ public FateId fromTypeAndKey(FateInstanceType instanceType, FateKey fateKey) { | |
// Keeps track of the number of concurrent callers to waitForStatusChange() | ||
private final AtomicInteger concurrentStatusChangeCallers = new AtomicInteger(0); | ||
|
||
public AbstractFateStore() { | ||
this(createDummyLockID(), null, DEFAULT_MAX_DEFERRED, DEFAULT_FATE_ID_GENERATOR); | ||
} | ||
|
||
public AbstractFateStore(ZooUtil.LockID lockID, Predicate<ZooUtil.LockID> isLockHeld) { | ||
this(lockID, isLockHeld, DEFAULT_MAX_DEFERRED, DEFAULT_FATE_ID_GENERATOR); | ||
} | ||
|
@@ -98,9 +94,7 @@ public AbstractFateStore(ZooUtil.LockID lockID, Predicate<ZooUtil.LockID> isLock | |
this.maxDeferred = maxDeferred; | ||
this.fateIdGenerator = Objects.requireNonNull(fateIdGenerator); | ||
this.deferred = Collections.synchronizedMap(new HashMap<>()); | ||
this.lockID = Objects.requireNonNull(lockID); | ||
// If the store is used for a Fate which runs a dead reservation cleaner, | ||
// this should be non-null, otherwise null is fine | ||
this.lockID = lockID; | ||
this.isLockHeld = isLockHeld; | ||
} | ||
|
||
|
@@ -275,6 +269,10 @@ protected void verifyFateKey(FateId fateId, Optional<FateKey> fateKeySeen, | |
"Collision detected for fate id " + fateId); | ||
} | ||
|
||
protected void verifyLock(ZooUtil.LockID lockID, FateId fateId) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feel free to ignore this comment, it was something I noticed but not sure about what if any changes to make based on this observation. In every place where this method is called the next line is something like |
||
Preconditions.checkState(lockID != null, "Tried to reserve " + fateId + " with null lockID"); | ||
} | ||
|
||
protected abstract Stream<FateIdStatus> getTransactions(EnumSet<TStatus> statuses); | ||
|
||
protected abstract TStatus _getStatus(FateId fateId); | ||
|
@@ -428,14 +426,4 @@ protected Serializable deserializeTxInfo(TxInfo txInfo, byte[] data) { | |
throw new IllegalStateException("Bad node data " + txInfo); | ||
} | ||
} | ||
|
||
/** | ||
* this is a temporary method used to create a dummy lock when using a FateStore outside the | ||
* context of a Manager (one example is testing) so reservations can still be made. | ||
* | ||
* @return a dummy {@link ZooUtil.LockID} | ||
*/ | ||
public static ZooUtil.LockID createDummyLockID() { | ||
return new ZooUtil.LockID("/path", "node", 123); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to drop this constant and have the test code create locks under the admin path when needed?