public abstract class AbstractTransactionAwareTable extends Object implements TransactionAware
TransactionAwareHTable
implementations.Modifier and Type | Class and Description |
---|---|
protected class |
AbstractTransactionAwareTable.ActionChange
Record of each transaction that causes a change.
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
allowNonTransactional |
protected Map<Long,Set<AbstractTransactionAwareTable.ActionChange>> |
changeSets |
protected TxConstants.ConflictDetection |
conflictLevel |
protected Transaction |
tx |
protected TransactionCodec |
txCodec |
Constructor and Description |
---|
AbstractTransactionAwareTable(TxConstants.ConflictDetection conflictLevel,
boolean allowNonTransactional) |
Modifier and Type | Method and Description |
---|---|
protected void |
addToChangeSet(byte[] row,
byte[] family,
byte[] qualifier) |
boolean |
commitTx()
Called before transaction has been committed.
|
protected abstract boolean |
doCommit()
Commits any pending writes by flushing the wrapped
HTable instance. |
protected abstract boolean |
doRollback()
Rolls back any persisted changes from the transaction by issuing offsetting deletes to the
wrapped
HTable instance. |
boolean |
getAllowNonTransactional()
True if the instance allows non-transaction operations.
|
byte[] |
getChangeKey(byte[] row,
byte[] family,
byte[] qualifier) |
protected abstract byte[] |
getTableKey()
Returns the table name to use as a key prefix for the transaction change set.
|
String |
getTransactionAwareName()
Used for error reporting.
|
Collection<byte[]> |
getTxChanges() |
void |
postTxCommit()
Called after transaction has been committed.
|
boolean |
rollbackTx()
Called during transaction rollback (for whatever reason: conflicts, errors, etc.).
|
void |
setAllowNonTransactional(boolean allowNonTransactional)
Set whether the instance allows non-transactional operations.
|
void |
startTx(Transaction tx)
Called when new transaction has started.
|
void |
updateTx(Transaction tx)
Called when the state of the current transaction has been updated.
|
protected final TransactionCodec txCodec
protected final Map<Long,Set<AbstractTransactionAwareTable.ActionChange>> changeSets
protected final TxConstants.ConflictDetection conflictLevel
protected Transaction tx
protected boolean allowNonTransactional
public AbstractTransactionAwareTable(TxConstants.ConflictDetection conflictLevel, boolean allowNonTransactional)
public boolean getAllowNonTransactional()
public void setAllowNonTransactional(boolean allowNonTransactional)
allowNonTransactional
- public void startTx(Transaction tx)
TransactionAware
startTx
in interface TransactionAware
tx
- transaction infopublic void updateTx(Transaction tx)
TransactionAware
Transaction
held by this TransactionAware
, but should not reset
any state (such as the write change sets) that is currently maintained.updateTx
in interface TransactionAware
tx
- the updated transactionpublic Collection<byte[]> getTxChanges()
getTxChanges
in interface TransactionAware
public byte[] getChangeKey(byte[] row, byte[] family, byte[] qualifier)
public boolean commitTx() throws Exception
TransactionAware
commitTx
in interface TransactionAware
Exception
protected abstract boolean doCommit() throws IOException
HTable
instance.IOException
public void postTxCommit()
TransactionAware
postTxCommit
in interface TransactionAware
public String getTransactionAwareName()
TransactionAware
getTransactionAwareName
in interface TransactionAware
protected abstract byte[] getTableKey()
public boolean rollbackTx() throws Exception
TransactionAware
rollbackTx
in interface TransactionAware
Exception
protected abstract boolean doRollback() throws Exception
HTable
instance. How this is handled will depend on the delete API exposed
by the specific version of HBase.Exception
protected void addToChangeSet(byte[] row, byte[] family, byte[] qualifier)
Copyright © 2016 The Apache Software Foundation. All rights reserved.