public class InMemoryTxSystemClient extends Object implements TransactionSystemClient
Constructor and Description |
---|
InMemoryTxSystemClient(TransactionManager txmgr) |
Modifier and Type | Method and Description |
---|---|
void |
abort(Transaction tx)
Makes transaction visible.
|
boolean |
canCommit(Transaction tx,
Collection<byte[]> changeIds)
Checks if transaction with the set of changes can be committed.
|
void |
canCommitOrThrow(Transaction tx,
Collection<byte[]> changeIds)
Checks if transaction with the set of changes can be committed.
|
Transaction |
checkpoint(Transaction tx)
Performs a checkpoint operation on the current transaction, returning a new Transaction instance with the
updated state.
|
boolean |
commit(Transaction tx)
Makes transaction visible.
|
void |
commitOrThrow(Transaction tx)
Makes transaction visible.
|
int |
getInvalidSize() |
InputStream |
getSnapshotInputStream()
Retrieves the state of the transaction manager and send it as a stream.
|
boolean |
invalidate(long tx)
Makes transaction invalid.
|
void |
pruneNow()
Trigger transaction pruning now.
|
void |
resetState()
Resets the state of the transaction manager.
|
Transaction |
startLong()
Starts new long transaction.
|
Transaction |
startShort()
Starts new short transaction.
|
Transaction |
startShort(int timeout)
Starts new short transaction.
|
String |
status()
Return the status of the transaction Manager
|
boolean |
truncateInvalidTx(Set<Long> invalidTxIds)
Removes the given transaction ids from the invalid list.
|
boolean |
truncateInvalidTxBefore(long time)
Removes all transaction ids started before the given time from invalid list.
|
@Inject public InMemoryTxSystemClient(TransactionManager txmgr)
public Transaction startLong()
TransactionSystemClient
startLong
in interface TransactionSystemClient
Transaction
public Transaction startShort()
TransactionSystemClient
startShort
in interface TransactionSystemClient
Transaction
public Transaction startShort(int timeout)
TransactionSystemClient
startShort
in interface TransactionSystemClient
timeout
- the timeout for the transactionTransaction
public boolean canCommit(Transaction tx, Collection<byte[]> changeIds) throws TransactionNotInProgressException
TransactionSystemClient
TransactionSystemClient.commitOrThrow(Transaction)
which will check conflicts again to avoid races.
Since we do conflict detection at commit time as well, this may seem redundant. The idea is to check for conflicts
before we persist changes to avoid rollback in case of conflicts as much as possible.
NOTE: in some situations we may want to skip this step to save on RPC with a risk of many rollback ops. So by
default we take safe path.canCommit
in interface TransactionSystemClient
tx
- transaction to verifychangeIds
- ids of changes made by transactionTransactionNotInProgressException
- if the transaction is not in progress; most likely it has timed out.public void canCommitOrThrow(Transaction tx, Collection<byte[]> changeIds) throws TransactionFailureException
TransactionSystemClient
TransactionSystemClient.commitOrThrow(Transaction)
which will check conflicts again to avoid races.
Since we do conflict detection at commit time as well, this may seem redundant. The idea is to check for conflicts
before we persist changes to avoid rollback in case of conflicts as much as possible.
NOTE: in some situations we may want to skip this step to save on RPC with a risk of many rollback ops. So by
default we take safe path.canCommitOrThrow
in interface TransactionSystemClient
tx
- transaction to verifychangeIds
- ids of changes made by transactionTransactionSizeException
- if the size of the change set exceeds the allowed limitTransactionConflictException
- if the change set has a conflict with an overlapping transactionTransactionNotInProgressException
- if the transaction is not in progress; most likely it has timed outTransactionFailureException
public boolean commit(Transaction tx) throws TransactionNotInProgressException
TransactionSystemClient
TransactionSystemClient.canCommitOrThrow(Transaction, java.util.Collection)
commit
in interface TransactionSystemClient
tx
- transaction to make visible.TransactionNotInProgressException
public void commitOrThrow(Transaction tx) throws TransactionFailureException
TransactionSystemClient
TransactionSystemClient.canCommitOrThrow(Transaction, java.util.Collection)
commitOrThrow
in interface TransactionSystemClient
tx
- transaction to make visible.TransactionConflictException
- if the transaction has a conflict with an overlapping transactionTransactionNotInProgressException
- if the transaction is not in progress; most likely it has timed outTransactionFailureException
public void abort(Transaction tx)
TransactionSystemClient
TransactionNotInProgressException
if transaction has timed out.abort
in interface TransactionSystemClient
tx
- transaction to make visible.public boolean invalidate(long tx)
TransactionSystemClient
TransactionNotInProgressException
if transaction has timed out.invalidate
in interface TransactionSystemClient
tx
- transaction id to invalidate.public Transaction checkpoint(Transaction tx) throws TransactionNotInProgressException
TransactionSystemClient
checkpoint
in interface TransactionSystemClient
tx
- the current transaction to checkpointTransactionNotInProgressException
public InputStream getSnapshotInputStream() throws TransactionCouldNotTakeSnapshotException
TransactionSystemClient
getSnapshotInputStream
in interface TransactionSystemClient
TransactionCouldNotTakeSnapshotException
public String status()
TransactionSystemClient
status
in interface TransactionSystemClient
public void resetState()
TransactionSystemClient
resetState
in interface TransactionSystemClient
public boolean truncateInvalidTx(Set<Long> invalidTxIds)
TransactionSystemClient
truncateInvalidTx
in interface TransactionSystemClient
invalidTxIds
- transaction idspublic boolean truncateInvalidTxBefore(long time) throws InvalidTruncateTimeException
TransactionSystemClient
truncateInvalidTxBefore
in interface TransactionSystemClient
time
- time in millisecondsInvalidTruncateTimeException
- if there are any in-progress transactions started before given timepublic int getInvalidSize()
getInvalidSize
in interface TransactionSystemClient
public void pruneNow()
TransactionSystemClient
pruneNow
in interface TransactionSystemClient
Copyright © 2017 The Apache Software Foundation. All rights reserved.