dlmarion commented on code in PR #2990:
URL: https://github.com/apache/accumulo/pull/2990#discussion_r984807013
##########
server/manager/src/main/java/org/apache/accumulo/manager/Manager.java:
##########
@@ -207,7 +208,7 @@ public class Manager extends AbstractServer
private ManagerState state = ManagerState.INITIAL;
- Fate<Manager> fate;
+ private final AtomicReference<Fate<Manager>> fateReady = new
AtomicReference<>(null);
Review Comment:
```suggestion
private final CountDownLatch fateLatch = new CountDownLatch(1);
```
##########
server/manager/src/main/java/org/apache/accumulo/manager/Manager.java:
##########
@@ -225,6 +226,35 @@ public boolean stillManager() {
return getManagerState() != ManagerState.STOP;
}
+ Fate<Manager> fate() {
+ Fate<Manager> fate = fateReady.get();
+ if (fate != null) {
+ // it's ready, just return it
+ return fate;
+ }
+
+ // it's not ready yet
+ long retryTime = 500; // millis
+
+ // 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"));
+ UtilWaitThread.sleep(retryTime);
+
+ // retry, logging retries at trace level
+ while ((fate = fateReady.get()) == null) {
+ log.trace("{} still blocked", msgPrefix);
+ UtilWaitThread.sleep(retryTime);
+ }
Review Comment:
```suggestion
fateLatch.await();
```
##########
server/manager/src/main/java/org/apache/accumulo/manager/Manager.java:
##########
@@ -1145,8 +1175,9 @@ boolean canSuspendTablets() {
context.getZooReaderWriter()),
TimeUnit.HOURS.toMillis(8), System::currentTimeMillis);
- fate = new Fate<>(this, store, TraceRepo::toLogString);
- fate.startTransactionRunners(getConfiguration());
+ Fate<Manager> f = new Fate<>(this, store, TraceRepo::toLogString);
+ f.startTransactionRunners(getConfiguration());
+ fateReady.set(f);
Review Comment:
```suggestion
fateReady.set(f);
fateLatch.countDown();
```
--
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]