Interface TwoPhaseCommands
- All Known Implementing Classes:
TwoPhaseCommands.CoordDecide, TwoPhaseCommands.CoordPrepare, TwoPhaseCommands.DecideAck, TwoPhaseCommands.DecideGroup, TwoPhaseCommands.DecideQuery, TwoPhaseCommands.PrepareAck, TwoPhaseCommands.PrepareGroup
public sealed interface TwoPhaseCommands
permits TwoPhaseCommands.PrepareGroup, TwoPhaseCommands.PrepareAck, TwoPhaseCommands.DecideGroup, TwoPhaseCommands.DecideAck, TwoPhaseCommands.DecideQuery, TwoPhaseCommands.CoordPrepare, TwoPhaseCommands.CoordDecide
Sealed command types for the cross-group 2PC protocol introduced in
BLK-2026-04-22-001 Phase C.
Each command is serialized via a manual DataOutputStream layout
(no Kryo dependency) so the wire format is stable across versions and does
not participate in the Kryo-ID lock-in table.
Foundation-only commit: command records + serialize/deserialize methods. Coordinator + participant + CacheNode dispatch follow in subsequent commits. HARD SAFETY RAIL 5 (Raft apply invariants) is preserved because this commit adds types but does not change any apply-path code.
Sealed hierarchy:
TwoPhaseCommand
├─ PrepareGroup — coordinator -> participant group leader
├─ PrepareAck — participant group -> coordinator
├─ DecideGroup — coordinator -> participant group leader
├─ DecideAck — participant group -> coordinator
└─ DecideQuery — recovering participant -> coordinator
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordDurable coordinator DECIDE record, replicated through raft-0's own log BEFORE the coordinator fans TX_DECIDE_GROUP out to the participant groups.static final recordDurable coordinator PREPARE record, replicated through raft-0's own log.static final recordAcknowledgment from a participant that it applied the coordinator's decision.static final recordPhase-2 decision broadcast from the coordinator to each participant.static final recordQuery from a recovering participant to the coordinator: "what decision did you make for this transaction?"static enumCoordinator decision in phase 2.static interfaceInternal writer callback used bywriteFrame(TwoPhaseCommands.Kind, TwoPhaseCommands.FrameWriter).static enumWire kind tag — serialized as the first byte of every frame.static final recordPhase-1 vote from a participant group back to the coordinator.static final recordTransaction phase-1 request from coordinator to a participant group.static enumParticipant vote in phase 1. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final int -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic @NonNull TwoPhaseCommandsdeserialize(byte @NonNull [] bytes) Deserialize a wire frame into the matching command record.static @NonNull List<Class<? extends TwoPhaseCommands>> static byte @NonNull []serialize(@NonNull TwoPhaseCommands cmd) Serialize any command instance.
-
Field Details
-
MAX_PARTICIPANT_GROUP_COUNT
static final int MAX_PARTICIPANT_GROUP_COUNT- See Also:
-
MAX_OPERATION_PAYLOAD_BYTES
static final int MAX_OPERATION_PAYLOAD_BYTES- See Also:
-
MAX_REASON_UTF_BYTES
static final int MAX_REASON_UTF_BYTES- See Also:
-
-
Method Details
-
deserialize
Deserialize a wire frame into the matching command record.- Parameters:
bytes- the wire frame (first byte is the Kind ordinal)- Returns:
- the parsed command
- Throws:
IllegalArgumentException- if the frame is truncated / has an unknown kind
-
serialize
Serialize any command instance. Sugar over the per-recordserializemethods so callers can take a polymorphicTwoPhaseCommandsreference. -
knownTypes
- Returns:
- the list of all TwoPhaseCommands sealed subtypes. Useful for dispatch tables and test coverage assertions.
-