Class TransactionManager
- java.lang.Object
-
- org.apache.tinkerpop.gremlin.server.handler.TransactionManager
-
public class TransactionManager extends Object
Tracks active transactions and returns references of them.
-
-
Constructor Summary
Constructors Constructor Description TransactionManager(ScheduledExecutorService scheduledExecutorService, GraphManager graphManager, long transactionTimeoutMs, int maxConcurrentTransactions, long perGraphCloseMs)Creates a new TransactionManager with the specified configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UnmanagedTransactioncreate(String traversalSourceName)Creates a newUnmanagedTransactionfor the specified traversal source.voiddestroy(String id)Removes a transaction from the active transactions map.Optional<UnmanagedTransaction>get(String transactionId)Gets an existingUnmanagedTransactionby ID.intgetActiveTransactionCount()Returns the number of currently active transactions.voidshutdown()Shuts down the transaction manager, rolling back all active transactions.
-
-
-
Constructor Detail
-
TransactionManager
public TransactionManager(ScheduledExecutorService scheduledExecutorService, GraphManager graphManager, long transactionTimeoutMs, int maxConcurrentTransactions, long perGraphCloseMs)
Creates a new TransactionManager with the specified configuration.- Parameters:
scheduledExecutorService- Scheduler for timeout managementgraphManager- The graph manager for accessing traversal sourcestransactionTimeoutMs- Timeout in milliseconds before auto-rollbackmaxConcurrentTransactions- Maximum number of concurrent transactions allowed
-
-
Method Detail
-
create
public UnmanagedTransaction create(String traversalSourceName)
Creates a newUnmanagedTransactionfor the specified traversal source.- Parameters:
traversalSourceName- The traversal source alias (e.g., "g")- Returns:
- The new
UnmanagedTransaction, ready for task submission - Throws:
IllegalStateException- if max transactions exceededIllegalArgumentException- if traversal source not foundUnsupportedOperationException- if the graph does not support transactions
-
destroy
public void destroy(String id)
Removes a transaction from the active transactions map. Called when a transaction is committed, rolled back, or otherwise closed.- Parameters:
id- The transaction ID to remove
-
get
public Optional<UnmanagedTransaction> get(String transactionId)
Gets an existingUnmanagedTransactionby ID.- Parameters:
transactionId- The transaction ID to look up- Returns:
- Optional containing the
UnmanagedTransactionif found, empty otherwise
-
getActiveTransactionCount
public int getActiveTransactionCount()
Returns the number of currently active transactions.- Returns:
- the count of active transactions
-
shutdown
public void shutdown()
Shuts down the transaction manager, rolling back all active transactions.This method should be called during server shutdown to ensure all transactions are properly cleaned up. It blocks until all rollbacks complete.
-
-