Class TransactionManager
java.lang.Object
org.apache.tinkerpop.gremlin.server.transaction.TransactionManager
Tracks active transactions and returns references of them.
-
Constructor Summary
ConstructorsConstructorDescriptionTransactionManager(ScheduledExecutorService scheduledExecutorService, GraphManager graphManager, long idleTransactionTimeoutMillis, long maxTransactionLifetimeMillis, int maxConcurrentTransactions, long perGraphCloseMillis) Creates a new TransactionManager with the specified configuration. -
Method Summary
Modifier and TypeMethodDescriptionCreates a newUnmanagedTransactionfor the specified traversal source.Gets an existingUnmanagedTransactionby ID.intReturns the number of currently active transactions.voidshutdown()Shuts down the transaction manager, rolling back all active transactions.
-
Constructor Details
-
TransactionManager
public TransactionManager(ScheduledExecutorService scheduledExecutorService, GraphManager graphManager, long idleTransactionTimeoutMillis, long maxTransactionLifetimeMillis, int maxConcurrentTransactions, long perGraphCloseMillis) Creates a new TransactionManager with the specified configuration.- Parameters:
scheduledExecutorService- Scheduler for timeout managementgraphManager- The graph manager for accessing traversal sourcesidleTransactionTimeoutMillis- Inactivity timeout in milliseconds before auto-rollback;0disables itmaxTransactionLifetimeMillis- Absolute cap in milliseconds on total transaction age;0disables itmaxConcurrentTransactions- Maximum number of concurrent transactions allowed
-
-
Method Details
-
create
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
-
get
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.
-