@SuppressWarnings({ "rawtypes", "unchecked" }) private <T> TypeSerializer<T> getKeySerializer() { return proxy != null ? (TypeSerializer) proxy.getKeySerializerConfigSnapshot().restoreSerializer() : (TypeSerializer) keySerializer; }
private TypeSerializer<?> getKeySerializer(KeyedBackendSerializationProxy<?> proxy) { TypeSerializer<?> keySerializer = proxy.getKeySerializerConfigSnapshot().restoreSerializer(); if (keySerializer instanceof TupleSerializerBase) { TupleSerializerBase ts = (TupleSerializerBase) keySerializer; if (ts.getTupleClass().equals(Tuple1.class)) { return ts.getFieldSerializers()[0]; } } return keySerializer; }
if (!serializationProxy.getKeySerializerConfigSnapshot() .resolveSchemaCompatibility(keySerializer).isCompatibleAsIs()) { throw new StateMigrationException("The new key serializer must be compatible.");
if (!serializationProxy.getKeySerializerConfigSnapshot() .resolveSchemaCompatibility(rocksDBKeyedStateBackend.keySerializer).isCompatibleAsIs()) { throw new StateMigrationException("The new key serializer must be compatible.");
if (!serializationProxy.getKeySerializerConfigSnapshot() .resolveSchemaCompatibility(keySerializer).isCompatibleAsIs()) { throw new StateMigrationException("The new key serializer must be compatible.");
if (!serializationProxy.getKeySerializerConfigSnapshot() .resolveSchemaCompatibility(rocksDBKeyedStateBackend.keySerializer).isCompatibleAsIs()) { throw new StateMigrationException("The new key serializer must be compatible.");
serializationProxy.getKeySerializer(), UnloadableDummyTypeSerializer.class, serializationProxy.getKeySerializerConfigSnapshot(), rocksDBKeyedStateBackend.keySerializer) .isRequiresMigration()) {
serializationProxy.getKeySerializer(), UnloadableDummyTypeSerializer.class, serializationProxy.getKeySerializerConfigSnapshot(), keySerializer) .isRequiresMigration()) {
serializationProxy.getKeySerializer(), UnloadableDummyTypeSerializer.class, serializationProxy.getKeySerializerConfigSnapshot(), keySerializer) .isRequiresMigration()) {
/** * Reads Flink's state meta data file from the state handle. */ private List<StateMetaInfoSnapshot> readMetaData( StreamStateHandle metaStateHandle) throws Exception { FSDataInputStream inputStream = null; try { inputStream = metaStateHandle.openInputStream(); stateBackend.cancelStreamRegistry.registerCloseable(inputStream); // 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<T> serializationProxy = new KeyedBackendSerializationProxy<>(stateBackend.userCodeClassLoader); DataInputView in = new DataInputViewStreamWrapper(inputStream); serializationProxy.read(in); // check for key serializer compatibility; this also reconfigures the // key serializer to be compatible, if it is required and is possible if (!serializationProxy.getKeySerializerConfigSnapshot() .resolveSchemaCompatibility(stateBackend.keySerializer).isCompatibleAsIs()) { throw new StateMigrationException("The new key serializer must be compatible."); } return serializationProxy.getStateMetaInfoSnapshots(); } finally { if (stateBackend.cancelStreamRegistry.unregisterCloseable(inputStream)) { inputStream.close(); } } }
/** * Reads Flink's state meta data file from the state handle. */ private List<StateMetaInfoSnapshot> readMetaData( StreamStateHandle metaStateHandle) throws Exception { FSDataInputStream inputStream = null; try { inputStream = metaStateHandle.openInputStream(); stateBackend.cancelStreamRegistry.registerCloseable(inputStream); // 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<T> serializationProxy = new KeyedBackendSerializationProxy<>(stateBackend.userCodeClassLoader); DataInputView in = new DataInputViewStreamWrapper(inputStream); serializationProxy.read(in); // check for key serializer compatibility; this also reconfigures the // key serializer to be compatible, if it is required and is possible if (!serializationProxy.getKeySerializerConfigSnapshot() .resolveSchemaCompatibility(stateBackend.keySerializer).isCompatibleAsIs()) { throw new StateMigrationException("The new key serializer must be compatible."); } return serializationProxy.getStateMetaInfoSnapshots(); } finally { if (stateBackend.cancelStreamRegistry.unregisterCloseable(inputStream)) { inputStream.close(); } } }
private List<RegisteredKeyedBackendStateMetaInfo.Snapshot<?, ?>> readMetaData( StreamStateHandle metaStateHandle) throws Exception { FSDataInputStream inputStream = null; try { inputStream = metaStateHandle.openInputStream(); stateBackend.cancelStreamRegistry.registerClosable(inputStream); KeyedBackendSerializationProxy<T> serializationProxy = new KeyedBackendSerializationProxy<>(stateBackend.userCodeClassLoader); DataInputView in = new DataInputViewStreamWrapper(inputStream); serializationProxy.read(in); // check for key serializer compatibility; this also reconfigures the // key serializer to be compatible, if it is required and is possible if (CompatibilityUtil.resolveCompatibilityResult( serializationProxy.getKeySerializer(), UnloadableDummyTypeSerializer.class, serializationProxy.getKeySerializerConfigSnapshot(), stateBackend.keySerializer) .isRequiresMigration()) { // TODO replace with state migration; note that key hash codes need to remain the same after migration throw new StateMigrationException("The new key serializer is not compatible to read previous keys. " + "Aborting now since state migration is currently not available"); } return serializationProxy.getStateMetaInfoSnapshots(); } finally { if (inputStream != null) { stateBackend.cancelStreamRegistry.unregisterClosable(inputStream); inputStream.close(); } } }