public class TransactionManager
extends com.google.common.util.concurrent.AbstractService
Modifier and Type | Class and Description |
---|---|
static class |
TransactionManager.ChangeSet
Represents a set of changes from a client.
|
static class |
TransactionManager.InProgressTx
Represents some of the info on in-progress tx
|
static class |
TransactionManager.InProgressType
Type of in-progress transaction.
|
Constructor and Description |
---|
TransactionManager(org.apache.hadoop.conf.Configuration config) |
TransactionManager(org.apache.hadoop.conf.Configuration conf,
TransactionStateStorage persistor,
MetricsCollector txMetricsCollector) |
Modifier and Type | Method and Description |
---|---|
void |
abort(Transaction tx) |
void |
canCommit(long txId,
Collection<byte[]> changeIds) |
Transaction |
checkpoint(Transaction originalTx) |
void |
commit(long txId,
long writePointer) |
void |
doStart() |
void |
doStop() |
TransactionSnapshot |
getCurrentState() |
int |
getExcludedListSize() |
int |
getInvalidSize() |
TransactionSnapshot |
getSnapshot() |
TransactionStateStorage |
getTransactionStateStorage() |
static long |
getTxExpirationFromWritePointer(long writePointer,
long timeoutInSeconds) |
boolean |
invalidate(long tx) |
void |
logStatistics()
Called from the tx service every 10 seconds.
|
void |
recoverState() |
void |
resetState()
Resets the state of the transaction manager.
|
Transaction |
startLong()
Start a long transaction.
|
Transaction |
startLong(String clientId)
Starts a long transaction with a client id.
|
Transaction |
startShort()
Start a short transaction with the default timeout.
|
Transaction |
startShort(int timeoutInSeconds)
Start a short transaction with a given timeout.
|
Transaction |
startShort(String clientId)
Start a short transaction with a client id and default timeout.
|
Transaction |
startShort(String clientId,
int timeoutInSeconds)
Start a short transaction with a given timeout.
|
boolean |
takeSnapshot(OutputStream out)
Take a snapshot of the transaction state and serialize it into the given output stream.
|
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.
|
static Map<Long,TransactionManager.InProgressTx> |
txnBackwardsCompatCheck(int defaultLongTimeout,
long longTimeoutTolerance,
Map<Long,TransactionManager.InProgressTx> inProgress)
Check if in-progress transactions need to be migrated to have expiration time and type, if so do the migration.
|
public TransactionManager(org.apache.hadoop.conf.Configuration config)
@Inject public TransactionManager(org.apache.hadoop.conf.Configuration conf, @Nonnull TransactionStateStorage persistor, MetricsCollector txMetricsCollector)
public void doStart()
doStart
in class com.google.common.util.concurrent.AbstractService
public TransactionSnapshot getSnapshot() throws IOException
IOException
public boolean takeSnapshot(OutputStream out) throws IOException
IOException
public TransactionSnapshot getCurrentState()
public void recoverState()
public static Map<Long,TransactionManager.InProgressTx> txnBackwardsCompatCheck(int defaultLongTimeout, long longTimeoutTolerance, Map<Long,TransactionManager.InProgressTx> inProgress)
public void resetState()
public void doStop()
doStop
in class com.google.common.util.concurrent.AbstractService
public Transaction startShort()
public Transaction startShort(String clientId)
clientId
- id of the client requesting a transaction.public Transaction startShort(int timeoutInSeconds)
timeoutInSeconds
- the time out period in seconds.public Transaction startShort(String clientId, int timeoutInSeconds)
clientId
- id of the client requesting a transaction.timeoutInSeconds
- the time out period in seconds.public static long getTxExpirationFromWritePointer(long writePointer, long timeoutInSeconds)
public Transaction startLong()
public Transaction startLong(String clientId)
public void canCommit(long txId, Collection<byte[]> changeIds) throws TransactionNotInProgressException, TransactionSizeException, TransactionConflictException
public void commit(long txId, long writePointer) throws TransactionNotInProgressException, TransactionConflictException
public void abort(Transaction tx)
public boolean invalidate(long tx)
public boolean truncateInvalidTx(Set<Long> invalidTxIds)
invalidTxIds
- transaction idspublic boolean truncateInvalidTxBefore(long time) throws InvalidTruncateTimeException
time
- time in millisecondsInvalidTruncateTimeException
- if there are any in-progress transactions started before given timepublic Transaction checkpoint(Transaction originalTx) throws TransactionNotInProgressException
public int getExcludedListSize()
public int getInvalidSize()
public void logStatistics()
public TransactionStateStorage getTransactionStateStorage()
Copyright © 2018 The Apache Software Foundation. All rights reserved.