public class DetachedTxSystemClient extends Object implements TransactionSystemClient
Constructor and Description |
---|
DetachedTxSystemClient() |
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.
|
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.
|
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 |
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.
|
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 Transaction startLong()
TransactionSystemClient
startLong
in interface TransactionSystemClient
Transaction
public boolean canCommit(Transaction tx, Collection<byte[]> changeIds)
TransactionSystemClient
TransactionSystemClient.commit(Transaction)
which may 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 transactionpublic boolean commit(Transaction tx)
TransactionSystemClient
TransactionSystemClient.canCommit(Transaction, java.util.Collection)
commit
in interface TransactionSystemClient
tx
- transaction to make visible.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)
TransactionSystemClient
checkpoint
in interface TransactionSystemClient
tx
- the current transaction to checkpointpublic 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
Copyright © 2016 The Apache Software Foundation. All rights reserved.