public abstract class AbstractTransactionManager extends Object implements TransactionManager
TransactionManager interface.
Provides extra methods to allow transaction manager developers to perform
different actions before/after the methods exposed by the TransactionManager interface.
So, this abstract class must be extended by particular implementations of
transaction managers related to different storage systems (HBase...)| Modifier and Type | Class and Description |
|---|---|
static interface |
AbstractTransactionManager.TransactionFactory<T extends CellId> |
| Modifier and Type | Field and Description |
|---|---|
protected CommitTable.Client |
commitTableClient |
protected TSOProtocol |
tsoClient |
| Constructor and Description |
|---|
AbstractTransactionManager(MetricsRegistry metrics,
PostCommitActions postCommitter,
TSOProtocol tsoClient,
CommitTable.Client commitTableClient,
CommitTable.Writer commitTableWriter,
AbstractTransactionManager.TransactionFactory<? extends CellId> transactionFactory)
Base constructor
|
| Modifier and Type | Method and Description |
|---|---|
Transaction |
begin()
Starts a new transaction.
|
void |
close() |
protected abstract void |
closeResources() |
void |
commit(Transaction transaction)
Commits a transaction.
|
Transaction |
fence(byte[] tableName)
Creates a fence
Creates a fence and returns a
Transaction interface implementation that contains the fence information. |
CommitTable.Client |
getCommitTableClient()
Return the commit table client
|
abstract long |
getHashForTable(byte[] tableName)
Generates hash ID for table name, this hash is later-on sent to the TSO and used for fencing
|
boolean |
isLowLatency() |
void |
postBegin(AbstractTransaction<? extends CellId> transaction)
Allows transaction manager developers to perform actions after having started a transaction.
|
void |
postCommit(AbstractTransaction<? extends CellId> transaction)
Allows transaction manager developers to perform actions after committing a transaction.
|
void |
postRollback(AbstractTransaction<? extends CellId> transaction)
Allows transaction manager developers to perform actions after rolling-back a transaction.
|
void |
preBegin()
Allows transaction manager developers to perform actions before creating a transaction.
|
void |
preCommit(AbstractTransaction<? extends CellId> transaction)
Allows transaction manager developers to perform actions before committing a transaction.
|
void |
preRollback(AbstractTransaction<? extends CellId> transaction)
Allows transaction manager developers to perform actions before rolling-back a transaction.
|
void |
rollback(Transaction transaction)
Aborts a transaction.
|
protected final TSOProtocol tsoClient
protected final CommitTable.Client commitTableClient
public AbstractTransactionManager(MetricsRegistry metrics, PostCommitActions postCommitter, TSOProtocol tsoClient, CommitTable.Client commitTableClient, CommitTable.Writer commitTableWriter, AbstractTransactionManager.TransactionFactory<? extends CellId> transactionFactory)
metrics - instrumentation metricspostCommitter - post commit action executortsoClient - a client for accessing functionality of the status oraclecommitTableClient - a client for accessing functionality of the commit tabletransactionFactory - a transaction factory to create the specific transaction
objects required by the transaction manager being implemented.public void preBegin()
throws TransactionManagerException
TransactionManagerException - in case of any issuespublic final Transaction begin() throws TransactionException
TransactionManagerTransaction interface implementation that will be used in TTable's methods for
doing operations on the transactional context defined by the returned object.begin in interface TransactionManagerTransactionException - in case of any issuesTransactionManager.begin()public abstract long getHashForTable(byte[] tableName)
tableName - - the table namepublic CommitTable.Client getCommitTableClient()
public final Transaction fence(byte[] tableName) throws TransactionException
TransactionManagerTransaction interface implementation that contains the fence information.fence in interface TransactionManagertableName - name of the table that requires a fenceTransactionException - in case of any issuesTransactionManager.fence(byte[])public void postBegin(AbstractTransaction<? extends CellId> transaction) throws TransactionManagerException
transaction - the transaction that was just created.TransactionManagerException - in case of any issuespublic void preCommit(AbstractTransaction<? extends CellId> transaction) throws TransactionManagerException
transaction - the transaction that is going to be committed.TransactionManagerException - in case of any issuespublic final void commit(Transaction transaction) throws RollbackException, TransactionException
TransactionManagerRollbackException will be thrown.commit in interface TransactionManagertransaction - transaction to be committed.RollbackException - thrown when transaction has conflicts with another transaction or when was marked
for rollback.TransactionException - in case of any issuesTransactionManager.commit(Transaction)public void postCommit(AbstractTransaction<? extends CellId> transaction) throws TransactionManagerException
transaction - the transaction that was committed.TransactionManagerException - in case of any issuespublic void preRollback(AbstractTransaction<? extends CellId> transaction) throws TransactionManagerException
transaction - the transaction that is going to be rolled-back.TransactionManagerException - in case of any issuespublic final void rollback(Transaction transaction) throws TransactionException
TransactionManagerrollback in interface TransactionManagertransaction - transaction to be rolled-backTransactionException - in case of any issuesTransactionManager.rollback(Transaction)public void postRollback(AbstractTransaction<? extends CellId> transaction) throws TransactionManagerException
transaction - the transaction that was rolled-back.TransactionManagerException - in case of any issuesprotected abstract void closeResources()
throws IOException
IOExceptionpublic final void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCloseable.close()public boolean isLowLatency()
Copyright © 2011–2020 Apache Software Foundation. All rights reserved.