Java Code Examples for org.apache.flink.runtime.state.KeyedBackendSerializationProxy#write()
The following examples show how to use
org.apache.flink.runtime.state.KeyedBackendSerializationProxy#write() .
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: RocksFullSnapshotStrategy.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private void writeKVStateMetaData( final List<Tuple2<RocksIteratorWrapper, Integer>> kvStateIterators, final ReadOptions readOptions, final DataOutputView outputView) throws IOException { int kvStateId = 0; for (MetaData metaDataEntry : metaData) { RocksIteratorWrapper rocksIteratorWrapper = getRocksIterator( db, metaDataEntry.rocksDbKvStateInfo.columnFamilyHandle, metaDataEntry.stateSnapshotTransformer, readOptions); kvStateIterators.add(Tuple2.of(rocksIteratorWrapper, kvStateId)); ++kvStateId; } KeyedBackendSerializationProxy<K> serializationProxy = new KeyedBackendSerializationProxy<>( // TODO: this code assumes that writing a serializer is threadsafe, we should support to // get a serialized form already at state registration time in the future keySerializer, stateMetaInfoSnapshots, !Objects.equals( UncompressedStreamCompressionDecorator.INSTANCE, keyGroupCompressionDecorator)); serializationProxy.write(outputView); }
Example 2
Source File: RocksFullSnapshotStrategy.java From flink with Apache License 2.0 | 6 votes |
private void writeKVStateMetaData( final List<Tuple2<RocksIteratorWrapper, Integer>> kvStateIterators, final ReadOptions readOptions, final DataOutputView outputView) throws IOException { int kvStateId = 0; for (MetaData metaDataEntry : metaData) { RocksIteratorWrapper rocksIteratorWrapper = getRocksIterator( db, metaDataEntry.rocksDbKvStateInfo.columnFamilyHandle, metaDataEntry.stateSnapshotTransformer, readOptions); kvStateIterators.add(Tuple2.of(rocksIteratorWrapper, kvStateId)); ++kvStateId; } KeyedBackendSerializationProxy<K> serializationProxy = new KeyedBackendSerializationProxy<>( // TODO: this code assumes that writing a serializer is threadsafe, we should support to // get a serialized form already at state registration time in the future keySerializer, stateMetaInfoSnapshots, !Objects.equals( UncompressedStreamCompressionDecorator.INSTANCE, keyGroupCompressionDecorator)); serializationProxy.write(outputView); }
Example 3
Source File: RocksFullSnapshotStrategy.java From flink with Apache License 2.0 | 6 votes |
private void writeKVStateMetaData( final List<Tuple2<RocksIteratorWrapper, Integer>> kvStateIterators, final ReadOptions readOptions, final DataOutputView outputView) throws IOException { int kvStateId = 0; for (MetaData metaDataEntry : metaData) { RocksIteratorWrapper rocksIteratorWrapper = getRocksIterator( db, metaDataEntry.rocksDbKvStateInfo.columnFamilyHandle, metaDataEntry.stateSnapshotTransformer, readOptions); kvStateIterators.add(Tuple2.of(rocksIteratorWrapper, kvStateId)); ++kvStateId; } KeyedBackendSerializationProxy<K> serializationProxy = new KeyedBackendSerializationProxy<>( // TODO: this code assumes that writing a serializer is threadsafe, we should support to // get a serialized form already at state registration time in the future keySerializer, stateMetaInfoSnapshots, !Objects.equals( UncompressedStreamCompressionDecorator.INSTANCE, keyGroupCompressionDecorator)); serializationProxy.write(outputView); }
Example 4
Source File: RocksIncrementalSnapshotStrategy.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Nonnull private SnapshotResult<StreamStateHandle> materializeMetaData() throws Exception { CheckpointStreamWithResultProvider streamWithResultProvider = localRecoveryConfig.isLocalRecoveryEnabled() ? CheckpointStreamWithResultProvider.createDuplicatingStream( checkpointId, CheckpointedStateScope.EXCLUSIVE, checkpointStreamFactory, localRecoveryConfig.getLocalStateDirectoryProvider()) : CheckpointStreamWithResultProvider.createSimpleStream( CheckpointedStateScope.EXCLUSIVE, checkpointStreamFactory); snapshotCloseableRegistry.registerCloseable(streamWithResultProvider); try { //no need for compression scheme support because sst-files are already compressed KeyedBackendSerializationProxy<K> serializationProxy = new KeyedBackendSerializationProxy<>( keySerializer, stateMetaInfoSnapshots, false); DataOutputView out = new DataOutputViewStreamWrapper(streamWithResultProvider.getCheckpointOutputStream()); serializationProxy.write(out); if (snapshotCloseableRegistry.unregisterCloseable(streamWithResultProvider)) { SnapshotResult<StreamStateHandle> result = streamWithResultProvider.closeAndFinalizeCheckpointStreamResult(); streamWithResultProvider = null; return result; } else { throw new IOException("Stream already closed and cannot return a handle."); } } finally { if (streamWithResultProvider != null) { if (snapshotCloseableRegistry.unregisterCloseable(streamWithResultProvider)) { IOUtils.closeQuietly(streamWithResultProvider); } } } }
Example 5
Source File: RocksIncrementalSnapshotStrategy.java From flink with Apache License 2.0 | 4 votes |
@Nonnull private SnapshotResult<StreamStateHandle> materializeMetaData() throws Exception { CheckpointStreamWithResultProvider streamWithResultProvider = localRecoveryConfig.isLocalRecoveryEnabled() ? CheckpointStreamWithResultProvider.createDuplicatingStream( checkpointId, CheckpointedStateScope.EXCLUSIVE, checkpointStreamFactory, localRecoveryConfig.getLocalStateDirectoryProvider()) : CheckpointStreamWithResultProvider.createSimpleStream( CheckpointedStateScope.EXCLUSIVE, checkpointStreamFactory); snapshotCloseableRegistry.registerCloseable(streamWithResultProvider); try { //no need for compression scheme support because sst-files are already compressed KeyedBackendSerializationProxy<K> serializationProxy = new KeyedBackendSerializationProxy<>( keySerializer, stateMetaInfoSnapshots, false); DataOutputView out = new DataOutputViewStreamWrapper(streamWithResultProvider.getCheckpointOutputStream()); serializationProxy.write(out); if (snapshotCloseableRegistry.unregisterCloseable(streamWithResultProvider)) { SnapshotResult<StreamStateHandle> result = streamWithResultProvider.closeAndFinalizeCheckpointStreamResult(); streamWithResultProvider = null; return result; } else { throw new IOException("Stream already closed and cannot return a handle."); } } finally { if (streamWithResultProvider != null) { if (snapshotCloseableRegistry.unregisterCloseable(streamWithResultProvider)) { IOUtils.closeQuietly(streamWithResultProvider); } } } }
Example 6
Source File: RocksIncrementalSnapshotStrategy.java From flink with Apache License 2.0 | 4 votes |
@Nonnull private SnapshotResult<StreamStateHandle> materializeMetaData() throws Exception { CheckpointStreamWithResultProvider streamWithResultProvider = localRecoveryConfig.isLocalRecoveryEnabled() ? CheckpointStreamWithResultProvider.createDuplicatingStream( checkpointId, CheckpointedStateScope.EXCLUSIVE, checkpointStreamFactory, localRecoveryConfig.getLocalStateDirectoryProvider()) : CheckpointStreamWithResultProvider.createSimpleStream( CheckpointedStateScope.EXCLUSIVE, checkpointStreamFactory); snapshotCloseableRegistry.registerCloseable(streamWithResultProvider); try { //no need for compression scheme support because sst-files are already compressed KeyedBackendSerializationProxy<K> serializationProxy = new KeyedBackendSerializationProxy<>( keySerializer, stateMetaInfoSnapshots, false); DataOutputView out = new DataOutputViewStreamWrapper(streamWithResultProvider.getCheckpointOutputStream()); serializationProxy.write(out); if (snapshotCloseableRegistry.unregisterCloseable(streamWithResultProvider)) { SnapshotResult<StreamStateHandle> result = streamWithResultProvider.closeAndFinalizeCheckpointStreamResult(); streamWithResultProvider = null; return result; } else { throw new IOException("Stream already closed and cannot return a handle."); } } finally { if (streamWithResultProvider != null) { if (snapshotCloseableRegistry.unregisterCloseable(streamWithResultProvider)) { IOUtils.closeQuietly(streamWithResultProvider); } } } }