|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.zookeeper.server.persistence.FileTxnLog
public class FileTxnLog
This class implements the TxnLog interface. It provides api's to access the txnlogs and add entries to it.
The format of a Transactional log is as follows:
LogFile:
FileHeader TxnList ZeroPad
FileHeader: {
magic 4bytes (ZKLG)
version 4bytes
dbid 8bytes
}
TxnList:
Txn || Txn TxnList
Txn:
checksum Txnlen TxnHeader Record 0x42
checksum: 8bytes Adler32 is currently used
calculated across payload -- Txnlen, TxnHeader, Record and 0x42
Txnlen:
len 4bytes
TxnHeader: {
sessionid 8bytes
cxid 4bytes
zxid 8bytes
time 8bytes
type 4bytes
}
Record:
See Jute definition file for details on the various record types
ZeroPad:
0 padded to EOF (filled during preallocation stage)
| Nested Class Summary | |
|---|---|
static class |
FileTxnLog.FileTxnIterator
this class implements the txnlog iterator interface which is used for reading the transaction logs |
| Nested classes/interfaces inherited from interface org.apache.zookeeper.server.persistence.TxnLog |
|---|
TxnLog.TxnIterator |
| Field Summary | |
|---|---|
static int |
TXNLOG_MAGIC
|
static int |
VERSION
|
| Constructor Summary | |
|---|---|
FileTxnLog(File logDir)
constructor for FileTxnLog. |
|
| Method Summary | |
|---|---|
boolean |
append(TxnHeader hdr,
org.apache.jute.Record txn)
append an entry to the transaction log |
void |
close()
close all the open file handles |
void |
commit()
commit the logs. |
long |
getDbId()
the dbid of this transaction database |
long |
getLastLoggedZxid()
get the last zxid that was logged in the transaction logs |
static File[] |
getLogFiles(File[] logDirList,
long snapshotZxid)
Find the log file that starts at, or just before, the snapshot. |
boolean |
isForceSync()
the forceSync value. |
protected Checksum |
makeChecksumAlgorithm()
creates a checksum alogrithm to be used |
TxnLog.TxnIterator |
read(long zxid)
start reading all the transactions from the given zxid |
void |
rollLog()
rollover the current log file to a new one. |
static void |
setPreallocSize(long size)
method to allow setting preallocate size of log file to pad the file. |
boolean |
truncate(long zxid)
truncate the current transaction logs |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int TXNLOG_MAGIC
public static final int VERSION
| Constructor Detail |
|---|
public FileTxnLog(File logDir)
logDir - the directory where the txnlogs are stored| Method Detail |
|---|
public static void setPreallocSize(long size)
size - the size to set to in bytesprotected Checksum makeChecksumAlgorithm()
public void rollLog()
throws IOException
rollLog in interface TxnLogIOException
public void close()
throws IOException
close in interface TxnLogIOException
public boolean append(TxnHeader hdr,
org.apache.jute.Record txn)
throws IOException
append in interface TxnLoghdr - the header of the transactiontxn - the transaction part of the entry
returns true iff something appended, otw false
IOException
public static File[] getLogFiles(File[] logDirList,
long snapshotZxid)
logDirList - array of filessnapshotZxid - return files at, or before this zxid
public long getLastLoggedZxid()
getLastLoggedZxid in interface TxnLog
public void commit()
throws IOException
commit in interface TxnLogIOException
public TxnLog.TxnIterator read(long zxid)
throws IOException
read in interface TxnLogzxid - the zxid to start reading transactions from
IOException
public boolean truncate(long zxid)
throws IOException
truncate in interface TxnLogzxid - the zxid to truncate the logs to
IOException
public long getDbId()
throws IOException
getDbId in interface TxnLogIOExceptionpublic boolean isForceSync()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||