Class TransactionExecutor
Atomicity Guarantee: Ensures strict atomicity by acquiring a lock on the map's backing store during condition evaluation and operation execution. All conditions are evaluated before any operation is executed, ensuring no interleaving with concurrent transactions.
Design: This is a stateless utility class with a single static execute method. It is thread-safe for concurrent transaction execution on different maps. The lock acquisition uses ReentrantLock instead of synchronized to avoid virtual thread pinning.
Thread Safety: Multiple threads can safely execute transactions on the same map or different maps concurrently. Each transaction acquires a lock to ensure isolation.
- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic TransactionResultexecute(Transaction txn, DistributedMap<String, String> map) Executes a transaction atomically on the given map.
-
Method Details
-
execute
Executes a transaction atomically on the given map.Semantics: The execution is atomic: either all THEN operations execute (if all conditions are true), or all ELSE operations execute (if any condition is false). No partial execution occurs.
Ordering: All conditions are evaluated first (short-circuit evaluation). If all conditions are true, THEN operations execute. Otherwise, ELSE operations execute.
Performance: Latency is tracked and logged for performance monitoring. For transactions with many operations, latency can be significant.
- Parameters:
txn- the transaction to execute (must not be null)map- the DistributedMap to execute the transaction on (must not be null)- Returns:
- a TransactionResult indicating success/failure and operation results (never null)
- Throws:
NullPointerException- if txn or map is null
-