Record Class ReplicatedTransactionCommand
java.lang.Object
java.lang.Record
com.loomcache.server.transaction.ReplicatedTransactionCommand
public record ReplicatedTransactionCommand(Transaction transaction, Map<Integer, Set<String>> mapNamesByGroup, @Nullable String senderId)
extends Record
Serialized cross-group transaction payload replicated through Raft.
The Transaction model intentionally carries only keys/operations, so
the replicated command also includes the logical map name(s) bound to each Raft
group touched by the transaction. Followers use that metadata to resolve the
correct sharded DistributedMap for state-machine apply.
Cross-group atomic BATCH (ESC-14)
Before ESC-14 each Raft group mapped to at most one logical map (Map<Integer,
String>). Cross-group atomic BATCH_EXECUTE however lets every operation
target a different logical map — which means a single Raft group can hold slices
for multiple maps in the same transaction. The shape is therefore
Map<Integer, Set<String>>. The legacy "one map per group" call sites
continue to work via mapNameForGroup(int) which returns the single
entry when the set has exactly one element, or throws otherwise so callers
cannot silently drop a map.-
Constructor Summary
ConstructorsConstructorDescriptionReplicatedTransactionCommand(Transaction transaction, Map<Integer, Set<String>> mapNamesByGroup) ReplicatedTransactionCommand(Transaction transaction, Map<Integer, Set<String>> mapNamesByGroup, @Nullable String senderId) Creates an instance of aReplicatedTransactionCommandrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.booleanfinal inthashCode()Returns a hash code value for this object.mapNameForGroup(int groupId) Returns the group's single logical map name, or throws if the group has multiple maps (cross-group atomic BATCH case — callers must usemapNamesForGroup(int)and the per-opTransaction.Operation.mapName()instead).Returns the value of themapNamesByGrouprecord component.mapNamesForGroup(int groupId) Returns all logical map names touched by this transaction ingroupId.static ReplicatedTransactionCommandofSingleMapPerGroup(Transaction transaction, Map<Integer, String> mapNameByGroup) static ReplicatedTransactionCommandofSingleMapPerGroup(Transaction transaction, Map<Integer, String> mapNameByGroup, @Nullable String senderId) Convenience factory for the legacy "one map per group" shape.@Nullable StringsenderId()Returns the value of thesenderIdrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thetransactionrecord component.
-
Constructor Details
-
ReplicatedTransactionCommand
public ReplicatedTransactionCommand(Transaction transaction, Map<Integer, Set<String>> mapNamesByGroup, @Nullable String senderId) Creates an instance of aReplicatedTransactionCommandrecord class.- Parameters:
transaction- the value for thetransactionrecord componentmapNamesByGroup- the value for themapNamesByGrouprecord componentsenderId- the value for thesenderIdrecord component
-
ReplicatedTransactionCommand
public ReplicatedTransactionCommand(Transaction transaction, Map<Integer, Set<String>> mapNamesByGroup)
-
-
Method Details
-
ofSingleMapPerGroup
public static ReplicatedTransactionCommand ofSingleMapPerGroup(Transaction transaction, Map<Integer, String> mapNameByGroup, @Nullable String senderId) Convenience factory for the legacy "one map per group" shape. Every group maps to a single-elementSet. Used by the single-map cross-group TX commit path and by tests that were written against the pre-ESC-14 wire format. -
ofSingleMapPerGroup
public static ReplicatedTransactionCommand ofSingleMapPerGroup(Transaction transaction, Map<Integer, String> mapNameByGroup) -
mapNameForGroup
Returns the group's single logical map name, or throws if the group has multiple maps (cross-group atomic BATCH case — callers must usemapNamesForGroup(int)and the per-opTransaction.Operation.mapName()instead). -
mapNamesForGroup
Returns all logical map names touched by this transaction ingroupId. Never null; never empty when the group is present inmapNamesByGroup(). -
hasConditions
public boolean hasConditions() -
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
transaction
Returns the value of thetransactionrecord component.- Returns:
- the value of the
transactionrecord component
-
mapNamesByGroup
-
senderId
Returns the value of thesenderIdrecord component.- Returns:
- the value of the
senderIdrecord component
-