|
||||||||||
| 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(java.io.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 java.io.File[] |
getLogFiles(java.io.File[] logDirList,
long snapshotZxid)
Find the log file that starts at, or just before, the snapshot. |
boolean |
isForceSync()
the forceSync value. |
protected java.util.zip.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(java.io.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 java.util.zip.Checksum makeChecksumAlgorithm()
public void rollLog()
throws java.io.IOException
rollLog in interface TxnLogjava.io.IOException
public void close()
throws java.io.IOException
close in interface TxnLogjava.io.IOException
public boolean append(TxnHeader hdr,
org.apache.jute.Record txn)
throws java.io.IOException
append in interface TxnLoghdr - the header of the transactiontxn - the transaction part of the entry
returns true iff something appended, otw false
java.io.IOException
public static java.io.File[] getLogFiles(java.io.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 java.io.IOException
commit in interface TxnLogjava.io.IOException
public TxnLog.TxnIterator read(long zxid)
throws java.io.IOException
read in interface TxnLogzxid - the zxid to start reading transactions from
java.io.IOException
public boolean truncate(long zxid)
throws java.io.IOException
truncate in interface TxnLogzxid - the zxid to truncate the logs to
java.io.IOException
public long getDbId()
throws java.io.IOException
getDbId in interface TxnLogjava.io.IOExceptionpublic boolean isForceSync()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||