horizonzy commented on code in PR #2024:
URL: https://github.com/apache/zookeeper/pull/2024#discussion_r1256977998


##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/persistence/FileTxnLog.java:
##########
@@ -289,22 +297,25 @@ public synchronized boolean append(TxnHeader hdr, Record 
txn, TxnDigest digest)
             logStream = new BufferedOutputStream(fos);
             oa = BinaryOutputArchive.getArchive(logStream);
             FileHeader fhdr = new FileHeader(TXNLOG_MAGIC, VERSION, dbId);
+            long dataSize = oa.getDataSize();
             fhdr.serialize(oa, "fileheader");
             // Make sure that the magic number is written before padding.
             logStream.flush();
-            filePadding.setCurrentSize(fos.getChannel().position());
+            filePosition += oa.getDataSize() - dataSize;

Review Comment:
   FilePosition: The position of the file which has been already flushed to 
file.
   
   In this case, we initial the OutputArchive, and write the file header to it, 
then invoke `logStream.flush()`. 
   Before writing the header, we record the dataSize, after writing the header, 
we use current dataSize minus the before dataSize, get the position.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to