dcapwell commented on code in PR #101:
URL: https://github.com/apache/cassandra-accord/pull/101#discussion_r1664690734


##########
accord-core/src/main/java/accord/topology/TopologyManager.java:
##########
@@ -371,15 +391,87 @@ private int indexOf(long epoch)
         }
     }
 
+    private static class FutureEpoch
+    {
+        private volatile AsyncResult.Settable<Void> future;
+        private long deadlineMillis;
+
+        public FutureEpoch(long deadlineMillis)
+        {
+            this.future = AsyncResults.settable();
+            this.deadlineMillis = deadlineMillis;
+        }
+
+        /*
+         * Notify any listeners that are waiting for the epoch that is has 
been a long time since
+         * we started waiting for the epoch. We may still eventually get the 
epoch so also create
+         * a new future so subsequent operations may have a chance at seeing 
the epoch if it ever appears.
+         *
+         * Subsequent waiters may get a timeout notification far sooner 
(WATCHDOG_INTERVAL_MILLISS)
+         * instead of EPOCH_INITIAL_TIMEOUT_MILLIS
+         */
+        @GuardedBy("TopologyManager.this")
+        private void timeOutCurrentListeners(long newDeadline, Agent agent)
+        {
+            deadlineMillis = newDeadline;
+            AsyncResult.Settable<Void> oldFuture = future;
+            if (oldFuture.isDone())
+                return;
+            future = AsyncResults.settable();
+            future.addCallback(agent);
+            oldFuture.tryFailure(new Timeout(null, null));

Review Comment:
   Can we use a new type?  `Timeout` implies we waited the allowed amount of 
time for a txn, but this timeout is different... There is an edge case 
(documented above) where a txn sees this `Timeout` after < 1s of starting... 
which would be super confusing to figure out



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to