Class AbstractThreadLocalTransaction
java.lang.Object
org.apache.tinkerpop.gremlin.structure.util.AbstractTransaction
org.apache.tinkerpop.gremlin.structure.util.AbstractThreadLocalTransaction
- All Implemented Interfaces:
AutoCloseable,Transaction
A base implementation of
Transaction that provides core functionality for transaction listeners using
ThreadLocal. In this implementation, the listeners are bound to the current thread of execution (usually
the same as the transaction for most graph database implementations). Therefore, when AbstractTransaction.commit() is
called on a particular thread, the only listeners that get notified are those bound to that thread.- Author:
- Stephen Mallette (http://stephen.genoprime.com)
- See Also:
-
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
FieldsModifier and TypeFieldDescriptionprotected final ThreadLocal<Consumer<Transaction>>protected final ThreadLocal<Consumer<Transaction>>protected final ThreadLocal<List<Consumer<Transaction.Status>>>Fields inherited from interface org.apache.tinkerpop.gremlin.structure.Transaction
NO_OP -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTransactionListener(Consumer<Transaction.Status> listener) Adds a listener that is called back with a status when a commit or rollback is successful.voidRemoves all transaction listeners.protected voiddoClose()CalledAbstractTransaction.close().protected voidCalledAbstractTransaction.readWrite().protected voidCalled withinAbstractTransaction.commit()just after the internal call toAbstractTransaction.doCommit().protected voidCalled withinAbstractTransaction.rollback()just after the internal call toAbstractTransaction.doRollback()()}.onClose(Consumer<Transaction> consumer) Describes what happens to a transaction on a call toGraph.close().onReadWrite(Consumer<Transaction> consumer) Describes how a transaction is started when a read or a write occurs.voidremoveTransactionListener(Consumer<Transaction.Status> listener) Removes a transaction listener.Methods inherited from class org.apache.tinkerpop.gremlin.structure.util.AbstractTransaction
begin, close, commit, createThreadedTx, doCommit, doOpen, doRollback, readWrite, rollbackMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.tinkerpop.gremlin.structure.Transaction
begin, isOpen
-
Field Details
-
readWriteConsumerInternal
-
closeConsumerInternal
-
transactionListeners
-
-
Constructor Details
-
AbstractThreadLocalTransaction
-
-
Method Details
-
fireOnCommit
protected void fireOnCommit()Description copied from class:AbstractTransactionCalled withinAbstractTransaction.commit()just after the internal call toAbstractTransaction.doCommit(). Implementations of this method should raiseTransaction.Status.COMMITevents to any listeners added viaTransaction.addTransactionListener(Consumer).- Specified by:
fireOnCommitin classAbstractTransaction
-
fireOnRollback
protected void fireOnRollback()Description copied from class:AbstractTransactionCalled withinAbstractTransaction.rollback()just after the internal call toAbstractTransaction.doRollback()()}. Implementations of this method should raiseTransaction.Status.ROLLBACKevents to any listeners added viaTransaction.addTransactionListener(Consumer).- Specified by:
fireOnRollbackin classAbstractTransaction
-
addTransactionListener
Description copied from interface:TransactionAdds a listener that is called back with a status when a commit or rollback is successful. It is expected that listeners be bound to the current thread as is standard for transactions. Therefore a listener registered in the current thread will not get callback events from a commit or rollback call in a different thread. -
removeTransactionListener
Description copied from interface:TransactionRemoves a transaction listener. -
clearTransactionListeners
public void clearTransactionListeners()Description copied from interface:TransactionRemoves all transaction listeners. -
doReadWrite
protected void doReadWrite()Description copied from class:AbstractTransactionCalledAbstractTransaction.readWrite(). Implementers should run their readWrite consumer here.- Specified by:
doReadWritein classAbstractTransaction
-
doClose
protected void doClose()Description copied from class:AbstractTransactionCalledAbstractTransaction.close(). Implementers should run their readWrite consumer here.- Specified by:
doClosein classAbstractTransaction
-
onReadWrite
Description copied from interface:TransactionDescribes how a transaction is started when a read or a write occurs. This value can be set using standard behaviors defined inTransaction.READ_WRITE_BEHAVIORor a mapperConsumerfunction. -
onClose
Description copied from interface:TransactionDescribes what happens to a transaction on a call toGraph.close(). This value can be set using standard behavior defined inTransaction.CLOSE_BEHAVIORor a mapperConsumerfunction.
-