Java Code Examples for org.apache.flink.runtime.state.KeyedBackendSerializationProxy#read()
The following examples show how to use
org.apache.flink.runtime.state.KeyedBackendSerializationProxy#read() .
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: AbstractRocksDBRestoreOperation.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
KeyedBackendSerializationProxy<K> readMetaData(DataInputView dataInputView) throws IOException, StateMigrationException { // isSerializerPresenceRequired flag is set to false, since for the RocksDB state backend, // deserialization of state happens lazily during runtime; we depend on the fact // that the new serializer for states could be compatible, and therefore the restore can continue // without old serializers required to be present. KeyedBackendSerializationProxy<K> serializationProxy = new KeyedBackendSerializationProxy<>(userCodeClassLoader); serializationProxy.read(dataInputView); if (!isKeySerializerCompatibilityChecked) { // check for key serializer compatibility; this also reconfigures the // key serializer to be compatible, if it is required and is possible TypeSerializerSchemaCompatibility<K> keySerializerSchemaCompat = keySerializerProvider.setPreviousSerializerSnapshotForRestoredState(serializationProxy.getKeySerializerSnapshot()); if (keySerializerSchemaCompat.isCompatibleAfterMigration() || keySerializerSchemaCompat.isIncompatible()) { throw new StateMigrationException("The new key serializer must be compatible."); } isKeySerializerCompatibilityChecked = true; } return serializationProxy; }
Example 2
Source File: AbstractRocksDBRestoreOperation.java From flink with Apache License 2.0 | 6 votes |
KeyedBackendSerializationProxy<K> readMetaData(DataInputView dataInputView) throws IOException, StateMigrationException { // isSerializerPresenceRequired flag is set to false, since for the RocksDB state backend, // deserialization of state happens lazily during runtime; we depend on the fact // that the new serializer for states could be compatible, and therefore the restore can continue // without old serializers required to be present. KeyedBackendSerializationProxy<K> serializationProxy = new KeyedBackendSerializationProxy<>(userCodeClassLoader); serializationProxy.read(dataInputView); if (!isKeySerializerCompatibilityChecked) { // check for key serializer compatibility; this also reconfigures the // key serializer to be compatible, if it is required and is possible TypeSerializerSchemaCompatibility<K> keySerializerSchemaCompat = keySerializerProvider.setPreviousSerializerSnapshotForRestoredState(serializationProxy.getKeySerializerSnapshot()); if (keySerializerSchemaCompat.isCompatibleAfterMigration() || keySerializerSchemaCompat.isIncompatible()) { throw new StateMigrationException("The new key serializer must be compatible."); } isKeySerializerCompatibilityChecked = true; } return serializationProxy; }
Example 3
Source File: AbstractRocksDBRestoreOperation.java From flink with Apache License 2.0 | 6 votes |
KeyedBackendSerializationProxy<K> readMetaData(DataInputView dataInputView) throws IOException, StateMigrationException { // isSerializerPresenceRequired flag is set to false, since for the RocksDB state backend, // deserialization of state happens lazily during runtime; we depend on the fact // that the new serializer for states could be compatible, and therefore the restore can continue // without old serializers required to be present. KeyedBackendSerializationProxy<K> serializationProxy = new KeyedBackendSerializationProxy<>(userCodeClassLoader); serializationProxy.read(dataInputView); if (!isKeySerializerCompatibilityChecked) { // check for key serializer compatibility; this also reconfigures the // key serializer to be compatible, if it is required and is possible TypeSerializerSchemaCompatibility<K> keySerializerSchemaCompat = keySerializerProvider.setPreviousSerializerSnapshotForRestoredState(serializationProxy.getKeySerializerSnapshot()); if (keySerializerSchemaCompat.isCompatibleAfterMigration() || keySerializerSchemaCompat.isIncompatible()) { throw new StateMigrationException("The new key serializer must be compatible."); } isKeySerializerCompatibilityChecked = true; } return serializationProxy; }
Example 4
Source File: StateMetadataUtils.java From bravo with Apache License 2.0 | 5 votes |
public static KeyedBackendSerializationProxy<?> getKeyedBackendSerializationProxy( StreamStateHandle streamStateHandle) { KeyedBackendSerializationProxy<Integer> serializationProxy = new KeyedBackendSerializationProxy<>( StateMetadataUtils.class.getClassLoader()); try (FSDataInputStream is = streamStateHandle.openInputStream()) { DataInputViewStreamWrapper iw = new DataInputViewStreamWrapper(is); serializationProxy.read(iw); return serializationProxy; } catch (IOException e) { throw new RuntimeException(e); } }
Example 5
Source File: HeapRestoreOperation.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public Void restore() throws Exception { final Map<Integer, StateMetaInfoSnapshot> kvStatesById = new HashMap<>(); registeredKVStates.clear(); registeredPQStates.clear(); boolean keySerializerRestored = false; for (KeyedStateHandle keyedStateHandle : restoreStateHandles) { if (keyedStateHandle == null) { continue; } if (!(keyedStateHandle instanceof KeyGroupsStateHandle)) { throw new IllegalStateException("Unexpected state handle type, " + "expected: " + KeyGroupsStateHandle.class + ", but found: " + keyedStateHandle.getClass()); } KeyGroupsStateHandle keyGroupsStateHandle = (KeyGroupsStateHandle) keyedStateHandle; FSDataInputStream fsDataInputStream = keyGroupsStateHandle.openInputStream(); cancelStreamRegistry.registerCloseable(fsDataInputStream); try { DataInputViewStreamWrapper inView = new DataInputViewStreamWrapper(fsDataInputStream); KeyedBackendSerializationProxy<K> serializationProxy = new KeyedBackendSerializationProxy<>(userCodeClassLoader); serializationProxy.read(inView); if (!keySerializerRestored) { // check for key serializer compatibility; this also reconfigures the // key serializer to be compatible, if it is required and is possible TypeSerializerSchemaCompatibility<K> keySerializerSchemaCompat = keySerializerProvider.setPreviousSerializerSnapshotForRestoredState(serializationProxy.getKeySerializerSnapshot()); if (keySerializerSchemaCompat.isCompatibleAfterMigration() || keySerializerSchemaCompat.isIncompatible()) { throw new StateMigrationException("The new key serializer must be compatible."); } keySerializerRestored = true; } List<StateMetaInfoSnapshot> restoredMetaInfos = serializationProxy.getStateMetaInfoSnapshots(); createOrCheckStateForMetaInfo(restoredMetaInfos, kvStatesById); readStateHandleStateData( fsDataInputStream, inView, keyGroupsStateHandle.getGroupRangeOffsets(), kvStatesById, restoredMetaInfos.size(), serializationProxy.getReadVersion(), serializationProxy.isUsingKeyGroupCompression()); } finally { if (cancelStreamRegistry.unregisterCloseable(fsDataInputStream)) { IOUtils.closeQuietly(fsDataInputStream); } } } return null; }
Example 6
Source File: HeapRestoreOperation.java From flink with Apache License 2.0 | 4 votes |
@Override public Void restore() throws Exception { final Map<Integer, StateMetaInfoSnapshot> kvStatesById = new HashMap<>(); registeredKVStates.clear(); registeredPQStates.clear(); boolean keySerializerRestored = false; for (KeyedStateHandle keyedStateHandle : restoreStateHandles) { if (keyedStateHandle == null) { continue; } if (!(keyedStateHandle instanceof KeyGroupsStateHandle)) { throw new IllegalStateException("Unexpected state handle type, " + "expected: " + KeyGroupsStateHandle.class + ", but found: " + keyedStateHandle.getClass()); } KeyGroupsStateHandle keyGroupsStateHandle = (KeyGroupsStateHandle) keyedStateHandle; FSDataInputStream fsDataInputStream = keyGroupsStateHandle.openInputStream(); cancelStreamRegistry.registerCloseable(fsDataInputStream); try { DataInputViewStreamWrapper inView = new DataInputViewStreamWrapper(fsDataInputStream); KeyedBackendSerializationProxy<K> serializationProxy = new KeyedBackendSerializationProxy<>(userCodeClassLoader); serializationProxy.read(inView); if (!keySerializerRestored) { // check for key serializer compatibility; this also reconfigures the // key serializer to be compatible, if it is required and is possible TypeSerializerSchemaCompatibility<K> keySerializerSchemaCompat = keySerializerProvider.setPreviousSerializerSnapshotForRestoredState(serializationProxy.getKeySerializerSnapshot()); if (keySerializerSchemaCompat.isCompatibleAfterMigration() || keySerializerSchemaCompat.isIncompatible()) { throw new StateMigrationException("The new key serializer must be compatible."); } keySerializerRestored = true; } List<StateMetaInfoSnapshot> restoredMetaInfos = serializationProxy.getStateMetaInfoSnapshots(); createOrCheckStateForMetaInfo(restoredMetaInfos, kvStatesById); readStateHandleStateData( fsDataInputStream, inView, keyGroupsStateHandle.getGroupRangeOffsets(), kvStatesById, restoredMetaInfos.size(), serializationProxy.getReadVersion(), serializationProxy.isUsingKeyGroupCompression()); } finally { if (cancelStreamRegistry.unregisterCloseable(fsDataInputStream)) { IOUtils.closeQuietly(fsDataInputStream); } } } return null; }
Example 7
Source File: HeapRestoreOperation.java From flink with Apache License 2.0 | 4 votes |
@Override public Void restore() throws Exception { registeredKVStates.clear(); registeredPQStates.clear(); boolean keySerializerRestored = false; for (KeyedStateHandle keyedStateHandle : restoreStateHandles) { if (keyedStateHandle == null) { continue; } if (!(keyedStateHandle instanceof KeyGroupsStateHandle)) { throw new IllegalStateException("Unexpected state handle type, " + "expected: " + KeyGroupsStateHandle.class + ", but found: " + keyedStateHandle.getClass()); } KeyGroupsStateHandle keyGroupsStateHandle = (KeyGroupsStateHandle) keyedStateHandle; FSDataInputStream fsDataInputStream = keyGroupsStateHandle.openInputStream(); cancelStreamRegistry.registerCloseable(fsDataInputStream); try { DataInputViewStreamWrapper inView = new DataInputViewStreamWrapper(fsDataInputStream); KeyedBackendSerializationProxy<K> serializationProxy = new KeyedBackendSerializationProxy<>(userCodeClassLoader); serializationProxy.read(inView); if (!keySerializerRestored) { // check for key serializer compatibility; this also reconfigures the // key serializer to be compatible, if it is required and is possible TypeSerializerSchemaCompatibility<K> keySerializerSchemaCompat = keySerializerProvider.setPreviousSerializerSnapshotForRestoredState(serializationProxy.getKeySerializerSnapshot()); if (keySerializerSchemaCompat.isCompatibleAfterMigration() || keySerializerSchemaCompat.isIncompatible()) { throw new StateMigrationException("The new key serializer must be compatible."); } keySerializerRestored = true; } List<StateMetaInfoSnapshot> restoredMetaInfos = serializationProxy.getStateMetaInfoSnapshots(); final Map<Integer, StateMetaInfoSnapshot> kvStatesById = new HashMap<>(); createOrCheckStateForMetaInfo(restoredMetaInfos, kvStatesById); readStateHandleStateData( fsDataInputStream, inView, keyGroupsStateHandle.getGroupRangeOffsets(), kvStatesById, restoredMetaInfos.size(), serializationProxy.getReadVersion(), serializationProxy.isUsingKeyGroupCompression()); } finally { if (cancelStreamRegistry.unregisterCloseable(fsDataInputStream)) { IOUtils.closeQuietly(fsDataInputStream); } } } return null; }