public class FileTxnSnapLog extends Object
Modifier and Type | Class and 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 and Description |
---|---|
static String |
version |
static int |
VERSION |
static String |
ZOOKEEPER_DATADIR_AUTOCREATE |
static String |
ZOOKEEPER_DATADIR_AUTOCREATE_DEFAULT |
static String |
ZOOKEEPER_SNAPSHOT_TRUST_EMPTY |
Constructor and Description |
---|
FileTxnSnapLog(File dataDir,
File snapDir)
the constructor which takes the datadir and
snapdir.
|
Modifier and Type | Method and 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,
Map<Long,Integer> sessions,
FileTxnSnapLog.PlayBackListener listener)
This function will fast forward the server database to have the latest
transactions in it.
|
File |
findMostRecentSnapshot()
the most recent snapshot in the snapshot
directory
|
List<File> |
findNRecentSnapshots(int n)
the n most recent snapshots
|
List<File> |
findNValidSnapshots(int n)
the n recent valid snapshots
|
File |
getDataDir()
get the datadir used by this filetxn
snap log
|
long |
getLastLoggedZxid()
the last logged zxid on the transaction logs
|
SnapshotInfo |
getLastSnapshotInfo()
get information of the last saved/restored snapshot
|
File |
getSnapDir()
get the snap dir used by this
filetxn snap log
|
File[] |
getSnapshotLogs(long zxid)
get the snapshot logs which may contain transactions newer than the given zxid.
|
long |
getTotalLogSize() |
long |
getTxnLogElapsedSyncTime() |
void |
processTransaction(TxnHeader hdr,
DataTree dt,
Map<Long,Integer> sessions,
Record txn)
process the transaction on the datatree
|
TxnLog.TxnIterator |
readTxnLog(long zxid)
Get TxnIterator for iterating through txnlog starting at a given zxid
|
TxnLog.TxnIterator |
readTxnLog(long zxid,
boolean fastForward)
Get TxnIterator for iterating through txnlog starting at a given zxid
|
long |
restore(DataTree dt,
Map<Long,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,
ConcurrentHashMap<Long,Integer> sessionsWithTimeouts,
boolean syncSnap)
save the datatree and the sessions into a snapshot
|
void |
setServerStats(ServerStats serverStats) |
void |
setTotalLogSize(long size) |
boolean |
shouldForceWriteInitialSnapshotAfterLeaderElection()
whether to force the write of an initial snapshot after a leader election,
to address ZOOKEEPER-3781 after upgrading from Zookeeper 3.4.x.
|
boolean |
truncateLog(long zxid)
truncate the transaction logs the zxid
specified
|
public static final int VERSION
public static final String version
public static final String ZOOKEEPER_DATADIR_AUTOCREATE
public static final String ZOOKEEPER_DATADIR_AUTOCREATE_DEFAULT
public static final String ZOOKEEPER_SNAPSHOT_TRUST_EMPTY
public FileTxnSnapLog(File dataDir, File snapDir) throws IOException
dataDir
- the transaction directorysnapDir
- the snapshot directoryIOException
public void setServerStats(ServerStats serverStats)
public File getDataDir()
public File getSnapDir()
public SnapshotInfo getLastSnapshotInfo()
public boolean shouldForceWriteInitialSnapshotAfterLeaderElection()
public long restore(DataTree dt, Map<Long,Integer> sessions, FileTxnSnapLog.PlayBackListener listener) throws IOException
dt
- the datatree to be restoredsessions
- the sessions to be restoredlistener
- the playback listener to run on the
database restorationIOException
public long fastForwardFromEdits(DataTree dt, Map<Long,Integer> sessions, FileTxnSnapLog.PlayBackListener listener) throws IOException
dt
- the datatree to write transactions to.sessions
- the sessions to be restored.listener
- the playback listener to run on the
database transactions.IOException
public TxnLog.TxnIterator readTxnLog(long zxid) throws IOException
zxid
- starting zxidIOException
public TxnLog.TxnIterator readTxnLog(long zxid, boolean fastForward) throws IOException
zxid
- starting zxidfastForward
- true if the iterator should be fast forwarded to point
to the txn of a given zxid, else the iterator will point to the
starting txn of a txnlog that may contain txn of a given zxidIOException
public void processTransaction(TxnHeader hdr, DataTree dt, Map<Long,Integer> sessions, 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.NoNodeException
public long getLastLoggedZxid()
public void save(DataTree dataTree, ConcurrentHashMap<Long,Integer> sessionsWithTimeouts, boolean syncSnap) throws IOException
dataTree
- the datatree to be serialized onto disksessionsWithTimeouts
- the session timeouts to be
serialized onto disksyncSnap
- sync the snapshot immediately after writeIOException
public boolean truncateLog(long zxid)
zxid
- the zxid to truncate the logs toIOException
public File findMostRecentSnapshot() throws IOException
IOException
public List<File> findNRecentSnapshots(int n) throws IOException
n
- the number of recent snapshotsIOException
public List<File> findNValidSnapshots(int n)
n
- the number of recent valid snapshotspublic File[] getSnapshotLogs(long zxid)
zxid
- the zxid that contains logs greater than
zxidpublic boolean append(Request si) throws IOException
si
- the request to be appendedIOException
public void commit() throws IOException
IOException
public long getTxnLogElapsedSyncTime()
public void rollLog() throws IOException
IOException
public void close() throws IOException
IOException
public void setTotalLogSize(long size)
public long getTotalLogSize()
Copyright © 2008–2023 The Apache Software Foundation. All rights reserved.