/** * the last logged zxid on the transaction logs * @return the last logged zxid */ public long getLastLoggedZxid() { FileTxnLog txnLog = new FileTxnLog(dataDir); return txnLog.getLastLoggedZxid(); }
public TxnLogProposalIterator(TxnIterator itr) { if (itr != null) { this.itr = itr; hasNext = (itr.getHeader() != null); } }
/** * the dbid of this transaction database * @return the dbid of this database */ public long getDbId() throws IOException { FileTxnIterator itr = new FileTxnIterator(logDir, 0); FileHeader fh=readHeader(itr.logFile); itr.close(); if(fh==null) throw new IOException("Unsupported Format."); return fh.getDbid(); }
/** * the n most recent snapshots * @param n the number of recent snapshots * @return the list of n most recent snapshots, with * the most recent in front * @throws IOException */ public List<File> findNRecentSnapshots(int n) throws IOException { FileSnap snaplog = new FileSnap(snapDir); return snaplog.findNRecentSnapshots(n); }
/** * the most recent snapshot in the snapshot * directory * @return the file that contains the most * recent snapshot * @throws IOException */ public File findMostRecentSnapshot() throws IOException { FileSnap snaplog = new FileSnap(snapDir); return snaplog.findMostRecentSnapshot(); }
/** * append to the underlying transaction log * @param si the request to append * @return true if the append was succesfull and false if not */ public boolean append(Request si) throws IOException { return this.snapLog.append(si); }
/** * commit to the underlying transaction log * @throws IOException */ public void commit() throws IOException { this.snapLog.commit(); }
/** * start reading all the transactions from the given zxid * @param zxid the zxid to start reading transactions from * @return returns an iterator to iterate through the transaction * logs */ public TxnIterator read(long zxid) throws IOException { return read(zxid, true); }
/** * start reading all the transactions from the given zxid. * * @param zxid the zxid to start reading transactions from * @param fastForward 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 * @return returns an iterator to iterate through the transaction logs */ public TxnIterator read(long zxid, boolean fastForward) throws IOException { return new FileTxnIterator(logDir, zxid, fastForward); }
/** * roll the underlying log */ public void rollLog() throws IOException { this.snapLog.rollLog(); }
/** * roll the transaction logs * @throws IOException */ public void rollLog() throws IOException { txnLog.rollLog(); }
/** * close the iterator * and release the resources. */ public void close() throws IOException { if (inputStream != null) { inputStream.close(); } } }
/** * commit the transaction of logs * @throws IOException */ public void commit() throws IOException { txnLog.commit(); }
private void singleDirSetupWithCorrectFiles() throws IOException { logVersionDir = createVersionDir(logDir); // transaction log and snapshot files in the same dir createLogFile(logVersionDir,1); createLogFile(logVersionDir,2); createSnapshotFile(logVersionDir,1); createSnapshotFile(logVersionDir,2); }
/** * Returns the elapsed sync of time of transaction log in milliseconds. */ public long getTxnLogElapsedSyncTime() { return txnLogFactory.getTxnLogElapsedSyncTime(); }
@Override public boolean accept(File dir, String name) { return Util.isLogFileName(name); } });
/** * Fast forward the database adding transactions from the committed log into memory. * @return the last valid zxid. * @throws IOException */ public long fastForwardDataBase() throws IOException { long zxid = snapLog.fastForwardFromEdits(dataTree, sessionsWithTimeouts, commitProposalPlaybackListener); initialized = true; return zxid; }
@Override public boolean accept(File dir, String name) { return Util.isSnapshotFileName(name); } });
/** * * @return elapsed sync time of transaction log commit in milliseconds */ public long getTxnLogElapsedSyncTime() { return txnLog.getTxnLogSyncElapsedTime(); }