Class FileTxnLog.FileTxnIterator
java.lang.Object
org.apache.zookeeper.server.persistence.FileTxnLog.FileTxnIterator
- All Implemented Interfaces:
Closeable,AutoCloseable,TxnLog.TxnIterator
- Enclosing class:
- FileTxnLog
this class implements the txnlog iterator interface
which is used for reading the transaction logs
-
Constructor Summary
ConstructorsConstructorDescriptionFileTxnIterator(File logDir, long zxid) create an iterator over a transaction database directoryFileTxnIterator(File logDir, long zxid, boolean fastForward) create an iterator over a transaction database directory -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()close the iterator and release the resources.protected InputArchivecreateInputArchive(File logFile) Invoked to indicate that the input stream has been created.return the current headerlongReturn total storage size of txnlog that will return by this iterator.getTxn()return the current transactionprotected voidinStreamCreated(InputArchive ia, InputStream is) read the header from the inputarchiveprotected Checksumcreate a checksum algorithmbooleannext()the iterator that moves to the next transaction
-
Constructor Details
-
FileTxnIterator
create an iterator over a transaction database directory- Parameters:
logDir- the transaction database directoryzxid- the zxid to start reading fromfastForward- 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 zxid- Throws:
IOException
-
FileTxnIterator
create an iterator over a transaction database directory- Parameters:
logDir- the transaction database directoryzxid- the zxid to start reading from- Throws:
IOException
-
-
Method Details
-
getStorageSize
public long getStorageSize()Return total storage size of txnlog that will return by this iterator.- Specified by:
getStorageSizein interfaceTxnLog.TxnIterator
-
inStreamCreated
read the header from the inputarchive- Parameters:
ia- the inputarchive to be read fromis- the inputstream- Throws:
IOException
-
createInputArchive
Invoked to indicate that the input stream has been created.- Parameters:
logFile- the file to read.- Throws:
IOException
-
makeChecksumAlgorithm
create a checksum algorithm- Returns:
- the checksum algorithm
-
next
the iterator that moves to the next transaction- Specified by:
nextin interfaceTxnLog.TxnIterator- Returns:
- true if there is more transactions to be read false if not.
- Throws:
IOException
-
getHeader
return the current header- Specified by:
getHeaderin interfaceTxnLog.TxnIterator- Returns:
- the current header that is read
-
getTxn
return the current transaction- Specified by:
getTxnin interfaceTxnLog.TxnIterator- Returns:
- the current transaction that is read
-
getDigest
- Specified by:
getDigestin interfaceTxnLog.TxnIterator- Returns:
- the digest associated with the transaction.
-
close
close the iterator and release the resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceTxnLog.TxnIterator- Throws:
IOException
-