@SuppressWarnings("unchecked") @Override public void read(DataInputView in) throws IOException { super.read(in); // read in a way that allows the stream to recover from exceptions int serializerBytes = in.readInt(); byte[] buffer = new byte[serializerBytes]; in.readFully(buffer); ClassLoader previousClassLoader = Thread.currentThread().getContextClassLoader(); try ( InstantiationUtil.FailureTolerantObjectInputStream ois = new InstantiationUtil.FailureTolerantObjectInputStream(new ByteArrayInputStream(buffer), userClassLoader)) { Thread.currentThread().setContextClassLoader(userClassLoader); typeSerializer = (TypeSerializer<T>) ois.readObject(); } catch (Exception e) { throw new UnloadableTypeSerializerException(e, buffer); } finally { Thread.currentThread().setContextClassLoader(previousClassLoader); } }
/** * This read attempts to first identify if the input view contains the special * {@link #VERSIONED_IDENTIFIER} by reading and buffering the first few bytes. * If identified to be versioned, the usual version resolution read path * in {@link VersionedIOReadableWritable#read(DataInputView)} is invoked. * Otherwise, we "reset" the input stream by pushing back the read buffered bytes * into the stream. */ public final void read(InputStream inputStream) throws IOException { byte[] tmp = new byte[VERSIONED_IDENTIFIER.length]; inputStream.read(tmp); if (Arrays.equals(tmp, VERSIONED_IDENTIFIER)) { DataInputView inputView = new DataInputViewStreamWrapper(inputStream); super.read(inputView); read(inputView, true); } else { PushbackInputStream resetStream = new PushbackInputStream(inputStream, VERSIONED_IDENTIFIER.length); resetStream.unread(tmp); read(new DataInputViewStreamWrapper(resetStream), false); } }
@Override public void read(DataInputView in) throws IOException { super.read(in); this.data = in.readUTF(); }
@SuppressWarnings("unchecked") @Override public void read(DataInputView in) throws IOException { // read version super.read(in); final int version = getReadVersion(); switch (version) { case 2: serializerSnapshot = deserializeV2(in, userCodeClassLoader); break; case 1: serializerSnapshot = deserializeV1(in, userCodeClassLoader, serializer); break; default: throw new IOException("Unrecognized version for TypeSerializerSnapshot format: " + version); } }
@Override public void read(DataInputView in) throws IOException { super.read(in); int numKvStates = in.readShort(); stateMetaInfoSnapshots = new ArrayList<>(numKvStates); for (int i = 0; i < numKvStates; i++) { stateMetaInfoSnapshots.add( OperatorBackendStateMetaInfoSnapshotReaderWriters .getReaderForVersion(getReadVersion(), userCodeClassLoader) .readStateMetaInfo(in)); } }
@SuppressWarnings("unchecked") @Override public void read(DataInputView in) throws IOException { super.read(in); // read in a way that allows the stream to recover from exceptions int serializerBytes = in.readInt(); byte[] buffer = new byte[serializerBytes]; in.readFully(buffer); ClassLoader previousClassLoader = Thread.currentThread().getContextClassLoader(); try ( InstantiationUtil.FailureTolerantObjectInputStream ois = new InstantiationUtil.FailureTolerantObjectInputStream(new ByteArrayInputStream(buffer), userClassLoader)) { Thread.currentThread().setContextClassLoader(userClassLoader); typeSerializer = (TypeSerializer<T>) ois.readObject(); } catch (Exception e) { throw new UnloadableTypeSerializerException(e, buffer); } finally { Thread.currentThread().setContextClassLoader(previousClassLoader); } }
@SuppressWarnings("unchecked") @Override public void read(DataInputView in) throws IOException { super.read(in); // read in a way that allows the stream to recover from exceptions int serializerBytes = in.readInt(); byte[] buffer = new byte[serializerBytes]; in.readFully(buffer); ClassLoader previousClassLoader = Thread.currentThread().getContextClassLoader(); try ( InstantiationUtil.FailureTolerantObjectInputStream ois = new InstantiationUtil.FailureTolerantObjectInputStream(new ByteArrayInputStream(buffer), userClassLoader)) { Thread.currentThread().setContextClassLoader(userClassLoader); typeSerializer = (TypeSerializer<T>) ois.readObject(); } catch (Exception e) { throw new UnloadableTypeSerializerException(e, buffer); } finally { Thread.currentThread().setContextClassLoader(previousClassLoader); } }
@SuppressWarnings("unchecked") @Override public void read(DataInputView in) throws IOException { // read version super.read(in); final int version = getReadVersion(); switch (version) { case 2: serializerSnapshot = deserializeV2(in, userCodeClassLoader); break; case 1: serializerSnapshot = deserializeV1(in, userCodeClassLoader, serializer); break; default: throw new IOException("Unrecognized version for TypeSerializerSnapshot format: " + version); } }
@Override public void read(DataInputView in) throws IOException { super.read(in); usingKeyGroupCompression = in.readBoolean(); keyedStateMetaInfoSnapshots = readStateMetaInfoSnapshot(in, true); subKeyedStateMetaInfoSnapshots = readStateMetaInfoSnapshot(in, false); }
/** * This read attempts to first identify if the input view contains the special * {@link #VERSIONED_IDENTIFIER} by reading and buffering the first few bytes. * If identified to be versioned, the usual version resolution read path * in {@link VersionedIOReadableWritable#read(DataInputView)} is invoked. * Otherwise, we "reset" the input stream by pushing back the read buffered bytes * into the stream. */ public final void read(InputStream inputStream) throws IOException { byte[] tmp = new byte[VERSIONED_IDENTIFIER.length]; inputStream.read(tmp); if (Arrays.equals(tmp, VERSIONED_IDENTIFIER)) { DataInputView inputView = new DataInputViewStreamWrapper(inputStream); super.read(inputView); read(inputView, true); } else { PushbackInputStream resetStream = new PushbackInputStream(inputStream, VERSIONED_IDENTIFIER.length); resetStream.unread(tmp); read(new DataInputViewStreamWrapper(resetStream), false); } }
/** * This read attempts to first identify if the input view contains the special * {@link #VERSIONED_IDENTIFIER} by reading and buffering the first few bytes. * If identified to be versioned, the usual version resolution read path * in {@link VersionedIOReadableWritable#read(DataInputView)} is invoked. * Otherwise, we "reset" the input stream by pushing back the read buffered bytes * into the stream. */ public final void read(InputStream inputStream) throws IOException { byte[] tmp = new byte[VERSIONED_IDENTIFIER.length]; inputStream.read(tmp); if (Arrays.equals(tmp, VERSIONED_IDENTIFIER)) { DataInputView inputView = new DataInputViewStreamWrapper(inputStream); super.read(inputView); read(inputView, true); } else { PushbackInputStream resetStream = new PushbackInputStream(inputStream, VERSIONED_IDENTIFIER.length); resetStream.unread(tmp); read(new DataInputViewStreamWrapper(resetStream), false); } }
@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); }
@Override public void read(DataInputView in) throws IOException { super.read(in); final int proxyReadVersion = getReadVersion(); final Integer metaInfoSnapshotVersion = META_INFO_SNAPSHOT_FORMAT_VERSION_MAPPER.get(proxyReadVersion); if (metaInfoSnapshotVersion == null) { // this should not happen; guard for the future throw new IOException("Cannot determine corresponding meta info snapshot version for operator backend serialization readVersion=" + proxyReadVersion); } final StateMetaInfoReader stateMetaInfoReader = StateMetaInfoSnapshotReadersWriters.getReader( metaInfoSnapshotVersion, StateMetaInfoSnapshotReadersWriters.StateTypeHint.OPERATOR_STATE); int numOperatorStates = in.readShort(); operatorStateMetaInfoSnapshots = new ArrayList<>(numOperatorStates); for (int i = 0; i < numOperatorStates; i++) { operatorStateMetaInfoSnapshots.add( stateMetaInfoReader.readStateMetaInfoSnapshot(in, userCodeClassLoader)); } if (proxyReadVersion >= 3) { // broadcast states did not exist prior to version 3 int numBroadcastStates = in.readShort(); broadcastStateMetaInfoSnapshots = new ArrayList<>(numBroadcastStates); for (int i = 0; i < numBroadcastStates; i++) { broadcastStateMetaInfoSnapshots.add( stateMetaInfoReader.readStateMetaInfoSnapshot(in, userCodeClassLoader)); } } else { broadcastStateMetaInfoSnapshots = new ArrayList<>(); } }
@Override public void read(DataInputView in) throws IOException { super.read(in); final int proxyReadVersion = getReadVersion(); final Integer metaInfoSnapshotVersion = META_INFO_SNAPSHOT_FORMAT_VERSION_MAPPER.get(proxyReadVersion); if (metaInfoSnapshotVersion == null) { // this should not happen; guard for the future throw new IOException("Cannot determine corresponding meta info snapshot version for operator backend serialization readVersion=" + proxyReadVersion); } final StateMetaInfoReader stateMetaInfoReader = StateMetaInfoSnapshotReadersWriters.getReader( metaInfoSnapshotVersion, StateMetaInfoSnapshotReadersWriters.StateTypeHint.OPERATOR_STATE); int numOperatorStates = in.readShort(); operatorStateMetaInfoSnapshots = new ArrayList<>(numOperatorStates); for (int i = 0; i < numOperatorStates; i++) { operatorStateMetaInfoSnapshots.add( stateMetaInfoReader.readStateMetaInfoSnapshot(in, userCodeClassLoader)); } if (proxyReadVersion >= 3) { // broadcast states did not exist prior to version 3 int numBroadcastStates = in.readShort(); broadcastStateMetaInfoSnapshots = new ArrayList<>(numBroadcastStates); for (int i = 0; i < numBroadcastStates; i++) { broadcastStateMetaInfoSnapshots.add( stateMetaInfoReader.readStateMetaInfoSnapshot(in, userCodeClassLoader)); } } else { broadcastStateMetaInfoSnapshots = new ArrayList<>(); } }
@Override public void read(DataInputView in) throws IOException { super.read(in); int numOperatorStates = in.readShort(); operatorStateMetaInfoSnapshots = new ArrayList<>(numOperatorStates); for (int i = 0; i < numOperatorStates; i++) { operatorStateMetaInfoSnapshots.add( OperatorBackendStateMetaInfoSnapshotReaderWriters .getOperatorStateReaderForVersion(getReadVersion(), userCodeClassLoader) .readOperatorStateMetaInfo(in)); } if (getReadVersion() >= 3) { // broadcast states did not exist prior to version 3 int numBroadcastStates = in.readShort(); broadcastStateMetaInfoSnapshots = new ArrayList<>(numBroadcastStates); for (int i = 0; i < numBroadcastStates; i++) { broadcastStateMetaInfoSnapshots.add( OperatorBackendStateMetaInfoSnapshotReaderWriters .getBroadcastStateReaderForVersion(getReadVersion(), userCodeClassLoader) .readBroadcastStateMetaInfo(in)); } } else { broadcastStateMetaInfoSnapshots = new ArrayList<>(); } }
@SuppressWarnings("unchecked") @Override public void read(DataInputView in) throws IOException { super.read(in); // only starting from version 3, we have the key serializer and its config snapshot written if (getReadVersion() >= 3) { Tuple2<TypeSerializer<?>, TypeSerializerConfigSnapshot> keySerializerAndConfig = TypeSerializerSerializationUtil.readSerializersAndConfigsWithResilience(in, userCodeClassLoader).get(0); this.keySerializer = (TypeSerializer<K>) keySerializerAndConfig.f0; this.keySerializerConfigSnapshot = keySerializerAndConfig.f1; } else { this.keySerializer = TypeSerializerSerializationUtil.tryReadSerializer(in, userCodeClassLoader); this.keySerializerConfigSnapshot = null; } int numKvStates = in.readShort(); stateMetaInfoSnapshots = new ArrayList<>(numKvStates); for (int i = 0; i < numKvStates; i++) { stateMetaInfoSnapshots.add( KeyedBackendStateMetaInfoSnapshotReaderWriters .getReaderForVersion(getReadVersion(), userCodeClassLoader) .readStateMetaInfo(in)); } } }
@SuppressWarnings("unchecked") @Override public void read(DataInputView in) throws IOException { super.read(in);
@SuppressWarnings("unchecked") @Override public void read(DataInputView in) throws IOException { super.read(in);
@SuppressWarnings("unchecked") @Override public void read(DataInputView in) throws IOException { super.read(in);