- Common ways to obtain FSEditLogOp$Reader
private void myMethod () {FSEditLogOp$Reader f =
DataInputStream in;StreamLimiter limiter;new FSEditLogOp.Reader(in, limiter, logVersion)
- Smart code suggestions by Codota
}
return nextOpImpl(skipBrokenEdits); case OPEN: op = reader.readOp(skipBrokenEdits); if ((op != null) && (op.hasTransactionId())) { long txId = op.getTransactionId();
reader = FSEditLogOp.Reader.create(dataIn, tracker, logVersion); reader.setMaxOpSize(maxOpSize); state = State.OPEN; } finally {
while (true) { try { return decodeOp(); } catch (IOException e) { in.reset();
@Override protected long scanNextOp() throws IOException { Preconditions.checkState(state == State.OPEN); FSEditLogOp cachedNext = getCachedOp(); return cachedNext == null ? reader.scanOp() : cachedNext.txid; }
@Override protected long scanNextOp() throws IOException { Preconditions.checkState(state == State.OPEN); FSEditLogOp cachedNext = getCachedOp(); return cachedNext == null ? reader.scanOp() : cachedNext.txid; }
void setBytes(byte[] newBytes, int version) throws IOException { inner.setData(newBytes); tracker = new FSEditLogLoader.PositionTrackingInputStream(inner); in = new DataInputStream(tracker); this.version = version; reader = new FSEditLogOp.Reader(in, tracker, version); }
@Override public void setMaxOpSize(int maxOpSize) { reader.setMaxOpSize(maxOpSize); }
@Override public void setMaxOpSize(int maxOpSize) { this.maxOpSize = maxOpSize; if (reader != null) { reader.setMaxOpSize(maxOpSize); } }
@Override protected FSEditLogOp nextValidOp() { try { return reader.readOp(true); } catch (IOException e) { throw new RuntimeException("got unexpected IOException " + e, e); } }
@Override protected long scanNextOp() throws IOException { Preconditions.checkState(state == State.OPEN); FSEditLogOp cachedNext = getCachedOp(); return cachedNext == null ? reader.scanOp() : cachedNext.txid; }
@Override protected FSEditLogOp nextOp() throws IOException { Preconditions.checkState(reader != null, "Must call setBytes() before readOp()"); return reader.readOp(false); }
@Override public void setMaxOpSize(int maxOpSize) { reader.setMaxOpSize(maxOpSize); }
@Override protected FSEditLogOp nextOp() throws IOException { return reader.readOp(false); }
@Override public void setMaxOpSize(int maxOpSize) { reader.setMaxOpSize(maxOpSize); }
@Override protected FSEditLogOp nextOp() throws IOException { Preconditions.checkState(reader != null, "Must call setBytes() before readOp()"); return reader.readOp(false); }
@Override public FSEditLogOp readOp() throws IOException { return reader.readOp(); }
@Override public void refresh(long position) throws IOException { fc.position(position); BufferedInputStream bin = new BufferedInputStream(fStream); tracker = new FSEditLogLoader.PositionTrackingInputStream(bin, position); DataInputStream in = new DataInputStream(tracker); reader = new FSEditLogOp.Reader(in, logVersion); }
/** * Open an EditLogInputStream for the given file. * @param name filename to open * @param firstTxId first transaction found in file * @param lastTxId last transaction id found in file * @throws LogHeaderCorruptException if the header is either missing or * appears to be corrupt/truncated * @throws IOException if an actual IO error occurs while reading the * header */ EditLogFileInputStream(File name, long firstTxId, long lastTxId) throws LogHeaderCorruptException, IOException { file = name; rp = new RandomAccessFile(file, "r"); fStream = new FileInputStream(rp.getFD()); fc = rp.getChannel(); BufferedInputStream bin = new BufferedInputStream(fStream); tracker = new FSEditLogLoader.PositionTrackingInputStream(bin); DataInputStream in = new DataInputStream(tracker); try { logVersion = readLogVersion(in); } catch (EOFException eofe) { throw new LogHeaderCorruptException("No header found in log"); } reader = new FSEditLogOp.Reader(in, logVersion); this.firstTxId = firstTxId; this.lastTxId = lastTxId; }
@Override public void setMaxOpSize(int maxOpSize) { this.maxOpSize = maxOpSize; if (reader != null) { reader.setMaxOpSize(maxOpSize); } }
verifyTerminator(); return HdfsConstants.INVALID_TXID; FSEditLogOp op = decodeOp(); return op == null ? HdfsConstants.INVALID_TXID : op.getTransactionId();