@Override public void close() throws IOException { fileClosed(is); super.close(); } };
@Override public int read(long position, byte[] buffer, int offset, int length) throws IOException { operatorStats.startWait(); try { return super.read(position, buffer, offset, length); } finally { operatorStats.stopWait(); } }
@Override public void readFully(long position, byte[] buffer, int offset, int length) throws IOException { operatorStats.startWait(); try { super.readFully(position, buffer, offset, length); } finally { operatorStats.stopWait(); } }
FSDataInputStreamWrapper newFSDataInputStreamWrapper(Path f, final FSDataInputStream is) throws IOException { try { FSDataInputStreamWrapper result = (operatorStats != null) ? new FSDataInputStreamWithStatsWrapper(is, operatorStats) : new FSDataInputStreamWrapper(is); if (TRACKING_ENABLED) { result = new FSDataInputStreamWrapper(result) { @Override public void close() throws IOException { fileClosed(is); super.close(); } }; fileOpened(f, is); } return result; } catch(FSError e) { throw propagateFSError(e); } }
@Override public long skip(long n) throws IOException { operatorStats.startWait(); try { return super.skip(n); } finally { operatorStats.stopWait(); } }
@Override public synchronized void seek(long desired) throws IOException { operatorStats.startWait(); try { super.seek(desired); } finally { operatorStats.stopWait(); } }
@Test public void test() throws Exception { assumeNonMaprProfile(); final IOException ioException = new IOException("test io exception"); final FSError fsError = newFSError(ioException); FSDataInputStream fdis = mock(FSDataInputStream.class, new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { throw fsError; } }); FSDataInputStreamWrapper fdisw = new FSDataInputStreamWrapper(fdis); Object[] params = getDummyArguments(method); try { method.invoke(fdisw, params); } catch(InvocationTargetException e) { assertThat(e.getTargetException(), is(instanceOf(IOException.class))); assertThat((IOException) e.getTargetException(), is(sameInstance(ioException))); } } }
@Override public void readFully(long position, byte[] buffer) throws IOException { operatorStats.startWait(); try { super.readFully(position, buffer); } finally { operatorStats.stopWait(); } }
@Override public ByteBuffer read(ByteBufferPool bufferPool, int maxLength, EnumSet<ReadOption> opts) throws IOException, UnsupportedOperationException { operatorStats.startWait(); try { return super.read(bufferPool, maxLength, opts); } finally { operatorStats.stopWait(); } }