public class TransactionServiceClient extends Object implements TransactionSystemClient
| Constructor and Description |
|---|
TransactionServiceClient(org.apache.hadoop.conf.Configuration config,
ThriftClientProvider clientProvider)
Create from a configuration.
|
TransactionServiceClient(org.apache.hadoop.conf.Configuration config,
ThriftClientProvider clientProvider,
String clientId)
Create from a configuration.
|
| 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.
|
static void |
doMain(boolean verbose,
org.apache.hadoop.conf.Configuration conf) |
int |
getInvalidSize() |
InputStream |
getSnapshotInputStream()
Retrieves the state of the transaction manager and send it as a stream.
|
boolean |
invalidate(long tx)
Makes transaction invalid.
|
static void |
main(String[] args)
Utility to be used for basic verification of transaction system availability and functioning
|
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.
|
public TransactionServiceClient(org.apache.hadoop.conf.Configuration config,
ThriftClientProvider clientProvider)
config - a configuration containing the zookeeper properties@Inject
public TransactionServiceClient(org.apache.hadoop.conf.Configuration config,
ThriftClientProvider clientProvider,
String clientId)
config - a configuration containing the zookeeper propertiesclientId - id of the client that identifies it when it starts a transactionpublic static void main(String[] args) throws Exception
args - arguments list, accepts single option "-v" that makes it to print out more details about started txExceptionpublic static void doMain(boolean verbose,
org.apache.hadoop.conf.Configuration conf)
throws Exception
Exceptionpublic Transaction startLong()
TransactionSystemClientstartLong in interface TransactionSystemClientTransactionpublic Transaction startShort()
TransactionSystemClientstartShort in interface TransactionSystemClientTransactionpublic Transaction startShort(int timeout)
TransactionSystemClientstartShort in interface TransactionSystemClienttimeout - the timeout for the transactionTransactionpublic boolean canCommit(Transaction tx, Collection<byte[]> changeIds) throws TransactionNotInProgressException
TransactionSystemClientTransactionSystemClient.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 TransactionSystemClienttx - 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
TransactionSystemClientTransactionSystemClient.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 TransactionSystemClienttx - 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 outTransactionFailureExceptionpublic boolean commit(Transaction tx) throws TransactionNotInProgressException
TransactionSystemClientTransactionSystemClient.canCommitOrThrow(Transaction, java.util.Collection)commit in interface TransactionSystemClienttx - transaction to make visible.TransactionNotInProgressExceptionpublic void commitOrThrow(Transaction tx) throws TransactionFailureException
TransactionSystemClientTransactionSystemClient.canCommitOrThrow(Transaction, java.util.Collection)commitOrThrow in interface TransactionSystemClienttx - 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 outTransactionFailureExceptionpublic void abort(Transaction tx)
TransactionSystemClientTransactionNotInProgressException if transaction has timed out.abort in interface TransactionSystemClienttx - transaction to make visible.public boolean invalidate(long tx)
TransactionSystemClientTransactionNotInProgressException if transaction has timed out.invalidate in interface TransactionSystemClienttx - transaction id to invalidate.public Transaction checkpoint(Transaction tx) throws TransactionNotInProgressException
TransactionSystemClientcheckpoint in interface TransactionSystemClienttx - the current transaction to checkpointTransactionNotInProgressExceptionpublic InputStream getSnapshotInputStream() throws TransactionCouldNotTakeSnapshotException
TransactionSystemClientgetSnapshotInputStream in interface TransactionSystemClientTransactionCouldNotTakeSnapshotExceptionpublic String status()
TransactionSystemClientstatus in interface TransactionSystemClientpublic void resetState()
TransactionSystemClientresetState in interface TransactionSystemClientpublic boolean truncateInvalidTx(Set<Long> invalidTxIds)
TransactionSystemClienttruncateInvalidTx in interface TransactionSystemClientinvalidTxIds - transaction idspublic boolean truncateInvalidTxBefore(long time)
throws InvalidTruncateTimeException
TransactionSystemClienttruncateInvalidTxBefore in interface TransactionSystemClienttime - time in millisecondsInvalidTruncateTimeException - if there are any in-progress transactions started before given timepublic int getInvalidSize()
getInvalidSize in interface TransactionSystemClientpublic void pruneNow()
TransactionSystemClientpruneNow in interface TransactionSystemClientCopyright © 2018 The Apache Software Foundation. All rights reserved.