@Override public void close() throws IOException { final FSDataOutputStream s = this.stream; if (s != null) { this.stream = null; s.close(); } }
@Override public void close() throws IOException { outputStream.close(); }
@Override public void close() throws IOException { if (!closed) { closed = true; registry.unregisterCloseable(this); outputStream.close(); } }
@Override public void close() throws IOException { if (closed.compareAndSet(false, true)) { try { originalStream.close(); } catch (IOException e) { handleIOException(e); } finally { fs.unregisterOutputStream(this); } } }
@Test public void testDelegateOutStreamMethods() throws IOException { // mock the output stream final FSDataOutputStream mockOut = mock(FSDataOutputStream.class); final long outPos = 46651L; when(mockOut.getPos()).thenReturn(outPos); final FileSystem fs = mock(FileSystem.class); when(fs.create(any(Path.class), any(WriteMode.class))).thenReturn(mockOut); final LimitedConnectionsFileSystem lfs = new LimitedConnectionsFileSystem(fs, 100); final FSDataOutputStream out = lfs.create(mock(Path.class), WriteMode.OVERWRITE); // validate the output stream out.write(77); verify(mockOut).write(77); { byte[] bytes = new byte[1786]; out.write(bytes, 100, 111); verify(mockOut).write(bytes, 100, 111); } assertEquals(outPos, out.getPos()); out.flush(); verify(mockOut).flush(); out.sync(); verify(mockOut).sync(); out.close(); verify(mockOut).close(); }
@Test public void testCreateEntropyAwarePlainFs() throws Exception { File folder = TMP_FOLDER.newFolder(); Path path = new Path(Path.fromLocalFile(folder), "_entropy_/file"); OutputStreamAndPath out = EntropyInjector.createEntropyAware( LocalFileSystem.getSharedInstance(), path, WriteMode.NO_OVERWRITE); out.stream().close(); assertEquals(path, out.path()); assertTrue(new File (new File(folder, "_entropy_"), "file").exists()); }
@Test public void testCreateEntropyAwareEntropyFs() throws Exception { File folder = TMP_FOLDER.newFolder(); Path path = new Path(Path.fromLocalFile(folder), "_entropy_/file"); Path pathWithEntropy = new Path(Path.fromLocalFile(folder), "test-entropy/file"); FileSystem fs = new TestEntropyInjectingFs("_entropy_", "test-entropy"); OutputStreamAndPath out = EntropyInjector.createEntropyAware(fs, path, WriteMode.NO_OVERWRITE); out.stream().close(); assertEquals(new Path(Path.fromLocalFile(folder), "test-entropy/file"), out.path()); assertTrue(new File (new File(folder, "test-entropy"), "file").exists()); }
outputStream.close();
lfsoutput1.close();
@Override public void close() throws IOException { final FSDataOutputStream s = this.stream; if (s != null) { this.stream = null; s.close(); } }
@Override public void close() throws IOException { final FSDataOutputStream s = this.stream; if (s != null) { this.stream = null; s.close(); } }
@Override public void close() throws IOException { outputStream.close(); }
@Override public void close() throws IOException { outputStream.close(); }
@Override public void close() throws IOException { if (!closed) { closed = true; registry.unregisterCloseable(this); outputStream.close(); } }
@Override public void close() throws IOException { if (!closed) { closed = true; registry.unregisterCloseable(this); outputStream.close(); } }
@Override public void close() { if (!closed) { closed = true; try { out.close(); } catch (Throwable t) { LOG.warn("Could not close the state stream for {}.", tmpMetadataFilePath, t); } closeFilesQuietly(); } }
@Override public void close() { if (!closed) { closed = true; try { out.close(); fileSystem.delete(path, false); } catch (Throwable t) { LOG.warn("Could not close the state stream for {}.", path, t); } } }
@Override public void close() throws IOException { try { if (this.officeWriter!=null) { this.officeWriter.close(); } } finally { if (this.stream!=null) { this.stream.close(); } } }
@Override public void close() { if (!closed) { closed = true; try { out.close(); fileSystem.delete(metadataFilePath, false); } catch (Throwable t) { LOG.warn("Could not close the state stream for {}.", metadataFilePath, t); } } }
@Override public void close() { if (!closed) { closed = true; try { out.close(); fileSystem.delete(path, false); } catch (Throwable t) { LOG.warn("Could not close the state stream for {}.", path, t); } } }