bdeggleston commented on code in PR #33:
URL: https://github.com/apache/cassandra-accord/pull/33#discussion_r1123661596
##########
accord-core/src/main/java/accord/local/Command.java:
##########
@@ -109,1087 +313,758 @@ public boolean is(Status status)
* Once this restriction is imposed, we no longer need to pass around
Routable.Domain with TxnId.
*/
public abstract RoutingKey homeKey();
- protected abstract void setHomeKey(RoutingKey key);
+ public abstract TxnId txnId();
+ public abstract Ballot promised();
+ public abstract Status.Durability durability();
+ public abstract Listeners.Immutable listeners();
+ public abstract SaveStatus saveStatus();
- public abstract RoutingKey progressKey();
- protected abstract void setProgressKey(RoutingKey key);
+ static boolean isSameClass(Command command, Class<? extends Command> klass)
+ {
+ return command.getClass() == klass;
+ }
- /**
- * If this is the home shard, we require that this is a Route for all
states > NotWitnessed;
- * otherwise for the local progress shard this is ordinarily a
PartialRoute, and for other shards this is not set,
- * so that there is only one copy per node that can be consulted to
construct the full set of involved keys.
- *
- * If hasBeen(Committed) this must contain the keys for both txnId.epoch
and executeAt.epoch
- */
- public abstract @Nullable Route<?> route();
- protected abstract void setRoute(Route<?> route);
+ private static void checkNewBallot(Ballot current, Ballot next, String
name)
+ {
+ if (next.compareTo(current) < 0)
+ throw new IllegalArgumentException(String.format("Cannot update %s
ballot from %s to %s. New ballot is less than current", name, current, next));
+ }
- public abstract PartialTxn partialTxn();
- protected abstract void setPartialTxn(PartialTxn txn);
+ private static void checkPromised(Command command, Ballot ballot)
+ {
+ checkNewBallot(command.promised(), ballot, "promised");
+ }
- public abstract Ballot promised();
- protected abstract void setPromised(Ballot ballot);
+ private static void checkAccepted(Command command, Ballot ballot)
+ {
+ checkNewBallot(command.accepted(), ballot, "accepted");
+ }
- public abstract Ballot accepted();
- protected abstract void setAccepted(Ballot ballot);
+ private static void checkSameClass(Command command, Class<? extends
Command> klass, String errorMsg)
+ {
+ if (!isSameClass(command, klass))
+ throw new IllegalArgumentException(errorMsg + format(" expected %s
got %s", klass.getSimpleName(), command.getClass().getSimpleName()));
+ }
- public abstract Timestamp executeAt();
- protected abstract void setExecuteAt(Timestamp timestamp);
+ // TODO (low priority, progress): callers should try to consult the local
progress shard (if any) to obtain the full set of keys owned locally
+ public final Route<?> someRoute()
+ {
+ if (route() != null)
+ return route();
- /**
- * While !hasBeen(Committed), used only as a register for Accept state,
used by Recovery
- * If hasBeen(Committed), represents the full deps owned by this range for
execution at both txnId.epoch
- * AND executeAt.epoch so that it may be used for Recovery (which contacts
only txnId.epoch topology),
- * but also for execution.
- */
- public abstract PartialDeps partialDeps();
- protected abstract void setPartialDeps(PartialDeps deps);
+ if (homeKey() != null)
+ return PartialRoute.empty(txnId().domain(), homeKey());
- public abstract Writes writes();
- protected abstract void setWrites(Writes writes);
+ return null;
+ }
- public abstract Result result();
- protected abstract void setResult(Result result);
+ public Unseekables<?, ?> maxUnseekables()
+ {
+ Route<?> route = someRoute();
+ if (route == null)
+ return null;
- public abstract SaveStatus saveStatus();
- protected abstract void setSaveStatus(SaveStatus status);
+ return route.toMaximalUnseekables();
+ }
+
+ public PreLoadContext contextForSelf()
+ {
+ return contextForCommand(this);
+ }
- public Status status() { return saveStatus().status; }
- protected void setStatus(Status status) {
setSaveStatus(SaveStatus.get(status, known())); }
+ public abstract Timestamp executeAt();
+ public abstract Ballot accepted();
+ public abstract PartialTxn partialTxn();
+ public abstract @Nullable PartialDeps partialDeps();
- public Known known() { return saveStatus().known; }
+ public final Status status()
+ {
+ return saveStatus().status;
+ }
- public abstract Durability durability();
- public abstract void setDurability(Durability v);
+ public final Status.Known known()
+ {
+ return saveStatus().known;
+ }
- public abstract Command addListener(CommandListener listener);
- public abstract void removeListener(CommandListener listener);
- protected abstract void notifyListeners(SafeCommandStore safeStore);
+ public boolean hasBeenWitnessed()
+ {
+ return partialTxn() != null;
Review Comment:
removed
--
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]