Class TransactionManager

java.lang.Object
org.apache.tinkerpop.gremlin.server.transaction.TransactionManager

public class TransactionManager extends Object
Tracks active transactions and returns references of them.
  • 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 management
      graphManager - The graph manager for accessing traversal sources
      idleTransactionTimeoutMillis - Inactivity timeout in milliseconds before auto-rollback; 0 disables it
      maxTransactionLifetimeMillis - Absolute cap in milliseconds on total transaction age; 0 disables it
      maxConcurrentTransactions - Maximum number of concurrent transactions allowed
  • Method Details

    • create

      public UnmanagedTransaction create(String traversalSourceName)
      Creates a new UnmanagedTransaction for 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 exceeded
      IllegalArgumentException - if traversal source not found
      UnsupportedOperationException - if the graph does not support transactions
    • get

      public Optional<UnmanagedTransaction> get(String transactionId)
      Gets an existing UnmanagedTransaction by ID.
      Parameters:
      transactionId - The transaction ID to look up
      Returns:
      Optional containing the UnmanagedTransaction if 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.