@Override public synchronized void seek(long newpos) throws IOException { if (newpos < 0) { throw new EOFException( FSExceptionMessages.NEGATIVE_SEEK); } if (pos != newpos) { // the seek is attempting to move the current position reopen(newpos); } }
@Override public synchronized int read() throws IOException { int result; try { result = in.read(); } catch (IOException e) { LOG.info("Received IOException while reading '{}', attempting to reopen", key); LOG.debug("{}", e, e); try { reopen(pos); result = in.read(); } catch (EOFException eof) { LOG.debug("EOF on input stream read: {}", eof, eof); result = -1; } } if (result != -1) { pos++; } if (statistics != null && result != -1) { statistics.incrementBytesRead(1); } return result; } @Override
@Override public synchronized int read(byte[] b, int off, int len) throws IOException { if (in == null) { throw new EOFException("Cannot read closed stream"); } int result = -1; try { result = in.read(b, off, len); } catch (EOFException eof) { throw eof; } catch (IOException e) { LOG.info( "Received IOException while reading '{}'," + " attempting to reopen.", key); reopen(pos); result = in.read(b, off, len); } if (result > 0) { pos += result; } if (statistics != null && result > 0) { statistics.incrementBytesRead(result); } return result; }