use of org.apache.zookeeper_voltpatches.server.persistence.FileTxnLog in project voltdb by VoltDB.
the class FileTxnLog method getLastLoggedZxid.
/**
* get the last zxid that was logged in the transaction logs
* @return the last zxid logged in the transaction logs
*/
public long getLastLoggedZxid() {
File[] files = getLogFiles(logDir.listFiles(), 0);
long maxLog = files.length > 0 ? Util.getZxidFromName(files[files.length - 1].getName(), "log") : -1;
// if a log file is more recent we must scan it to find
// the highest zxid
long zxid = maxLog;
try {
FileTxnLog txn = new FileTxnLog(logDir);
TxnIterator itr = txn.read(maxLog);
while (true) {
if (!itr.next())
break;
TxnHeader hdr = itr.getHeader();
zxid = hdr.getZxid();
}
} catch (IOException e) {
LOG.warn("Unexpected exception", e);
}
return zxid;
}
Aggregations