belliottsmith commented on code in PR #10:
URL: https://github.com/apache/cassandra-accord/pull/10#discussion_r979042670


##########
accord-core/src/main/java/accord/local/Command.java:
##########
@@ -274,99 +289,110 @@ public boolean commit(Txn txn, Key homeKey, Key 
progressKey, Timestamp executeAt
             });
         }
 
-        if (waitingOnCommit.isEmpty())
-        {
-            waitingOnCommit = null;
-            if (waitingOnApply.isEmpty())
-                waitingOnApply = null;
-        }
 
-        boolean isProgressShard = progressKey != null && handles(txnId.epoch, 
progressKey);
-        commandStore.progressLog().commit(txnId, isProgressShard, 
isProgressShard && progressKey.equals(homeKey));
+        boolean isProgressShard = progressKey != null && 
handles(txnId().epoch, progressKey);
+        commandStore().progressLog().commit(txnId(), isProgressShard, 
isProgressShard && progressKey.equals(homeKey));
 
-        maybeExecute(false);
-        listeners.forEach(this);
         return true;
     }
 
+    public Future<Void> commitAndBeginExecution(Txn txn, Key homeKey, Key 
progressKey, Timestamp executeAt, Deps deps)
+    {
+        if (!commit(txn, homeKey, progressKey, executeAt, deps))
+            return Write.SUCCESS;
+
+        return maybeExecute(true);
+    }
+
+    // TODO (now): commitInvalidate may need to update cfks _if_ possible
     public boolean commitInvalidate()
     {
         if (hasBeen(Committed))
         {
+            logger.trace("{}: skipping commit invalidated - already committed 
({})", txnId(), status());
             if (!hasBeen(Invalidated))
-                commandStore.agent().onInconsistentTimestamp(this, 
Timestamp.NONE, executeAt);
+                commandStore().agent().onInconsistentTimestamp(this, 
Timestamp.NONE, executeAt());
 
             return false;
         }
 
-        status = Invalidated;
+        status(Invalidated);
 
-        boolean isProgressShard = progressKey != null && handles(txnId.epoch, 
progressKey);
-        commandStore.progressLog().invalidate(txnId, isProgressShard, 
isProgressShard && progressKey.equals(homeKey));
+        boolean isProgressShard = progressKey() != null && 
handles(txnId().epoch, progressKey());
+        commandStore().progressLog().invalidate(txnId(), isProgressShard, 
isProgressShard && progressKey().equals(homeKey()));
+        logger.trace("{}: committed invalidated", txnId());
 
-        listeners.forEach(this);
+        notifyListeners();
         return true;
     }
 
-    public boolean apply(Txn txn, Key homeKey, Key progressKey, Timestamp 
executeAt, Deps deps, Writes writes, Result result)
+    public Future<Void> apply(Txn txn, Key homeKey, Key progressKey, Timestamp 
executeAt, Deps deps, Writes writes, Result result)

Review Comment:
   It seems totally reasonable to introduce a new status `Applying` or 
something, that avoids duplicated work.



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