Java Code Examples for org.apache.flink.api.common.typeutils.TypeSerializerSerializationUtil#readSerializersAndConfigsWithResilience()

The following examples show how to use org.apache.flink.api.common.typeutils.TypeSerializerSerializationUtil#readSerializersAndConfigsWithResilience() . 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: LegacyStateMetaInfoReaders.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public StateMetaInfoSnapshot readStateMetaInfoSnapshot(
	@Nonnull DataInputView in, @Nonnull ClassLoader userCodeClassLoader) throws IOException {

	final StateDescriptor.Type stateDescType = StateDescriptor.Type.values()[in.readInt()];
	final String stateName = in.readUTF();
	List<Tuple2<TypeSerializer<?>, TypeSerializerSnapshot<?>>> serializersAndConfigs =
		TypeSerializerSerializationUtil.readSerializersAndConfigsWithResilience(in, userCodeClassLoader);

	Map<String, String> optionsMap = Collections.singletonMap(
		StateMetaInfoSnapshot.CommonOptionsKeys.KEYED_STATE_TYPE.toString(),
		stateDescType.toString());

	Map<String, TypeSerializerSnapshot<?>> serializerConfigSnapshotMap = new HashMap<>(2);
	serializerConfigSnapshotMap.put(StateMetaInfoSnapshot.CommonSerializerKeys.NAMESPACE_SERIALIZER.toString(),
		serializersAndConfigs.get(0).f1);
	serializerConfigSnapshotMap.put(StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER.toString(),
		serializersAndConfigs.get(1).f1);

	return new StateMetaInfoSnapshot(
		stateName,
		StateMetaInfoSnapshot.BackendStateType.KEY_VALUE,
		optionsMap,
		serializerConfigSnapshotMap);
}
 
Example 2
Source File: LegacyStateMetaInfoReaders.java    From flink with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public StateMetaInfoSnapshot readStateMetaInfoSnapshot(
	@Nonnull DataInputView in, @Nonnull ClassLoader userCodeClassLoader) throws IOException {

	final StateDescriptor.Type stateDescType = StateDescriptor.Type.values()[in.readInt()];
	final String stateName = in.readUTF();
	List<Tuple2<TypeSerializer<?>, TypeSerializerSnapshot<?>>> serializersAndConfigs =
		TypeSerializerSerializationUtil.readSerializersAndConfigsWithResilience(in, userCodeClassLoader);

	Map<String, String> optionsMap = Collections.singletonMap(
		StateMetaInfoSnapshot.CommonOptionsKeys.KEYED_STATE_TYPE.toString(),
		stateDescType.toString());

	Map<String, TypeSerializerSnapshot<?>> serializerConfigSnapshotMap = new HashMap<>(2);
	serializerConfigSnapshotMap.put(StateMetaInfoSnapshot.CommonSerializerKeys.NAMESPACE_SERIALIZER.toString(),
		serializersAndConfigs.get(0).f1);
	serializerConfigSnapshotMap.put(StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER.toString(),
		serializersAndConfigs.get(1).f1);

	return new StateMetaInfoSnapshot(
		stateName,
		StateMetaInfoSnapshot.BackendStateType.KEY_VALUE,
		optionsMap,
		serializerConfigSnapshotMap);
}
 
Example 3
Source File: LegacyStateMetaInfoReaders.java    From flink with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public StateMetaInfoSnapshot readStateMetaInfoSnapshot(
	@Nonnull DataInputView in, @Nonnull ClassLoader userCodeClassLoader) throws IOException {

	final StateDescriptor.Type stateDescType = StateDescriptor.Type.values()[in.readInt()];
	final String stateName = in.readUTF();
	List<Tuple2<TypeSerializer<?>, TypeSerializerSnapshot<?>>> serializersAndConfigs =
		TypeSerializerSerializationUtil.readSerializersAndConfigsWithResilience(in, userCodeClassLoader);

	Map<String, String> optionsMap = Collections.singletonMap(
		StateMetaInfoSnapshot.CommonOptionsKeys.KEYED_STATE_TYPE.toString(),
		stateDescType.toString());

	Map<String, TypeSerializerSnapshot<?>> serializerConfigSnapshotMap = new HashMap<>(2);
	serializerConfigSnapshotMap.put(StateMetaInfoSnapshot.CommonSerializerKeys.NAMESPACE_SERIALIZER.toString(),
		serializersAndConfigs.get(0).f1);
	serializerConfigSnapshotMap.put(StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER.toString(),
		serializersAndConfigs.get(1).f1);

	return new StateMetaInfoSnapshot(
		stateName,
		StateMetaInfoSnapshot.BackendStateType.KEY_VALUE,
		optionsMap,
		serializerConfigSnapshotMap);
}
 
