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


##########
accord-core/src/main/java/accord/topology/TopologyManager.java:
##########
@@ -442,6 +448,102 @@ private void timeOutCurrentListeners(long newDeadline, 
Agent agent)
         }
     }
 
+    // this class could be just the list, but left it here in case we wish to 
expose "futureEpochs" and "pending" as well
+    public static class EpochsSnapshot implements 
Iterable<EpochsSnapshot.Epoch>
+    {
+        public final ImmutableList<Epoch> epochs;
+
+        public EpochsSnapshot(ImmutableList<Epoch> epochs)
+        {
+            this.epochs = epochs;
+        }
+
+        @Override
+        public Iterator<Epoch> iterator()
+        {
+            return epochs.iterator();
+        }
+
+        public enum ResultStatus
+        {
+            PENDING("pending"),
+            SUCCESS("success"),
+            FAILURE("failure");
+
+            public final String value;
+
+            ResultStatus(String value)
+            {
+                this.value = value;
+            }
+
+            private static ResultStatus of(AsyncResult<?> result)
+            {
+                if (result == null || !result.isDone())
+                    return PENDING;
+
+                return result.isSuccess() ? SUCCESS : FAILURE;
+            }
+        }
+
+        public static class EpochReady
+        {
+            public final ResultStatus metadata, coordinate, data, reads;
+
+            public EpochReady(ResultStatus metadata, ResultStatus coordinate, 
ResultStatus data, ResultStatus reads)
+            {
+                this.metadata = metadata;
+                this.coordinate = coordinate;
+                this.data = data;
+                this.reads = reads;
+            }
+
+            private static EpochReady of(ConfigurationService.EpochReady ready)
+            {
+                return new EpochReady(ResultStatus.of(ready.metadata),
+                                      ResultStatus.of(ready.coordinate),
+                                      ResultStatus.of(ready.data),
+                                      ResultStatus.of(ready.reads));
+            }
+        }
+
+        public static class Epoch
+        {
+            public final long epoch;
+            public final EpochReady ready;
+            public final Ranges global, addedRanges, removedRanges, synced, 
closed, retired;
+
+            public Epoch(long epoch, EpochReady ready, Ranges global, Ranges 
addedRanges, Ranges removedRanges, Ranges synced, Ranges closed, Ranges retired)
+            {
+                this.epoch = epoch;
+                this.ready = ready;
+                this.global = global;
+                this.addedRanges = addedRanges;
+                this.removedRanges = removedRanges;
+                this.synced = synced;
+                this.closed = closed;
+                this.retired = retired;
+            }
+        }
+
+        private static class Builder

Review Comment:
   could inline, the first draft of this wasn't defining each field at once



-- 
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: pr-unsubscr...@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org

Reply via email to