Class DriverRemoteTransaction
- java.lang.Object
-
- org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTransaction
-
- All Implemented Interfaces:
AutoCloseable
,RemoteConnection
,Transaction
public class DriverRemoteTransaction extends Object implements Transaction, RemoteConnection
A remoteTransaction
implementation that is implemented with the Java driver. It is also a proxy for aRemoteConnection
that is bound to a session. For users, starting a transaction withTransaction.begin()
will produce aTraversalSource
that can be used across multiple threads sending the bytecode based requests to a remote session. It is worth noting that the session will process these requests in a serial fashion and not in parallel. Callingcommit()
orrollback()
will also close the session and no additional traversal can be executed on theTraversalSource
. A fresh call toTransaction.begin()
will be required to open a fresh session to work with. The default behavior ofclose()
is to commit the transaction.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.tinkerpop.gremlin.structure.Transaction
Transaction.CLOSE_BEHAVIOR, Transaction.Exceptions, Transaction.READ_WRITE_BEHAVIOR, Transaction.Status, Transaction.Symbols
-
-
Field Summary
Fields Modifier and Type Field Description protected Consumer<Transaction>
closeConsumer
-
Fields inherited from interface org.apache.tinkerpop.gremlin.process.remote.RemoteConnection
GREMLIN_REMOTE, GREMLIN_REMOTE_CONNECTION_CLASS
-
Fields inherited from interface org.apache.tinkerpop.gremlin.structure.Transaction
NO_OP
-
-
Constructor Summary
Constructors Constructor Description DriverRemoteTransaction(DriverRemoteConnection sessionBasedConnection)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTransactionListener(Consumer<Transaction.Status> listener)
There is no support for remote transaction listeners.<T extends TraversalSource>
Tbegin(Class<T> traversalSourceClass)
Starts a transaction in the context of a particularTraversalSource
instance.void
clearTransactionListeners()
There is no support for remote transaction listeners.void
close()
The default close behavior for thisTransaction
implementation is tocommit()
.void
commit()
Commits a transaction.boolean
isOpen()
Determines if a transaction is currently open.Transaction
onClose(Consumer<Transaction> consumer)
Describes what happens to a transaction on a call toGraph.close()
.Transaction
onReadWrite(Consumer<Transaction> consumer)
ThisTransaction
implementation is not auto-managed and therefore this method is not supported.void
open()
By virtue of creating aDriverRemoteTransaction
, the transaction is considered open.void
readWrite()
ThisTransaction
implementation is not auto-managed and therefore this method is not supported.void
removeTransactionListener(Consumer<Transaction.Status> listener)
There is no support for remote transaction listeners.void
rollback()
Rolls back a transaction.<E> CompletableFuture<RemoteTraversal<?,E>>
submitAsync(Bytecode bytecode)
Transaction
tx()
It is not possible to have child transactions, therefore this method always returnsTransaction.NO_OP
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.tinkerpop.gremlin.structure.Transaction
begin, createThreadedTx
-
-
-
-
Field Detail
-
closeConsumer
protected Consumer<Transaction> closeConsumer
-
-
Constructor Detail
-
DriverRemoteTransaction
public DriverRemoteTransaction(DriverRemoteConnection sessionBasedConnection)
-
-
Method Detail
-
begin
public <T extends TraversalSource> T begin(Class<T> traversalSourceClass)
Description copied from interface:Transaction
Starts a transaction in the context of a particularTraversalSource
instance. It is up to theTransaction
implementation to decide what this means and up to users to be aware of that meaning.- Specified by:
begin
in interfaceTransaction
-
open
public void open()
By virtue of creating aDriverRemoteTransaction
, the transaction is considered open. There is no need to call this method. Calling it when the transaction is closed will result in exception.- Specified by:
open
in interfaceTransaction
-
commit
public void commit()
Description copied from interface:Transaction
Commits a transaction. This method may optionally throwTransactionException
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.- Specified by:
commit
in interfaceTransaction
-
rollback
public void rollback()
Description copied from interface:Transaction
Rolls back a transaction. This method may optionally throwTransactionException
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.- Specified by:
rollback
in interfaceTransaction
-
isOpen
public boolean isOpen()
Description copied from interface:Transaction
Determines if a transaction is currently open.- Specified by:
isOpen
in interfaceTransaction
-
close
public void close()
The default close behavior for thisTransaction
implementation is tocommit()
.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceTransaction
-
readWrite
public void readWrite()
ThisTransaction
implementation is not auto-managed and therefore this method is not supported.- Specified by:
readWrite
in interfaceTransaction
-
onReadWrite
public Transaction onReadWrite(Consumer<Transaction> consumer)
ThisTransaction
implementation is not auto-managed and therefore this method is not supported.- Specified by:
onReadWrite
in interfaceTransaction
-
onClose
public Transaction onClose(Consumer<Transaction> consumer)
Description copied from interface:Transaction
Describes what happens to a transaction on a call toGraph.close()
. This value can be set using standard behavior defined inTransaction.CLOSE_BEHAVIOR
or a mapperConsumer
function.- Specified by:
onClose
in interfaceTransaction
-
addTransactionListener
public void addTransactionListener(Consumer<Transaction.Status> listener)
There is no support for remote transaction listeners.- Specified by:
addTransactionListener
in interfaceTransaction
-
removeTransactionListener
public void removeTransactionListener(Consumer<Transaction.Status> listener)
There is no support for remote transaction listeners.- Specified by:
removeTransactionListener
in interfaceTransaction
-
clearTransactionListeners
public void clearTransactionListeners()
There is no support for remote transaction listeners.- Specified by:
clearTransactionListeners
in interfaceTransaction
-
tx
public Transaction tx()
It is not possible to have child transactions, therefore this method always returnsTransaction.NO_OP
.- Specified by:
tx
in interfaceRemoteConnection
-
submitAsync
public <E> CompletableFuture<RemoteTraversal<?,E>> submitAsync(Bytecode bytecode) throws RemoteConnectionException
Description copied from interface:RemoteConnection
SubmitsTraversal
Bytecode
to a server and returns a promise of aRemoteTraversal
. TheRemoteTraversal
is an abstraction over two types of results that can be returned as part of the response from the server: the results of theTraversal
itself and the side-effects that it produced.- Specified by:
submitAsync
in interfaceRemoteConnection
- Throws:
RemoteConnectionException
-
-