Class TransactionOpCode
java.lang.Object
com.loomcache.common.protocol.TransactionOpCode
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]
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordShared decoded representation of one transaction operation on the wire. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byteTransactionContext#mapDelete(structName, key).static final byteTransactionContext#mapGetForUpdate(structName, key)carried byMessageType.TX_LOCK_KEY.static final byteTransactionContext#mapPut(structName, key, value).static final byteTransactionContext#mapPutIfAbsent(structName, key, value).static final intHard cap for one stateless transaction commit frame.static final byteTransactionContext#multiMapPut(structName, key, value).static final byteTransactionContext#multiMapRemove(structName, key, value).static final byteTransactionContext#queueOffer(structName, element)— element is stored in the key field.static final byteTransactionContext#queuePoll(structName).static final byteTransactionContext#setAdd(structName, member)— member is stored in the key field.static final byteTransactionContext#setRemove(structName, member). -
Method Summary
Modifier and TypeMethodDescriptiondecode(byte[] payload) Decode oneTX_OPERATIONbody.static List<TransactionOpCode.WireOperation> decodeBatch(byte[] payload) Decode a stateless transaction-commit payload into individual operations.static byte[]Encode a single transaction operation body for theTX_OPERATIONwire message.static byte[]encodeBatch(List<TransactionOpCode.WireOperation> operations) Encode a batch of transaction operations for the statelessTX_COMMITpath.
-
Field Details
-
MAX_BATCH_OPERATION_COUNT
public static final int MAX_BATCH_OPERATION_COUNTHard cap for one stateless transaction commit frame.This is intentionally well above normal client batches while preventing a malformed payload with
Integer.MAX_VALUEoperations from forcing a hugeArrayListallocation before payload validation.- See Also:
-
MAP_PUT
public static final byte MAP_PUTTransactionContext#mapPut(structName, key, value).- See Also:
-
MAP_DELETE
public static final byte MAP_DELETETransactionContext#mapDelete(structName, key).- See Also:
-
MAP_PUT_IF_ABSENT
public static final byte MAP_PUT_IF_ABSENTTransactionContext#mapPutIfAbsent(structName, key, value).- See Also:
-
SET_ADD
public static final byte SET_ADDTransactionContext#setAdd(structName, member)— member is stored in the key field.- See Also:
-
SET_REMOVE
public static final byte SET_REMOVETransactionContext#setRemove(structName, member).- See Also:
-
QUEUE_OFFER
public static final byte QUEUE_OFFERTransactionContext#queueOffer(structName, element)— element is stored in the key field.- See Also:
-
QUEUE_POLL
public static final byte QUEUE_POLLTransactionContext#queuePoll(structName).- See Also:
-
MULTIMAP_PUT
public static final byte MULTIMAP_PUTTransactionContext#multiMapPut(structName, key, value).- See Also:
-
MULTIMAP_REMOVE
public static final byte MULTIMAP_REMOVETransactionContext#multiMapRemove(structName, key, value).- See Also:
-
MAP_LOCK_KEY
public static final byte MAP_LOCK_KEYTransactionContext#mapGetForUpdate(structName, key)carried byMessageType.TX_LOCK_KEY.- See Also:
-
-
Method Details
-
encode
Encode a single transaction operation body for theTX_OPERATIONwire message. The returned byte array is placed intoMessage#withValue(byte[]).- Parameters:
opCode- one of theMAP_*,SET_*,QUEUE_*,MULTIMAP_*constantsstructName- 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
Encode a batch of transaction operations for the statelessTX_COMMITpath.Format:
[4 bytes opCount] repeated
encode(byte, String, String, String)payloads -
decode
Decode oneTX_OPERATIONbody. -
decodeBatch
Decode a stateless transaction-commit payload into individual operations.
-