ifesdjeen commented on code in PR #194:
URL: https://github.com/apache/cassandra-accord/pull/194#discussion_r2104579781
##########
accord-core/src/main/java/accord/local/StoreParticipants.java:
##########
@@ -639,4 +653,42 @@ public static StoreParticipants all(Route<?> route)
return new StoreParticipants(route, route, false);
}
+ public static long computeFetchLowEpoch(SafeCommandStore safeStore, TxnId
txnId, Command command)
+ {
+ StoreParticipants participants = command.participants();
+ // note: we use hasTouched rather than route here, to account for
cases route is null and we have already "touched" some key in an earlier epoch
+ return computeFetchLowEpoch(safeStore, txnId,
participants.hasTouched(), participants.owns());
+ }
+
+ private static long computeFetchLowEpoch(SafeCommandStore safeStore, TxnId
txnId, Participants<?> touches, Participants<?> owns)
+ {
+ long txnIdEpoch = txnId.epoch();
+ if (txnId.is(ExclusiveSyncPoint))
+ return computeCoveringEpoch(safeStore, txnIdEpoch, touches);
+
+ if (touches.equals(owns))
+ return txnIdEpoch;
+
+ return computeUnsyncedEpoch(safeStore, txnIdEpoch, touches);
+ }
+
+ public static long computePropagateLowEpoch(SafeCommandStore safeStore,
TxnId txnId, Route<?> newRoute)
+ {
+ return computeUnsyncedEpoch(safeStore, txnId.epoch(), newRoute);
+ }
+
+ private static long computeUnsyncedEpoch(SafeCommandStore safeStore, long
txnIdEpoch, Participants<?> participants)
+ {
+ Participants<?> unsynced =
safeStore.node().topology().unsyncedOnly(participants, txnIdEpoch);
+ if (unsynced == null || unsynced.isEmpty())
+ return txnIdEpoch;
+
+ return computeCoveringEpoch(safeStore, txnIdEpoch, unsynced);
+ }
+
+ private static long computeCoveringEpoch(SafeCommandStore safeStore, long
txnIdEpoch, Participants<?> participants)
+ {
+ long lowEpoch =
safeStore.ranges().latestEarlierEpochThatFullyCovers(txnIdEpoch, participants);
Review Comment:
`latestEarlier` feels a bit hard to parse, do we need "earlier" here?
--
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]