@Override public final void readSnapshot(int readVersion, DataInputView in, ClassLoader userCodeClassLoader) throws IOException { if (readVersion != ADAPTER_VERSION) { throw new IOException("Wrong/unexpected version for the TypeSerializerConfigSnapshot: " + readVersion); } serializer = TypeSerializerSerializationUtil.tryReadSerializer(in, userCodeClassLoader, true); // now delegate to the snapshots own reading code setUserCodeClassLoader(userCodeClassLoader); read(in); }
/** * Deserialization path for Flink versions in [1.4, 1.6]. */ @VisibleForTesting @SuppressWarnings("deprecation") static <T> TypeSerializerSnapshot<T> deserializeV1( DataInputView in, ClassLoader cl, @Nullable TypeSerializer<T> serializer) throws IOException { TypeSerializerSnapshot<T> snapshot = readAndInstantiateSnapshotClass(in, cl); // if the snapshot was created before Flink 1.7, we need to distinguish the following cases: // - old snapshot type that needs serializer from the outside // - new snapshot type that understands the old format and can produce a restore serializer from it if (snapshot instanceof TypeSerializerConfigSnapshot) { TypeSerializerConfigSnapshot<T> oldTypeSnapshot = (TypeSerializerConfigSnapshot<T>) snapshot; oldTypeSnapshot.setPriorSerializer(serializer); oldTypeSnapshot.setUserCodeClassLoader(cl); oldTypeSnapshot.read(in); } else { // new type, simple case int readVersion = in.readInt(); snapshot.readSnapshot(readVersion, in, cl); } return snapshot; }
@Override public final void readSnapshot(int readVersion, DataInputView in, ClassLoader userCodeClassLoader) throws IOException { if (readVersion != ADAPTER_VERSION) { throw new IOException("Wrong/unexpected version for the TypeSerializerConfigSnapshot: " + readVersion); } serializer = TypeSerializerSerializationUtil.tryReadSerializer(in, userCodeClassLoader, true); // now delegate to the snapshots own reading code setUserCodeClassLoader(userCodeClassLoader); read(in); }
@SuppressWarnings("unchecked") @Override public void read(DataInputView in) throws IOException { super.read(in); String serializerConfigClassname = in.readUTF(); Class<? extends TypeSerializerConfigSnapshot> serializerConfigSnapshotClass; try { serializerConfigSnapshotClass = (Class<? extends TypeSerializerConfigSnapshot>) Class.forName(serializerConfigClassname, true, userCodeClassLoader); } catch (ClassNotFoundException e) { throw new IOException( "Could not find requested TypeSerializerConfigSnapshot class " + serializerConfigClassname + " in classpath.", e); } serializerConfigSnapshot = InstantiationUtil.instantiate(serializerConfigSnapshotClass); serializerConfigSnapshot.setUserCodeClassLoader(userCodeClassLoader); serializerConfigSnapshot.read(in); }
/** * Deserialization path for Flink versions in [1.4, 1.6]. */ @VisibleForTesting @SuppressWarnings("deprecation") static <T> TypeSerializerSnapshot<T> deserializeV1( DataInputView in, ClassLoader cl, @Nullable TypeSerializer<T> serializer) throws IOException { TypeSerializerSnapshot<T> snapshot = readAndInstantiateSnapshotClass(in, cl); // if the snapshot was created before Flink 1.7, we need to distinguish the following cases: // - old snapshot type that needs serializer from the outside // - new snapshot type that understands the old format and can produce a restore serializer from it if (snapshot instanceof TypeSerializerConfigSnapshot) { TypeSerializerConfigSnapshot<T> oldTypeSnapshot = (TypeSerializerConfigSnapshot<T>) snapshot; oldTypeSnapshot.setPriorSerializer(serializer); oldTypeSnapshot.setUserCodeClassLoader(cl); oldTypeSnapshot.read(in); } else { // new type, simple case int readVersion = in.readInt(); snapshot.readSnapshot(readVersion, in, cl); } return snapshot; }