public abstract class AbstractTransaction<T extends CellId> extends Object implements Transaction
Transaction interface.
Provides extra methods to access other basic transaction state required by
TransactionManager implementations based on snapshot
isolation.
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 class |
AbstractTransaction.VisibilityLevel |
Transaction.Status| Modifier and Type | Field and Description |
|---|---|
protected long |
readTimestamp |
protected long |
writeTimestamp |
| Constructor and Description |
|---|
AbstractTransaction(long transactionId,
long readTimestamp,
AbstractTransaction.VisibilityLevel visibilityLevel,
long epoch,
Set<T> writeSet,
Set<T> conflictFreeWriteSet,
AbstractTransactionManager transactionManager,
boolean isLowLatency) |
AbstractTransaction(long transactionId,
long epoch,
Set<T> writeSet,
Set<T> conflictFreeWriteSet,
AbstractTransactionManager transactionManager,
boolean isLowLatency)
Base constructor
|
AbstractTransaction(long transactionId,
long epoch,
Set<T> writeSet,
Set<T> conflictFreeWriteSet,
AbstractTransactionManager transactionManager,
long readTimestamp,
long writeTimestamp,
boolean isLowLatency)
Base constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
addConflictFreeWriteSetElement(T element)
Adds an element to the transaction conflict free write-set.
|
void |
addWriteSetElement(T element)
Adds an element to the transaction write-set.
|
void |
appendMetadata(String key,
Object value)
Expects they metadata stored under key "key" to be of the "Set" type,
append "value" to the existing set or creates a new one
|
void |
checkpoint()
Creates a checkpoint and sets the visibility level to SNAPSHOT_EXCLUDE_CURRENT
The number of checkpoints is bounded to NUM_CHECKPOINTS in order to make checkpoint a client side operation
|
abstract void |
cleanup()
Allows to define specific clean-up task for transaction implementations
|
long |
getCommitTimestamp()
Returns the commit timestamp for this transaction.
|
Set<T> |
getConflictFreeWriteSet()
Returns the current write-set for this transaction that its elements are not candidates for conflict analysis.
|
long |
getEpoch()
Returns the epoch given by the TSOServer
|
org.apache.phoenix.thirdparty.com.google.common.base.Optional<Object> |
getMetadata(String key) |
long |
getReadTimestamp()
Returns the read timestamp for this transaction.
|
long |
getStartTimestamp()
Returns the start timestamp for this transaction.
|
Transaction.Status |
getStatus()
Returns the current transaction
Transaction.Status |
long |
getTransactionId()
Returns the transaction identifier
|
AbstractTransactionManager |
getTransactionManager()
Returns transaction manager associated to this transaction.
|
AbstractTransaction.VisibilityLevel |
getVisibilityLevel()
Returns the visibility level for this transaction.
|
Set<T> |
getWriteSet()
Returns the current write-set for this transaction.
|
long |
getWriteTimestamp()
Returns the write timestamp for this transaction.
|
boolean |
isLowLatency()
Returns whether the transaction was created by a lowLatency TransactionalManager
|
boolean |
isRollbackOnly()
Returns whether the transaction was marked for rollback or not
|
void |
setCommitTimestamp(long commitTimestamp)
Sets the commit timestamp for this transaction.
|
void |
setMetadata(String key,
Object value) |
void |
setRollbackOnly()
Forces the transaction to rollback, even when there's an intention
to commit it.
|
void |
setStatus(Transaction.Status status)
Sets the status for this transaction.
|
void |
setVisibilityLevel(AbstractTransaction.VisibilityLevel visibilityLevel)
Sets the visibility level for this transaction.
|
String |
toString() |
protected long readTimestamp
protected long writeTimestamp
public AbstractTransaction(long transactionId,
long epoch,
Set<T> writeSet,
Set<T> conflictFreeWriteSet,
AbstractTransactionManager transactionManager,
boolean isLowLatency)
transactionId - transaction identifier to assignepoch - epoch of the TSOServer instance that created this transaction
Used in High Availability to guarantee data consistencywriteSet - initial write set for the transaction.
Should be empty in most cases.conflictFreeWriteSet - initial conflict free write set for the transaction.
Should be empty in most cases.transactionManager - transaction manager associated to this transaction.
Usually, should be the one that created the transaction
instance.public AbstractTransaction(long transactionId,
long readTimestamp,
AbstractTransaction.VisibilityLevel visibilityLevel,
long epoch,
Set<T> writeSet,
Set<T> conflictFreeWriteSet,
AbstractTransactionManager transactionManager,
boolean isLowLatency)
public AbstractTransaction(long transactionId,
long epoch,
Set<T> writeSet,
Set<T> conflictFreeWriteSet,
AbstractTransactionManager transactionManager,
long readTimestamp,
long writeTimestamp,
boolean isLowLatency)
transactionId - transaction identifier to assignepoch - epoch of the TSOServer instance that created this transaction
Used in High Availability to guarantee data consistencywriteSet - initial write set for the transaction.
Should be empty in most cases.transactionManager - transaction manager associated to this transaction.
Usually, should be the one that created the transaction
instance.readTimestamp - the snapshot to read fromwriteTimestamp - the timestamp to write topublic void checkpoint()
throws TransactionException
TransactionExceptionpublic abstract void cleanup()
public long getTransactionId()
TransactiongetTransactionId in interface TransactionTransaction.getTransactionId()public long getEpoch()
TransactiongetEpoch in interface TransactionTransaction.getEpoch()public Transaction.Status getStatus()
TransactionTransaction.StatusgetStatus in interface TransactionTransaction.getStatus()public void setRollbackOnly()
TransactionsetRollbackOnly in interface TransactionTransaction.isRollbackOnly()public boolean isRollbackOnly()
TransactionisRollbackOnly in interface TransactionTransaction.isRollbackOnly()public AbstractTransactionManager getTransactionManager()
public long getStartTimestamp()
public long getReadTimestamp()
getReadTimestamp in interface Transactionpublic long getWriteTimestamp()
getWriteTimestamp in interface Transactionpublic long getCommitTimestamp()
public AbstractTransaction.VisibilityLevel getVisibilityLevel()
public void setCommitTimestamp(long commitTimestamp)
commitTimestamp - the commit timestamp to setpublic void setVisibilityLevel(AbstractTransaction.VisibilityLevel visibilityLevel)
visibilityLevel - the AbstractTransaction.VisibilityLevel to setpublic void setStatus(Transaction.Status status)
status - the Status to setpublic Set<T> getWriteSet()
public Set<T> getConflictFreeWriteSet()
public void addWriteSetElement(T element)
element - the element to addpublic void addConflictFreeWriteSetElement(T element)
element - the element to addpublic org.apache.phoenix.thirdparty.com.google.common.base.Optional<Object> getMetadata(String key)
getMetadata in interface Transactionpublic void appendMetadata(String key, Object value)
appendMetadata in interface Transactionkey - a key, like in hashtablevalue - a value to associate with the given keypublic void setMetadata(String key, Object value)
setMetadata in interface Transactionpublic boolean isLowLatency()
TransactionisLowLatency in interface TransactionCopyright © 2011–2020 Apache Software Foundation. All rights reserved.