public class FileTxnSnapLog
extends java.lang.Object
| Modifier and Type | Class | Description |
|---|---|---|
static class |
FileTxnSnapLog.DatadirException |
|
static class |
FileTxnSnapLog.LogDirContentCheckException |
|
static interface |
FileTxnSnapLog.PlayBackListener |
This listener helps
the external apis calling
restore to gather information
while the data is being
restored.
|
static class |
FileTxnSnapLog.SnapDirContentCheckException |
| Modifier and Type | Field | Description |
|---|---|---|
static java.lang.String |
version |
|
static int |
VERSION |
| Constructor | Description |
|---|---|
FileTxnSnapLog(java.io.File dataDir,
java.io.File snapDir) |
the constructor which takes the datadir and
snapdir.
|
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
append(Request si) |
append the request to the transaction logs
|
void |
close() |
close the transaction log files
|
void |
commit() |
commit the transaction of logs
|
long |
fastForwardFromEdits(DataTree dt,
java.util.Map<java.lang.Long,java.lang.Integer> sessions,
FileTxnSnapLog.PlayBackListener listener) |
This function will fast forward the server database to have the latest
transactions in it.
|
java.io.File |
findMostRecentSnapshot() |
the most recent snapshot in the snapshot
directory
|
java.util.List<java.io.File> |
findNRecentSnapshots(int n) |
the n most recent snapshots
|
java.io.File |
getDataDir() |
get the datadir used by this filetxn
snap log
|
long |
getLastLoggedZxid() |
the last logged zxid on the transaction logs
|
java.io.File |
getSnapDir() |
get the snap dir used by this
filetxn snap log
|
java.io.File[] |
getSnapshotLogs(long zxid) |
get the snapshot logs which may contain transactions newer than the given zxid.
|
void |
processTransaction(TxnHeader hdr,
DataTree dt,
java.util.Map<java.lang.Long,java.lang.Integer> sessions,
org.apache.jute.Record txn) |
process the transaction on the datatree
|
long |
restore(DataTree dt,
java.util.Map<java.lang.Long,java.lang.Integer> sessions,
FileTxnSnapLog.PlayBackListener listener) |
this function restores the server
database after reading from the
snapshots and transaction logs
|
void |
rollLog() |
roll the transaction logs
|
void |
save(DataTree dataTree,
java.util.concurrent.ConcurrentHashMap<java.lang.Long,java.lang.Integer> sessionsWithTimeouts) |
save the datatree and the sessions into a snapshot
|
boolean |
truncateLog(long zxid) |
truncate the transaction logs the zxid
specified
|
public static final int VERSION
public static final java.lang.String version
public FileTxnSnapLog(java.io.File dataDir,
java.io.File snapDir)
throws java.io.IOException
dataDir - the trasaction directorysnapDir - the snapshot directoryjava.io.IOExceptionpublic java.io.File getDataDir()
public java.io.File getSnapDir()
public long restore(DataTree dt, java.util.Map<java.lang.Long,java.lang.Integer> sessions, FileTxnSnapLog.PlayBackListener listener) throws java.io.IOException
dt - the datatree to be restoredsessions - the sessions to be restoredlistener - the playback listener to run on the
database restorationjava.io.IOExceptionpublic long fastForwardFromEdits(DataTree dt, java.util.Map<java.lang.Long,java.lang.Integer> sessions, FileTxnSnapLog.PlayBackListener listener) throws java.io.IOException
dt - the datatree to write transactions to.sessions - the sessions to be restored.listener - the playback listener to run on the
database transactions.java.io.IOExceptionpublic void processTransaction(TxnHeader hdr, DataTree dt, java.util.Map<java.lang.Long,java.lang.Integer> sessions, org.apache.jute.Record txn) throws KeeperException.NoNodeException
hdr - the hdr of the transactiondt - the datatree to apply transaction tosessions - the sessions to be restoredtxn - the transaction to be appliedKeeperException.NoNodeExceptionpublic long getLastLoggedZxid()
public void save(DataTree dataTree, java.util.concurrent.ConcurrentHashMap<java.lang.Long,java.lang.Integer> sessionsWithTimeouts) throws java.io.IOException
dataTree - the datatree to be serialized onto disksessionsWithTimeouts - the sesssion timeouts to be
serialized onto diskjava.io.IOExceptionpublic boolean truncateLog(long zxid)
throws java.io.IOException
zxid - the zxid to truncate the logs tojava.io.IOExceptionpublic java.io.File findMostRecentSnapshot()
throws java.io.IOException
java.io.IOExceptionpublic java.util.List<java.io.File> findNRecentSnapshots(int n)
throws java.io.IOException
n - the number of recent snapshotsjava.io.IOExceptionpublic java.io.File[] getSnapshotLogs(long zxid)
zxid - the zxid that contains logs greater than
zxidpublic boolean append(Request si) throws java.io.IOException
si - the request to be appended
returns true iff something appended, otw falsejava.io.IOExceptionpublic void commit()
throws java.io.IOException
java.io.IOExceptionpublic void rollLog()
throws java.io.IOException
java.io.IOExceptionpublic void close()
throws java.io.IOException
java.io.IOExceptionCopyright © 2018 The Apache Software Foundation