Example 4
Source File: InternalTimersSnapshotReaderWriters.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected void restoreKeyAndNamespaceSerializers(
		InternalTimersSnapshot<K, N> restoredTimersSnapshot,
		DataInputView in) throws IOException {

	List<Tuple2<TypeSerializer<?>, TypeSerializerSnapshot<?>>> serializersAndConfigs =
		TypeSerializerSerializationUtil.readSerializersAndConfigsWithResilience(in, userCodeClassLoader);

	restoredTimersSnapshot.setKeySerializerSnapshot((TypeSerializerSnapshot<K>) serializersAndConfigs.get(0).f1);
	restoredTimersSnapshot.setNamespaceSerializerSnapshot((TypeSerializerSnapshot<N>) serializersAndConfigs.get(1).f1);
}
 
Example 5
Source File: InternalTimersSnapshotReaderWriters.java    From flink with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected void restoreKeyAndNamespaceSerializers(
		InternalTimersSnapshot<K, N> restoredTimersSnapshot,
		DataInputView in) throws IOException {

	List<Tuple2<TypeSerializer<?>, TypeSerializerSnapshot<?>>> serializersAndConfigs =
		TypeSerializerSerializationUtil.readSerializersAndConfigsWithResilience(in, userCodeClassLoader);

	restoredTimersSnapshot.setKeySerializerSnapshot((TypeSerializerSnapshot<K>) serializersAndConfigs.get(0).f1);
	restoredTimersSnapshot.setNamespaceSerializerSnapshot((TypeSerializerSnapshot<N>) serializersAndConfigs.get(1).f1);
}
 
Example 6
Source File: InternalTimersSnapshotReaderWriters.java    From flink with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected void restoreKeyAndNamespaceSerializers(
		InternalTimersSnapshot<K, N> restoredTimersSnapshot,
		DataInputView in) throws IOException {

	List<Tuple2<TypeSerializer<?>, TypeSerializerSnapshot<?>>> serializersAndConfigs =
		TypeSerializerSerializationUtil.readSerializersAndConfigsWithResilience(in, userCodeClassLoader);

	restoredTimersSnapshot.setKeySerializerSnapshot((TypeSerializerSnapshot<K>) serializersAndConfigs.get(0).f1);
	restoredTimersSnapshot.setNamespaceSerializerSnapshot((TypeSerializerSnapshot<N>) serializersAndConfigs.get(1).f1);
}
 
Example 7
Source File: LegacyStateMetaInfoReaders.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public StateMetaInfoSnapshot readStateMetaInfoSnapshot(
	@Nonnull DataInputView in,
	@Nonnull ClassLoader userCodeClassLoader) throws IOException {

	final String name = in.readUTF();
	final OperatorStateHandle.Mode mode = OperatorStateHandle.Mode.values()[in.readByte()];

	Map<String, String> optionsMap = Collections.singletonMap(
		StateMetaInfoSnapshot.CommonOptionsKeys.OPERATOR_STATE_DISTRIBUTION_MODE.toString(),
		mode.toString());

	List<Tuple2<TypeSerializer<?>, TypeSerializerSnapshot<?>>> stateSerializerAndConfigList =
		TypeSerializerSerializationUtil.readSerializersAndConfigsWithResilience(in, userCodeClassLoader);

	final int listSize = stateSerializerAndConfigList.size();
	StateMetaInfoSnapshot.BackendStateType stateType = listSize == 1 ?
		StateMetaInfoSnapshot.BackendStateType.OPERATOR : StateMetaInfoSnapshot.BackendStateType.BROADCAST;

	Map<String, TypeSerializerSnapshot<?>> serializerConfigsMap = new HashMap<>(listSize);
	switch (stateType) {
		case OPERATOR:
			serializerConfigsMap.put(
				StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER.toString(),
				stateSerializerAndConfigList.get(0).f1);
			break;
		case BROADCAST:
			serializerConfigsMap.put(
				StateMetaInfoSnapshot.CommonSerializerKeys.KEY_SERIALIZER.toString(),
				stateSerializerAndConfigList.get(0).f1);

			serializerConfigsMap.put(
				StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER.toString(),
				stateSerializerAndConfigList.get(1).f1);
			break;
		default:
			throw new IllegalStateException("Unknown operator state type " + stateType);
	}

	return new StateMetaInfoSnapshot(
		name,
		stateType,
		optionsMap,
		serializerConfigsMap);
}
 
