Class TransactionOpCode

java.lang.Object
com.loomcache.common.protocol.TransactionOpCode

public final class TransactionOpCode extends Object
Wire-level op codes used inside a MessageType.TX_OPERATION body.

The transaction feature buffers operations inside a server-side TransactionContext; each buffered op is represented on the wire as a compact length-prefixed binary record. This class owns both the opcode constants and the encoder shared between client and server.

Body layout

  [1 byte  opcode]
  [2 bytes structureName len (unsigned)]
  [N bytes structureName UTF-8]
  [2 bytes key len (unsigned)]
  [N bytes key UTF-8]
  [4 bytes value len]
  [N bytes value UTF-8]
  • Field Details

    • MAX_BATCH_OPERATION_COUNT

      public static final int MAX_BATCH_OPERATION_COUNT
      Hard cap for one stateless transaction commit frame.

      This is intentionally well above normal client batches while preventing a malformed payload with Integer.MAX_VALUE operations from forcing a huge ArrayList allocation before payload validation.

      See Also:
    • MAP_PUT

      public static final byte MAP_PUT
      TransactionContext#mapPut(structName, key, value).
      See Also:
    • MAP_DELETE

      public static final byte MAP_DELETE
      TransactionContext#mapDelete(structName, key).
      See Also:
    • MAP_PUT_IF_ABSENT

      public static final byte MAP_PUT_IF_ABSENT
      TransactionContext#mapPutIfAbsent(structName, key, value).
      See Also:
    • SET_ADD

      public static final byte SET_ADD
      TransactionContext#setAdd(structName, member) — member is stored in the key field.
      See Also:
    • SET_REMOVE

      public static final byte SET_REMOVE
      TransactionContext#setRemove(structName, member).
      See Also:
    • QUEUE_OFFER

      public static final byte QUEUE_OFFER
      TransactionContext#queueOffer(structName, element) — element is stored in the key field.
      See Also:
    • QUEUE_POLL

      public static final byte QUEUE_POLL
      TransactionContext#queuePoll(structName).
      See Also:
    • MULTIMAP_PUT

      public static final byte MULTIMAP_PUT
      TransactionContext#multiMapPut(structName, key, value).
      See Also:
    • MULTIMAP_REMOVE

      public static final byte MULTIMAP_REMOVE
      TransactionContext#multiMapRemove(structName, key, value).
      See Also:
    • MAP_LOCK_KEY

      public static final byte MAP_LOCK_KEY
      TransactionContext#mapGetForUpdate(structName, key) carried by MessageType.TX_LOCK_KEY.
      See Also:
  • Method Details

    • encode

      public static byte[] encode(byte opCode, String structName, String key, @Nullable String value)
      Encode a single transaction operation body for the TX_OPERATION wire message. The returned byte array is placed into Message#withValue(byte[]).
      Parameters:
      opCode - one of the MAP_*, SET_*, QUEUE_*, MULTIMAP_* constants
      structName - target data-structure name (never null)
      key - primary key / member / element (never null — use empty string for ops that do not require a key)
      value - value (may be null or empty)
      Returns:
      length-prefixed binary body
    • encodeBatch

      public static byte[] encodeBatch(List<TransactionOpCode.WireOperation> operations)
      Encode a batch of transaction operations for the stateless TX_COMMIT path.

      Format:

        [4 bytes opCount]
        repeated encode(byte, String, String, String) payloads
      
    • decode

      public static TransactionOpCode.WireOperation decode(byte[] payload)
      Decode one TX_OPERATION body.
    • decodeBatch

      public static List<TransactionOpCode.WireOperation> decodeBatch(byte[] payload)
      Decode a stateless transaction-commit payload into individual operations.