Java Code Examples for org.apache.flink.core.fs.FSDataInputStream#close()
The following examples show how to use
org.apache.flink.core.fs.FSDataInputStream#close() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileInputFormat.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public void run() { try { final FileSystem fs = FileSystem.get(this.split.getPath().toUri()); this.fdis = fs.open(this.split.getPath()); // check for canceling and close the stream in that case, because no one will obtain it if (this.aborted) { final FSDataInputStream f = this.fdis; this.fdis = null; f.close(); } } catch (Throwable t) { this.error = t; } }
Example 2
Source File: RocksDBIncrementalRestoreOperation.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Reads Flink's state meta data file from the state handle. */ private KeyedBackendSerializationProxy<K> readMetaData(StreamStateHandle metaStateHandle) throws Exception { FSDataInputStream inputStream = null; try { inputStream = metaStateHandle.openInputStream(); cancelStreamRegistry.registerCloseable(inputStream); DataInputView in = new DataInputViewStreamWrapper(inputStream); return readMetaData(in); } finally { if (cancelStreamRegistry.unregisterCloseable(inputStream)) { inputStream.close(); } } }
Example 3
Source File: FileInputFormat.java From flink with Apache License 2.0 | 6 votes |
@Override public void run() { try { final FileSystem fs = FileSystem.get(this.split.getPath().toUri()); this.fdis = fs.open(this.split.getPath()); // check for canceling and close the stream in that case, because no one will obtain it if (this.aborted) { final FSDataInputStream f = this.fdis; this.fdis = null; f.close(); } } catch (Throwable t) { this.error = t; } }
Example 4
Source File: RocksDBIncrementalRestoreOperation.java From flink with Apache License 2.0 | 6 votes |
/** * Reads Flink's state meta data file from the state handle. */ private KeyedBackendSerializationProxy<K> readMetaData(StreamStateHandle metaStateHandle) throws Exception { FSDataInputStream inputStream = null; try { inputStream = metaStateHandle.openInputStream(); cancelStreamRegistry.registerCloseable(inputStream); DataInputView in = new DataInputViewStreamWrapper(inputStream); return readMetaData(in); } finally { if (cancelStreamRegistry.unregisterCloseable(inputStream)) { inputStream.close(); } } }
Example 5
Source File: FileInputFormat.java From flink with Apache License 2.0 | 6 votes |
@Override public void run() { try { final FileSystem fs = FileSystem.get(this.split.getPath().toUri()); this.fdis = fs.open(this.split.getPath()); // check for canceling and close the stream in that case, because no one will obtain it if (this.aborted) { final FSDataInputStream f = this.fdis; this.fdis = null; f.close(); } } catch (Throwable t) { this.error = t; } }
Example 6
Source File: FileInputFormat.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Double checked procedure setting the abort flag and closing the stream. */ private void abortWait() { this.aborted = true; final FSDataInputStream inStream = this.fdis; this.fdis = null; if (inStream != null) { try { inStream.close(); } catch (Throwable t) {} } }
Example 7
Source File: RocksDBStateDownloader.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Copies the file from a single state handle to the given path. */ private void downloadDataForStateHandle( Path restoreFilePath, StreamStateHandle remoteFileHandle, CloseableRegistry closeableRegistry) throws IOException { FSDataInputStream inputStream = null; FSDataOutputStream outputStream = null; try { FileSystem restoreFileSystem = restoreFilePath.getFileSystem(); inputStream = remoteFileHandle.openInputStream(); closeableRegistry.registerCloseable(inputStream); outputStream = restoreFileSystem.create(restoreFilePath, FileSystem.WriteMode.OVERWRITE); closeableRegistry.registerCloseable(outputStream); byte[] buffer = new byte[8 * 1024]; while (true) { int numBytes = inputStream.read(buffer); if (numBytes == -1) { break; } outputStream.write(buffer, 0, numBytes); } } finally { if (closeableRegistry.unregisterCloseable(inputStream)) { inputStream.close(); } if (closeableRegistry.unregisterCloseable(outputStream)) { outputStream.close(); } } }
Example 8
Source File: StateInitializationContextImplTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public FSDataInputStream openInputStream() throws IOException { final FSDataInputStream original = super.openInputStream(); return new FSDataInputStream() { private boolean closed = false; @Override public void seek(long desired) throws IOException { original.seek(desired); } @Override public long getPos() throws IOException { return original.getPos(); } @Override public int read() throws IOException { if (closed) { throw new IOException("Stream closed"); } return original.read(); } @Override public void close() throws IOException { original.close(); this.closed = true; } }; }
Example 9
Source File: FileInputFormat.java From flink with Apache License 2.0 | 5 votes |
/** * Double checked procedure setting the abort flag and closing the stream. */ private void abortWait() { this.aborted = true; final FSDataInputStream inStream = this.fdis; this.fdis = null; if (inStream != null) { try { inStream.close(); } catch (Throwable t) {} } }
Example 10
Source File: RocksDBStateDownloader.java From flink with Apache License 2.0 | 5 votes |
/** * Copies the file from a single state handle to the given path. */ private void downloadDataForStateHandle( Path restoreFilePath, StreamStateHandle remoteFileHandle, CloseableRegistry closeableRegistry) throws IOException { FSDataInputStream inputStream = null; FSDataOutputStream outputStream = null; try { FileSystem restoreFileSystem = restoreFilePath.getFileSystem(); inputStream = remoteFileHandle.openInputStream(); closeableRegistry.registerCloseable(inputStream); outputStream = restoreFileSystem.create(restoreFilePath, FileSystem.WriteMode.OVERWRITE); closeableRegistry.registerCloseable(outputStream); byte[] buffer = new byte[8 * 1024]; while (true) { int numBytes = inputStream.read(buffer); if (numBytes == -1) { break; } outputStream.write(buffer, 0, numBytes); } } finally { if (closeableRegistry.unregisterCloseable(inputStream)) { inputStream.close(); } if (closeableRegistry.unregisterCloseable(outputStream)) { outputStream.close(); } } }
Example 11
Source File: StateInitializationContextImplTest.java From flink with Apache License 2.0 | 5 votes |
@Override public FSDataInputStream openInputStream() throws IOException { final FSDataInputStream original = super.openInputStream(); return new FSDataInputStream() { private boolean closed = false; @Override public void seek(long desired) throws IOException { original.seek(desired); } @Override public long getPos() throws IOException { return original.getPos(); } @Override public int read() throws IOException { if (closed) { throw new IOException("Stream closed"); } return original.read(); } @Override public void close() throws IOException { original.close(); this.closed = true; } }; }
Example 12
Source File: RocksDBCheckpointIterator.java From bravo with Apache License 2.0 | 5 votes |
private void copyStateDataHandleData( Path restoreFilePath, StreamStateHandle remoteFileHandle) throws IOException { FileSystem restoreFileSystem = restoreFilePath.getFileSystem(); FSDataInputStream inputStream = null; FSDataOutputStream outputStream = null; try { inputStream = remoteFileHandle.openInputStream(); cancelStreamRegistry.registerCloseable(inputStream); outputStream = restoreFileSystem.create(restoreFilePath, FileSystem.WriteMode.OVERWRITE); cancelStreamRegistry.registerCloseable(outputStream); byte[] buffer = new byte[8 * 1024]; while (true) { int numBytes = inputStream.read(buffer); if (numBytes == -1) { break; } outputStream.write(buffer, 0, numBytes); } } finally { if (cancelStreamRegistry.unregisterCloseable(inputStream)) { inputStream.close(); } if (cancelStreamRegistry.unregisterCloseable(outputStream)) { outputStream.close(); } } }
Example 13
Source File: FileInputFormat.java From flink with Apache License 2.0 | 5 votes |
/** * Double checked procedure setting the abort flag and closing the stream. */ private void abortWait() { this.aborted = true; final FSDataInputStream inStream = this.fdis; this.fdis = null; if (inStream != null) { try { inStream.close(); } catch (Throwable t) {} } }
Example 14
Source File: RocksDBStateDownloader.java From flink with Apache License 2.0 | 5 votes |
/** * Copies the file from a single state handle to the given path. */ private void downloadDataForStateHandle( Path restoreFilePath, StreamStateHandle remoteFileHandle, CloseableRegistry closeableRegistry) throws IOException { FSDataInputStream inputStream = null; OutputStream outputStream = null; try { inputStream = remoteFileHandle.openInputStream(); closeableRegistry.registerCloseable(inputStream); Files.createDirectories(restoreFilePath.getParent()); outputStream = Files.newOutputStream(restoreFilePath); closeableRegistry.registerCloseable(outputStream); byte[] buffer = new byte[8 * 1024]; while (true) { int numBytes = inputStream.read(buffer); if (numBytes == -1) { break; } outputStream.write(buffer, 0, numBytes); } } finally { if (closeableRegistry.unregisterCloseable(inputStream)) { inputStream.close(); } if (closeableRegistry.unregisterCloseable(outputStream)) { outputStream.close(); } } }
Example 15
Source File: StateInitializationContextImplTest.java From flink with Apache License 2.0 | 5 votes |
@Override public FSDataInputStream openInputStream() throws IOException { final FSDataInputStream original = super.openInputStream(); return new FSDataInputStream() { private boolean closed = false; @Override public void seek(long desired) throws IOException { original.seek(desired); } @Override public long getPos() throws IOException { return original.getPos(); } @Override public int read() throws IOException { if (closed) { throw new IOException("Stream closed"); } return original.read(); } @Override public void close() throws IOException { original.close(); this.closed = true; } }; }