Example 8
Source File: LegacyStateMetaInfoReaders.java    From flink with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public StateMetaInfoSnapshot readStateMetaInfoSnapshot(
	@Nonnull DataInputView in,
	@Nonnull ClassLoader userCodeClassLoader) throws IOException {

	final String name = in.readUTF();
	final OperatorStateHandle.Mode mode = OperatorStateHandle.Mode.values()[in.readByte()];

	Map<String, String> optionsMap = Collections.singletonMap(
		StateMetaInfoSnapshot.CommonOptionsKeys.OPERATOR_STATE_DISTRIBUTION_MODE.toString(),
		mode.toString());

	List<Tuple2<TypeSerializer<?>, TypeSerializerSnapshot<?>>> stateSerializerAndConfigList =
		TypeSerializerSerializationUtil.readSerializersAndConfigsWithResilience(in, userCodeClassLoader);

	final int listSize = stateSerializerAndConfigList.size();
	StateMetaInfoSnapshot.BackendStateType stateType = listSize == 1 ?
		StateMetaInfoSnapshot.BackendStateType.OPERATOR : StateMetaInfoSnapshot.BackendStateType.BROADCAST;

	Map<String, TypeSerializerSnapshot<?>> serializerConfigsMap = new HashMap<>(listSize);
	switch (stateType) {
		case OPERATOR:
			serializerConfigsMap.put(
				StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER.toString(),
				stateSerializerAndConfigList.get(0).f1);
			break;
		case BROADCAST:
			serializerConfigsMap.put(
				StateMetaInfoSnapshot.CommonSerializerKeys.KEY_SERIALIZER.toString(),
				stateSerializerAndConfigList.get(0).f1);

			serializerConfigsMap.put(
				StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER.toString(),
				stateSerializerAndConfigList.get(1).f1);
			break;
		default:
			throw new IllegalStateException("Unknown operator state type " + stateType);
	}

	return new StateMetaInfoSnapshot(
		name,
		stateType,
		optionsMap,
		serializerConfigsMap);
}
 
Example 9
Source File: LegacyStateMetaInfoReaders.java    From flink with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public StateMetaInfoSnapshot readStateMetaInfoSnapshot(
	@Nonnull DataInputView in,
	@Nonnull ClassLoader userCodeClassLoader) throws IOException {

	final String name = in.readUTF();
	final OperatorStateHandle.Mode mode = OperatorStateHandle.Mode.values()[in.readByte()];

	Map<String, String> optionsMap = Collections.singletonMap(
		StateMetaInfoSnapshot.CommonOptionsKeys.OPERATOR_STATE_DISTRIBUTION_MODE.toString(),
		mode.toString());

	List<Tuple2<TypeSerializer<?>, TypeSerializerSnapshot<?>>> stateSerializerAndConfigList =
		TypeSerializerSerializationUtil.readSerializersAndConfigsWithResilience(in, userCodeClassLoader);

	final int listSize = stateSerializerAndConfigList.size();
	StateMetaInfoSnapshot.BackendStateType stateType = listSize == 1 ?
		StateMetaInfoSnapshot.BackendStateType.OPERATOR : StateMetaInfoSnapshot.BackendStateType.BROADCAST;

	Map<String, TypeSerializerSnapshot<?>> serializerConfigsMap = new HashMap<>(listSize);
	switch (stateType) {
		case OPERATOR:
			serializerConfigsMap.put(
				StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER.toString(),
				stateSerializerAndConfigList.get(0).f1);
			break;
		case BROADCAST:
			serializerConfigsMap.put(
				StateMetaInfoSnapshot.CommonSerializerKeys.KEY_SERIALIZER.toString(),
				stateSerializerAndConfigList.get(0).f1);

			serializerConfigsMap.put(
				StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER.toString(),
				stateSerializerAndConfigList.get(1).f1);
			break;
		default:
			throw new IllegalStateException("Unknown operator state type " + stateType);
	}

	return new StateMetaInfoSnapshot(
		name,
		stateType,
		optionsMap,
		serializerConfigsMap);
}