ifesdjeen commented on code in PR #3431:
URL: https://github.com/apache/cassandra/pull/3431#discussion_r1687594904
##########
src/java/org/apache/cassandra/journal/Journal.java:
##########
@@ -112,31 +116,92 @@ public class Journal<K, V> implements Shutdownable
private final WaitQueue segmentPrepared = newWaitQueue();
private final WaitQueue allocatorThreadWaitQueue = newWaitQueue();
private final BooleanSupplier allocatorThreadWaitCondition = () ->
(availableSegment == null);
+ private final FlusherCallbacks flusherCallbacks;
SequentialExecutorPlus closer;
//private final Set<Descriptor> invalidations =
Collections.newSetFromMap(new ConcurrentHashMap<>());
+ private class FlusherCallbacks implements Flusher.Callbacks
+ {
+ private final Queue<WaitingFor> waitingFor = new
ConcurrentLinkedQueue<>();
+
+ @Override
+ public void onFlush(long segment, int position)
+ {
+ Iterator<WaitingFor> iter = waitingFor.iterator();
+ while (iter.hasNext())
+ {
+ WaitingFor wait = iter.next();
+ if (wait.segment == segment && wait.position <= position)
+ {
+ wait.run();
+ iter.remove();
+ }
+ }
+ }
+
+ @Override
+ public void onFlushFailed(Throwable cause)
+ {
+ // TODO: panic
+ }
+
+ public void submit(RecordPointer pointer, Runnable runnable)
+ {
+ WaitingFor wait = new WaitingFor(pointer.segment,
pointer.position, runnable);
+ waitingFor.add(wait);
+ if (isFlushed(pointer))
+ wait.run();
+ }
+ }
+
+ private static class WaitingFor extends RecordPointer implements Runnable
+ {
+ private final AtomicReference<Runnable> onFlushed;
Review Comment:
It will catch up. Atomic's purpose was to avoid double-running, but it
should never happen, just a precaution really.
##########
src/java/org/apache/cassandra/service/accord/AccordCommandStore.java:
##########
@@ -333,22 +331,32 @@ public AccordStateCache.Instance<Key, CommandsForKey,
AccordSafeCommandsForKey>
{
return commandsForKeyCache;
}
- Command loadCommand(TxnId txnId)
+
+ @Nullable
+ Runnable appendToKeyspace(Command before, Command after)
{
- return AccordKeyspace.loadCommand(this, txnId);
+ if (after.keysOrRanges() != null && after.keysOrRanges() instanceof
Keys)
+ return NO_OP;
Review Comment:
Great point!
--
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]