Class CrossGroupTransactionContext

java.lang.Object
com.loomcache.server.sharding.CrossGroupTransactionContext

public class CrossGroupTransactionContext extends Object
Partitions a transaction's conditions and operations by their target Raft group.

Given a PartitionRouter, each condition and operation key is routed to its owning group. This allows the CrossGroupTransactionExecutor to evaluate conditions and execute operations on the correct group's data.

Since:
2.0
  • Constructor Details

    • CrossGroupTransactionContext

      public CrossGroupTransactionContext(Transaction transaction, PartitionRouter router)
      Create a cross-group context by routing all keys through the partition router.
      Parameters:
      transaction - the transaction to partition
      router - the partition router for key-to-group mapping
  • Method Details

    • sortedGroupIds

      public List<Integer> sortedGroupIds()
      Get all group IDs involved in this transaction, sorted ascending. Used for deadlock-free lock ordering.
      Returns:
      sorted list of group IDs
    • conditionsForGroup

      public List<Transaction.Condition> conditionsForGroup(int groupId)
      Get conditions targeted at a specific group.
      Parameters:
      groupId - the group ID
      Returns:
      list of conditions for this group (empty if none)
    • thenOpsForGroup

      public List<Transaction.Operation> thenOpsForGroup(int groupId)
      Get THEN operations targeted at a specific group.
      Parameters:
      groupId - the group ID
      Returns:
      list of THEN operations for this group (empty if none)
    • elseOpsForGroup

      public List<Transaction.Operation> elseOpsForGroup(int groupId)
      Get ELSE operations targeted at a specific group.
      Parameters:
      groupId - the group ID
      Returns:
      list of ELSE operations for this group (empty if none)
    • isMultiGroup

      public boolean isMultiGroup()
      Whether this transaction spans multiple groups.
      Returns:
      true if more than one group is involved
    • groupCount

      public int groupCount()
      Get the total number of groups involved.
      Returns:
      the group count