Interface TwoPhaseCommands

All Known Implementing Classes:
TwoPhaseCommands.CoordDecide, TwoPhaseCommands.CoordPrepare, TwoPhaseCommands.DecideAck, TwoPhaseCommands.DecideGroup, TwoPhaseCommands.DecideQuery, TwoPhaseCommands.PrepareAck, TwoPhaseCommands.PrepareGroup

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
  • Field Details

  • Method Details

    • deserialize

      static @NonNull TwoPhaseCommands deserialize(byte @NonNull [] bytes)
      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

      static byte @NonNull [] serialize(@NonNull TwoPhaseCommands cmd)
      Serialize any command instance. Sugar over the per-record serialize methods so callers can take a polymorphic TwoPhaseCommands reference.
    • knownTypes

      static @NonNull List<Class<? extends TwoPhaseCommands>> knownTypes()
      Returns:
      the list of all TwoPhaseCommands sealed subtypes. Useful for dispatch tables and test coverage assertions.