dlmarion commented on code in PR #2990:
URL: https://github.com/apache/accumulo/pull/2990#discussion_r984843162
##########
server/manager/src/main/java/org/apache/accumulo/manager/Manager.java:
##########
@@ -225,6 +230,33 @@ public boolean stillManager() {
return getManagerState() != ManagerState.STOP;
}
+ Fate<Manager> fate() {
+ // check if it's ready and return right away if it is
+ if (fateReadyLatch.getCount() == 0) {
+ return fateRef.get();
+ }
+
+ // it's not ready yet
+
+ // create informative warning
+ String msgPrefix = "Unexpected use of fate in thread " +
Thread.currentThread().getName()
+ + " at time " + System.currentTimeMillis();
+ log.warn("{} blocked until fate starts", msgPrefix,
+ new IllegalStateException("Attempted fate action before fate was
started; "
+ + "if this doesn't make progress, please report it as a bug to the
developers"));
+
+ try {
+ fateReadyLatch.await();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new IllegalStateException("Thread was interrupted; cannot
proceed");
+ }
+
+ // report at debug when the issue is resolved
+ log.debug("{} no longer blocked", msgPrefix);
+ return fateRef.get();
+ }
Review Comment:
I think you could re-write this method to the following. It's functionally
equivalent.
```
if (fateReadyLatch.getCount() != 0) {
String msgPrefix = "Unexpected use of fate in thread " +
Thread.currentThread().getName()
+ " at time " + System.currentTimeMillis();
log.warn("{} blocked until fate starts", msgPrefix,
new IllegalStateException("Attempted fate action before fate was
started; "
+ "if this doesn't make progress, please report it as a bug to
the developers"));
try {
fateReadyLatch.await();
// report at debug when the issue is resolved
log.debug("{} no longer blocked", msgPrefix);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException("Thread was interrupted; cannot
proceed");
}
}
return fateRef.get();
```
--
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]