public class HDFSTransactionStateStorage extends AbstractTransactionStateStorage
data.tx.snapshot.dir configuration property.
Both snapshot and transaction log files are suffixed with a timestamp to allow easy ordering. Snapshot files
are written with the filename "snapshot.<timestamp>". Transaction log files are written with the filename
"txlog.<timestamp>".codecProvider| Constructor and Description |
|---|
HDFSTransactionStateStorage(org.apache.hadoop.conf.Configuration hConf,
SnapshotCodecProvider codecProvider,
MetricsCollector metricsCollector) |
| Modifier and Type | Method and Description |
|---|---|
TransactionLog |
createLog(long timestamp)
Creates a new
TransactionLog. |
void |
deleteLogsOlderThan(long timestamp)
Removes any transaction logs with a timestamp older than the given value.
|
long |
deleteOldSnapshots(int numberToKeep)
Removes any snapshots prior to the
numberToKeep most recent. |
TransactionSnapshot |
getLatestSnapshot()
Returns the most recent snapshot that has been successfully written.
|
String |
getLocation()
Returns a string representation of the location used for persistence.
|
List<TransactionLog> |
getLogsSince(long timestamp)
Returns all
TransactionLogs with a timestamp greater than or equal to the given timestamp. |
List<String> |
listLogs()
Returns the (non-qualified) names of available logs.
|
List<String> |
listSnapshots()
Returns the (non-qualified) names of available snapshots.
|
static void |
main(String[] args)
Reads a transaction state snapshot or transaction log from HDFS and prints the entries to stdout.
|
protected void |
shutDown() |
protected void |
startUp() |
void |
writeSnapshot(TransactionSnapshot snapshot)
Persists a snapshot of transaction state.
|
writeSnapshotaddListener, executor, isRunning, start, startAndWait, state, stop, stopAndWait, toString@Inject
public HDFSTransactionStateStorage(org.apache.hadoop.conf.Configuration hConf,
SnapshotCodecProvider codecProvider,
MetricsCollector metricsCollector)
protected void startUp()
throws Exception
startUp in class com.google.common.util.concurrent.AbstractIdleServiceExceptionprotected void shutDown()
throws Exception
shutDown in class com.google.common.util.concurrent.AbstractIdleServiceExceptionpublic void writeSnapshot(TransactionSnapshot snapshot) throws IOException
TransactionStateStorageIOExceptionpublic TransactionSnapshot getLatestSnapshot() throws IOException
TransactionStateStoragenull
if no completed snapshot files are found.IOExceptionpublic long deleteOldSnapshots(int numberToKeep)
throws IOException
TransactionStateStoragenumberToKeep most recent.numberToKeep - The number of most recent snapshots to keep.IOException - If an error occurs while deleting old snapshots.public List<String> listSnapshots() throws IOException
TransactionStateStorageIOExceptionpublic List<TransactionLog> getLogsSince(long timestamp) throws IOException
TransactionStateStorageTransactionLogs with a timestamp greater than or equal to the given timestamp. Note that
the returned list is guaranteed to be sorted in ascending timestamp order.IOExceptionpublic TransactionLog createLog(long timestamp) throws IOException
TransactionStateStorageTransactionLog.IOExceptionpublic void deleteLogsOlderThan(long timestamp)
throws IOException
TransactionStateStoragetimestamp - The timestamp to delete up to. Logs with a timestamp less than this value will be removed.IOException - If an error occurs while removing logs.public List<String> listLogs() throws IOException
TransactionStateStorageIOExceptionpublic String getLocation()
TransactionStateStoragepublic static void main(String[] args)
args - Copyright © 2015. All Rights Reserved.