/** * Invoked to indicate that the input stream has been created. * @param ia input archive * @param is file input stream associated with the input archive. * @throws IOException **/ protected InputArchive createInputArchive(File logFile) throws IOException { if(inputStream==null){ inputStream= new PositionInputStream(new BufferedInputStream(new FileInputStream(logFile))); LOG.debug("Created new input stream " + logFile); ia = BinaryInputArchive.getArchive(inputStream); inStreamCreated(ia,inputStream); LOG.debug("Created new input archive " + logFile); } return ia; }
/** * truncate the current transaction logs * @param zxid the zxid to truncate the logs to * @return true if successful false if not */ public boolean truncate(long zxid) throws IOException { FileTxnIterator itr = null; try { itr = new FileTxnIterator(this.logDir, zxid); PositionInputStream input = itr.inputStream; if(input == null) { throw new IOException("No log files found to truncate! This could " + "happen if you still have snapshots from an old setup or " + "log files were deleted accidentally or dataLogDir was changed in zoo.cfg."); } long pos = input.getPosition(); // now, truncate at the current position RandomAccessFile raf = new RandomAccessFile(itr.logFile, "rw"); raf.setLength(pos); raf.close(); while (itr.goToNextLog()) { if (!itr.logFile.delete()) { LOG.warn("Unable to truncate {}", itr.logFile); } } } finally { close(itr); } return true; }
} catch (EOFException e) { LOG.debug("EOF excepton " + e); inputStream.close(); inputStream = null; ia = null;
/** * truncate the current transaction logs * @param zxid the zxid to truncate the logs to * @return true if successful false if not */ public boolean truncate(long zxid) throws IOException { FileTxnIterator itr = new FileTxnIterator(this.logDir, zxid); PositionInputStream input = itr.inputStream; long pos = input.getPosition(); // now, truncate at the current position RandomAccessFile raf=new RandomAccessFile(itr.logFile,"rw"); raf.setLength(pos); raf.close(); while(itr.goToNextLog()) { if (!itr.logFile.delete()) { LOG.warn("Unable to truncate " + itr.logFile); } } return true; }
/** * Invoked to indicate that the input stream has been created. * @param ia input archive * @param is file input stream associated with the input archive. * @throws IOException **/ protected InputArchive createInputArchive(File logFile) throws IOException { if(inputStream==null){ inputStream= new PositionInputStream(new BufferedInputStream(new FileInputStream(logFile))); LOG.debug("Created new input stream " + logFile); ia = BinaryInputArchive.getArchive(inputStream); inStreamCreated(ia,inputStream); LOG.debug("Created new input archive " + logFile); } return ia; }
/** * close the iterator * and release the resources. */ public void close() throws IOException { inputStream.close(); } }
/** * truncate the current transaction logs * @param zxid the zxid to truncate the logs to * @return true if successful false if not */ public boolean truncate(long zxid) throws IOException { FileTxnIterator itr = null; try { itr = new FileTxnIterator(this.logDir, zxid); PositionInputStream input = itr.inputStream; if(input == null) { throw new IOException("No log files found to truncate! This could " + "happen if you still have snapshots from an old setup or " + "log files were deleted accidentally or dataLogDir was changed in zoo.cfg."); } long pos = input.getPosition(); // now, truncate at the current position RandomAccessFile raf=new RandomAccessFile(itr.logFile,"rw"); raf.setLength(pos); raf.close(); while(itr.goToNextLog()) { if (!itr.logFile.delete()) { LOG.warn("Unable to truncate {}", itr.logFile); } } } finally { close(itr); } return true; }
/** * close the iterator * and release the resources. */ public void close() throws IOException { if (inputStream != null) { inputStream.close(); } } }
/** * Invoked to indicate that the input stream has been created. * @param ia input archive * @param is file input stream associated with the input archive. * @throws IOException **/ protected InputArchive createInputArchive(File logFile) throws IOException { if(inputStream==null){ inputStream= new PositionInputStream(new BufferedInputStream(new FileInputStream(logFile))); LOG.debug("Created new input stream " + logFile); ia = BinaryInputArchive.getArchive(inputStream); inStreamCreated(ia,inputStream); LOG.debug("Created new input archive " + logFile); } return ia; }
/** * close the iterator * and release the resources. */ public void close() throws IOException { if (inputStream != null) { inputStream.close(); } } }