fStream = log.getInputStream(); bin = new BufferedInputStream(fStream); tracker = new FSEditLogLoader.PositionTrackingInputStream(bin); dataIn = new DataInputStream(tracker); try {
long skipAmt = log.length() - tracker.getPos(); if (skipAmt > 0) { if (LOG.isDebugEnabled()) { " out of " + lastTxId); tracker.clearLimit(); IOUtils.skipFully(tracker, skipAmt);
@Override public int read(byte[] data, int offset, int length) throws IOException { checkLimit(length); int ret = super.read(data, offset, length); if (ret > 0) curPos += ret; return ret; }
long skipAmt = log.length() - tracker.getPos(); if (skipAmt > 0) { if (LOG.isDebugEnabled()) { " out of " + lastTxId); tracker.clearLimit(); IOUtils.skipFully(tracker, skipAmt);
long skipAmt = log.length() - tracker.getPos(); if (skipAmt > 0) { if (LOG.isDebugEnabled()) { " out of " + lastTxId); tracker.clearLimit(); IOUtils.skipFully(tracker, skipAmt);
BufferedInputStream bin = new BufferedInputStream(fin); FSEditLogLoader.PositionTrackingInputStream tracker = new FSEditLogLoader.PositionTrackingInputStream(bin); try { tracker.setLimit(2); tracker.mark(100); tracker.read(); tracker.read(); try { tracker.read(); fail("expected to get IOException after reading past the limit"); } catch (IOException e) { tracker.reset(); tracker.mark(100); byte arr[] = new byte[3]; try { tracker.read(arr); fail("expected to get IOException after reading past the limit"); } catch (IOException e) { tracker.reset(); arr = new byte[2]; tracker.read(arr); } finally { tracker.close();
fStream = log.getInputStream(); bin = new BufferedInputStream(fStream); tracker = new FSEditLogLoader.PositionTrackingInputStream(bin); dataIn = new DataInputStream(tracker); try {
fStream = log.getInputStream(); bin = new BufferedInputStream(fStream); tracker = new FSEditLogLoader.PositionTrackingInputStream(bin); dataIn = new DataInputStream(tracker); try {
/** * 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; }
/** * Process image file. */ public void go() throws IOException { DataInputStream in = null; PositionTrackingInputStream tracker = null; ImageLoader fsip = null; boolean done = false; try { tracker = new PositionTrackingInputStream(new BufferedInputStream( new FileInputStream(new File(inputFile)))); in = new DataInputStream(tracker); int imageVersionFile = findImageVersion(in); fsip = ImageLoader.LoaderFactory.getLoader(imageVersionFile); if(fsip == null) throw new IOException("No image processor to read version " + imageVersionFile + " is available."); fsip.loadImage(in, processor, skipBlocks); done = true; } finally { if (!done) { LOG.error("image loading failed at offset " + tracker.getPos()); } IOUtils.cleanup(LOG, in, tracker); } }
/** * Process image file. */ public void go() throws IOException { DataInputStream in = null; PositionTrackingInputStream tracker = null; ImageLoader fsip = null; boolean done = false; try { tracker = new PositionTrackingInputStream(new BufferedInputStream( new FileInputStream(new File(inputFile)))); in = new DataInputStream(tracker); int imageVersionFile = findImageVersion(in); fsip = ImageLoader.LoaderFactory.getLoader(imageVersionFile); if(fsip == null) throw new IOException("No image processor to read version " + imageVersionFile + " is available."); fsip.loadImage(in, processor, skipBlocks); done = true; } finally { if (!done) { LOG.error("image loading failed at offset " + tracker.getPos()); } IOUtils.cleanup(LOG, in, tracker); } }
@Override public long getPosition() { return tracker.getPos(); }
@Override public long getPosition() { return tracker.getPos(); }
@Override public long getPosition() { return tracker.getPos(); }
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 long getPosition() { if (state == State.OPEN) { return tracker.getPos(); } else { return 0; } }
@Override public int read(byte[] data) throws IOException { checkLimit(data.length); int ret = super.read(data); if (ret > 0) curPos += ret; return ret; }
@Override public int read(byte[] data, int offset, int length) throws IOException { checkLimit(length); int ret = super.read(data, offset, length); if (ret > 0) curPos += ret; return ret; }
@Override public long getPosition() throws IOException{ return tracker.getPos(); }
@Override public int read(byte[] data) throws IOException { checkLimit(data.length); int ret = super.read(data); if (ret > 0) curPos += ret; return ret; }