@Override public void close() throws IOException { if (!closed) { closed = true; registry.unregisterCloseable(this); inputStream.close(); } }
@Override public int available() throws IOException { try { return originalStream.available(); } catch (IOException e) { handleIOException(e); return 0; // silence the compiler } }
@Override public long skip(long n) throws IOException { try { return originalStream.skip(n); } catch (IOException e) { handleIOException(e); return 0L; // silence the compiler } }
private static void deleteIfExists(Path path) throws IOException { FileSystem fs = path.getFileSystem(); if (fs.exists(path)) { fs.delete(path, true); } }
@Override public void go() throws Exception { fs.initOutPathLocalFS(path.getParent(), WriteMode.OVERWRITE, true); try (FSDataOutputStream out = fs.create(path, WriteMode.OVERWRITE)) { out.write(11); } } }
@Override public int read(byte[] b) throws IOException { try { return originalStream.read(b); } catch (IOException e) { handleIOException(e); return 0; // silence the compiler } }
@Override public void seek(long desired) throws IOException { try { originalStream.seek(desired); } catch (IOException e) { handleIOException(e); } }
@Override public void write(byte[] b, int off, int len) throws IOException { try { originalStream.write(b, off, len); } catch (IOException e) { handleIOException(e); } }
@Override public void close() throws IOException { if (!closed) { closed = true; registry.unregisterCloseable(this); outputStream.close(); } }
@Override public void flush() throws IOException { try { originalStream.flush(); } catch (IOException e) { handleIOException(e); } }
@Override public void sync() throws IOException { try { originalStream.sync(); } catch (IOException e) { handleIOException(e); } }
@Override public void reset() throws IOException { try { originalStream.reset(); } catch (IOException e) { handleIOException(e); } }
@Override public FileSystem create(URI fsUri) throws IOException { FileSystem original = factory.create(fsUri); return new LimitedConnectionsFileSystem(original, settings.limitTotal, settings.limitOutput, settings.limitInput, settings.streamOpenTimeout, settings.streamInactivityTimeout); }
@Override public void closeDueToTimeout() throws IOException { this.timeoutException = new StreamTimeoutException(); close(); }
public static ClosingFSDataOutputStream wrapSafe( FSDataOutputStream delegate, SafetyNetCloseableRegistry registry, String debugInfo) throws IOException { ClosingFSDataOutputStream inputStream = new ClosingFSDataOutputStream(delegate, registry, debugInfo); registry.registerCloseable(inputStream); return inputStream; } }
public static ClosingFSDataInputStream wrapSafe( FSDataInputStream delegate, SafetyNetCloseableRegistry registry, String debugInfo) throws IOException{ ClosingFSDataInputStream inputStream = new ClosingFSDataInputStream(delegate, registry, debugInfo); registry.registerCloseable(inputStream); return inputStream; } }
@Override public void closeDueToTimeout() throws IOException { this.timeoutException = new StreamTimeoutException(); close(); }
@Override public int read(byte[] b, int off, int len) throws IOException { try { return originalStream.read(b, off, len); } catch (IOException e) { handleIOException(e); return 0; // silence the compiler } }
@Override public int read() throws IOException { try { return originalStream.read(); } catch (IOException e) { handleIOException(e); return 0; // silence the compiler } }