/** * 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(); }
/** * 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 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(); }
public void run(String snapshotFileName) throws IOException { InputStream is = new CheckedInputStream( new BufferedInputStream(new FileInputStream(snapshotFileName)), new Adler32()); InputArchive ia = BinaryInputArchive.getArchive(is); FileSnap fileSnap = new FileSnap(null); DataTree dataTree = new DataTree(); Map<Long, Integer> sessions = new HashMap<Long, Integer>(); fileSnap.deserialize(dataTree, sessions, ia); printDetails(dataTree, sessions); }
public void run(String snapshotFileName, boolean dumpData, boolean dumpJson) throws IOException { File snapshotFile = new File(snapshotFileName); try (InputStream is = new CheckedInputStream( new BufferedInputStream(new FileInputStream(snapshotFileName)), new Adler32())) { InputArchive ia = BinaryInputArchive.getArchive(is); FileSnap fileSnap = new FileSnap(null); DataTree dataTree = new DataTree(); Map<Long, Integer> sessions = new HashMap<Long, Integer>(); fileSnap.deserialize(dataTree, sessions, ia); long fileNameZxid = Util.getZxidFromName(snapshotFile.getName(), SNAPSHOT_FILE_PREFIX); if (dumpJson) { printSnapshotJson(dataTree); } else { printDetails(dataTree, sessions, dumpData, fileNameZxid); } } }
snapLog = new FileSnap(this.snapDir);
snapLog = new FileSnap(this.snapDir);
/** * truncate the transaction logs the zxid * specified * @param zxid the zxid to truncate the logs to * @return true if able to truncate the log, false if not * @throws IOException */ public boolean truncateLog(long zxid) throws IOException { // close the existing txnLog and snapLog close(); // truncate it FileTxnLog truncLog = new FileTxnLog(dataDir); boolean truncated = truncLog.truncate(zxid); truncLog.close(); // re-open the txnLog and snapLog // I'd rather just close/reopen this object itself, however that // would have a big impact outside ZKDatabase as there are other // objects holding a reference to this object. txnLog = new FileTxnLog(dataDir); snapLog = new FileSnap(snapDir); return truncated; }
/** * truncate the transaction logs the zxid * specified * @param zxid the zxid to truncate the logs to * @return true if able to truncate the log, false if not * @throws IOException */ public boolean truncateLog(long zxid) throws IOException { // close the existing txnLog and snapLog close(); // truncate it FileTxnLog truncLog = new FileTxnLog(dataDir); boolean truncated = truncLog.truncate(zxid); truncLog.close(); // re-open the txnLog and snapLog // I'd rather just close/reopen this object itself, however that // would have a big impact outside ZKDatabase as there are other // objects holding a reference to this object. txnLog = new FileTxnLog(dataDir); snapLog = new FileSnap(snapDir); return truncated; }
((FileSnap) snapLog.snapLog).findNRecentSnapshots(10).size()); snapLog.snapLog = new FileSnap(snapLog.dataDir); snapLog.save(tree, new ConcurrentHashMap<Long, Integer>(), false); Assert.assertEquals(1,
FileSnap snap = new FileSnap(versionDir); List<File> snapFiles = snap.findNRecentSnapshots(2); snapFile = snapFiles.get(0);
/** * 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(); }
/** * 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 constructor which takes the datadir and * snapdir. * @param dataDir the trasaction directory * @param snapDir the snapshot directory */ public FileTxnSnapLog(File dataDir, File snapDir) throws IOException { this.dataDir = new File(dataDir, version + VERSION); this.snapDir = new File(snapDir, version + VERSION); if (!this.dataDir.exists()) { if (!this.dataDir.mkdirs()) { throw new IOException("Unable to create data directory " + this.dataDir); } } if (!this.snapDir.exists()) { if (!this.snapDir.mkdirs()) { throw new IOException("Unable to create snap directory " + this.snapDir); } } txnLog = new FileTxnLog(this.dataDir); snapLog = new FileSnap(this.snapDir); }