FSDataOutputStreamWrapper newFSDataOutputStreamWrapper(FSDataOutputStream os) throws IOException { try { return (operatorStats != null) ? new FSDataOutputStreamWithStatsWrapper(os, operatorStats) : new FSDataOutputStreamWrapper(os); } catch(FSError e) { throw propagateFSError(e); } }
@Override public void close() throws IOException { operatorStats.startWait(); try { super.close(); } finally { operatorStats.stopWait(); } }
@Override public void flush() throws IOException { operatorStats.startWait(); try { super.flush(); } finally { operatorStats.stopWait(); } }
@Override public void write(byte[] b) throws IOException { operatorStats.startWait(); try { super.write(b); } finally { operatorStats.stopWait(); } }
@Override @Deprecated public void sync() throws IOException { operatorStats.startWait(); try { super.sync(); } finally { operatorStats.stopWait(); } }
@Override public void setDropBehind(Boolean dropBehind) throws IOException { operatorStats.startWait(); try { super.setDropBehind(dropBehind); } finally { operatorStats.stopWait(); } } }
@Override public void hflush() throws IOException { operatorStats.startWait(); try { super.hflush(); } finally { operatorStats.stopWait(); } }
@Override public void hsync() throws IOException { operatorStats.startWait(); try { super.hsync(); } finally { operatorStats.stopWait(); } }
@Override public void write(byte[] b, int off, int len) throws IOException { operatorStats.startWait(); try { super.write(b, off, len); } finally { operatorStats.stopWait(); } }
@Test public void test() throws Exception { assumeNonMaprProfile(); final IOException ioException = new IOException("test io exception"); final FSError fsError = newFSError(ioException); FSDataOutputStream fdos = mock(FSDataOutputStream.class, new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { throw fsError; } }); FSDataOutputStreamWrapper fdosw = new FSDataOutputStreamWrapper(fdos); Object[] params = getDummyArguments(method); try { method.invoke(fdosw, params); } catch(InvocationTargetException e) { assertThat(e.getTargetException(), is(instanceOf(IOException.class))); assertThat((IOException) e.getTargetException(), is(sameInstance(ioException))); } } }
@Override public void write(int b) throws IOException { operatorStats.startWait(); try { super.write(b); } finally { operatorStats.stopWait(); } }