public interface Transaction extends AutoCloseable
Graph
instance. Providers may
consider using AbstractTransaction
as a base implementation that provides default features for most of
these methods.Modifier and Type | Interface and Description |
---|---|
static class |
Transaction.CLOSE_BEHAVIOR
Behaviors to supply to the
onClose(Consumer) . |
static class |
Transaction.Exceptions |
static class |
Transaction.READ_WRITE_BEHAVIOR
Behaviors to supply to the
onReadWrite(Consumer) . |
static class |
Transaction.Status
A status provided to transaction listeners to inform whether a transaction was successfully committed
or rolled back.
|
Modifier and Type | Field and Description |
---|---|
static Transaction |
NO_OP |
Modifier and Type | Method and Description |
---|---|
void |
addTransactionListener(Consumer<Transaction.Status> listener)
Adds a listener that is called back with a status when a commit or rollback is successful.
|
default <T extends TraversalSource> |
begin()
Starts a transaction in the context of a
GraphTraversalSource instance. |
<T extends TraversalSource> |
begin(Class<T> traversalSourceClass)
Starts a transaction in the context of a particular
TraversalSource instance. |
void |
clearTransactionListeners()
Removes all transaction listeners.
|
void |
close()
Closes the transaction where the default close behavior defined by {
onClose(Consumer) } will be
executed. |
void |
commit()
Commits a transaction.
|
default <G extends Graph> |
createThreadedTx()
Creates a transaction that can be executed across multiple threads.
|
boolean |
isOpen()
Determines if a transaction is currently open.
|
Transaction |
onClose(Consumer<Transaction> consumer)
Describes what happens to a transaction on a call to
Graph.close() . |
Transaction |
onReadWrite(Consumer<Transaction> consumer)
Describes how a transaction is started when a read or a write occurs.
|
void |
open()
Opens a transaction.
|
void |
readWrite()
An internal function that signals a read or a write has occurred - not meant to be called directly by end users.
|
void |
removeTransactionListener(Consumer<Transaction.Status> listener)
Removes a transaction listener.
|
void |
rollback()
Rolls back a transaction.
|
static final Transaction NO_OP
void open()
void commit()
TransactionException
on error. Providers should
consider wrapping their transaction exceptions in this TinkerPop exception as it will lead to better error
handling with Gremlin Server and other parts of the stack.void rollback()
TransactionException
on error. Providers should
consider wrapping their transaction exceptions in this TinkerPop exception as it will lead to better error
handling with Gremlin Server and other parts of the stack.default <G extends Graph> G createThreadedTx()
Graph
returned from this
method is not meant to represent some form of child transaction that can be committed from this object.
A threaded transaction is a Graph
instance that has a transaction context that enables multiple
threads to collaborate on the same transaction. A standard transactional context tied to a Graph
that supports transactions will typically bind a transaction to a single thread via ThreadLocal
.default <T extends TraversalSource> T begin()
GraphTraversalSource
instance. It is up to the
Transaction
implementation to decide what this means and up to users to be aware of that meaning.<T extends TraversalSource> T begin(Class<T> traversalSourceClass)
TraversalSource
instance. It is up to the
Transaction
implementation to decide what this means and up to users to be aware of that meaning.boolean isOpen()
void readWrite()
void close()
onClose(Consumer)
} will be
executed.close
in interface AutoCloseable
Transaction onReadWrite(Consumer<Transaction> consumer)
Transaction.READ_WRITE_BEHAVIOR
or a mapper Consumer
function.Transaction onClose(Consumer<Transaction> consumer)
Graph.close()
. This value can be set using
standard behavior defined in Transaction.CLOSE_BEHAVIOR
or a mapper Consumer
function.void addTransactionListener(Consumer<Transaction.Status> listener)
void removeTransactionListener(Consumer<Transaction.Status> listener)
void clearTransactionListeners()
Copyright © 2013–2022 Apache Software Foundation. All rights reserved.