ifesdjeen commented on code in PR #175:
URL: https://github.com/apache/cassandra-accord/pull/175#discussion_r1977776845


##########
accord-core/src/main/java/accord/local/durability/DurabilityQueue.java:
##########
@@ -0,0 +1,375 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package accord.local.durability;
+
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Deque;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.NavigableMap;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.concurrent.ConcurrentSkipListMap;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import accord.api.RoutingKey;
+import accord.coordinate.ExecuteSyncPoint.SyncPointErased;
+import accord.coordinate.Exhausted;
+import accord.coordinate.Timeout;
+import accord.local.AgentExecutor;
+import accord.local.Node;
+import accord.primitives.Range;
+import accord.primitives.Ranges;
+import accord.primitives.Route;
+import accord.primitives.SyncPoint;
+import accord.primitives.TxnId;
+import accord.utils.Invariants;
+import accord.utils.async.AsyncResult;
+import org.agrona.collections.ObjectHashSet;
+
+import static accord.coordinate.ExecuteSyncPoint.coordinateIncluding;
+import static accord.local.durability.DurabilityService.SyncRemote.All;
+import static java.util.concurrent.TimeUnit.MICROSECONDS;
+import static java.util.concurrent.TimeUnit.MINUTES;
+
+/**
+ * Helper methods and classes to invoke coordination to propagate information 
about durability.
+ *
+ * Both CoordinateShardDurable and CoordinateGloballyDurable use wall time to 
loosely coordinate between nodes
+ * so that they take non-overlapping (hopefully) turns doing the coordination.
+ *
+ * Both of these have a concept of rounds where rounds have a known duration 
in wall time, and the current round is known
+ * based on time since the epoch, and the point in time where a node should do 
something in a given round is known based
+ * on its index in the sorted list of nodes ids in the current epoch.
+ *
+ * Coordinate globally durable is simpler because they just need to take turns 
so nodes just calculate when it is their
+ * turn and invoke CoordinateGloballyDurable.
+ *
+ * CoordinateShardDurable needs nodes to not overlap on the ranges they 
operate on or the exlusive sync points overlap
+ * with each other and block progress. A target duration to process the entire 
ring is set, and then each node in the
+ * current round has a time in the round that it should start processing, and 
the time it starts and the subranges it is
+ * responsible for rotates backwards every round so that a down node doesn't 
prevent a subrange from being processed.
+ *
+ * The work for CoordinateShardDurable is further subdivided where each 
subrange a node operates on is divided a fixed
+ * number of times and then processed one at a time with a fixed wait between 
them.
+ *
+ * TODO (expected): cap number of coordinations we can have in flight at once
+ * TODO (expected): do not start new ExclusiveSyncPoint if we have more than X 
already agreed and not yet applied
+ * Didn't go with recurring because it doesn't play well with async execution 
of these tasks
+ */
+public class DurabilityQueue

Review Comment:
   If you find it useful, here's what I left in my notes:
   
   ```
   /**
    * Durability queue tracks and schedules exclusive durability requests after 
sync point is complete.
    *
    * Up to {@code maxConcurrency} tasks are allowed to be in flight. All 
subsequent tasks are put into the {@code pending}
    * queue, which new tasks are pulled from after the current in-progress ones 
complete. To prevent unbounded growth of the
    * pending queue, pending tasks are periodically pruned.
    */
   ```



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