@Test public void normalReads() throws IOException { when(inputStream.read()).thenReturn(generateRandomByte()); when(objectStorage.getObject(any(GetObjectRequest.class))) .thenReturn(GetObjectResponse.builder().inputStream(inputStream).build()); BmcDirectFSInputStream directFSInputStream = new BmcDirectFSInputStream( objectStorage, fileStatus, getObjectRequestBuilderSupplier, statistics); for (int i = 0; i < READ_COUNT; i++) { directFSInputStream.read(); } verify(objectStorage, times(1)).getObject(any(GetObjectRequest.class)); verify(inputStream, times(READ_COUNT)).read(); }
@Override public int read() throws IOException { try { return super.read(); } catch (IOException e) { LOG.warn("Read failed, possibly a stale connection. Will re-attempt.", e); FSStreamUtils.closeQuietly(super.getSourceInputStream()); super.setSourceInputStream(null); return super.read(); } }
BmcDirectFSInputStream extends BmcFSInputStream { @Override public int read() throws IOException { try { return super.read(); } catch (IOException e) { LOG.warn("Read failed, possibly a stale connection. Will re-attempt.", e); FSStreamUtils.closeQuietly(super.getSourceInputStream()); super.setSourceInputStream(null); return super.read(); } } }
BmcDirectFSInputStream extends BmcFSInputStream { @Override public int read() throws IOException { try { return super.read(); } catch (IOException e) { LOG.warn("Read failed, possibly a stale connection. Will re-attempt.", e); FSStreamUtils.closeQuietly(super.getSourceInputStream()); super.setSourceInputStream(null); return super.read(); } } BmcDirectFSInputStream(
            final ObjectStorage objectStorage,
            final FileStatus status,
            final Supplier<GetObjectRequest.Builder> requestBuilder,
            final Statistics statistics); }
BmcDirectFSInputStream extends BmcFSInputStream { @Override public int read() throws IOException { try { return super.read(); } catch (IOException e) { LOG.warn("Read failed, possibly a stale connection. Will re-attempt.", e); FSStreamUtils.closeQuietly(super.getSourceInputStream()); super.setSourceInputStream(null); return super.read(); } } BmcDirectFSInputStream(
            final ObjectStorage objectStorage,
            final FileStatus status,
            final Supplier<GetObjectRequest.Builder> requestBuilder,
            final Statistics statistics); @Override int read(); @Override int read(final byte[] b, final int off, final int len); }
BmcDirectFSInputStream extends BmcFSInputStream { @Override public int read() throws IOException { try { return super.read(); } catch (IOException e) { LOG.warn("Read failed, possibly a stale connection. Will re-attempt.", e); FSStreamUtils.closeQuietly(super.getSourceInputStream()); super.setSourceInputStream(null); return super.read(); } } BmcDirectFSInputStream(
            final ObjectStorage objectStorage,
            final FileStatus status,
            final Supplier<GetObjectRequest.Builder> requestBuilder,
            final Statistics statistics); @Override int read(); @Override int read(final byte[] b, final int off, final int len);  }