org.apache.flink.util.LinkedOptionalMap.MergeResult Java Examples

The following examples show how to use org.apache.flink.util.LinkedOptionalMap.MergeResult. 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: KryoSerializerSnapshot.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(
	MergeResult<Class<?>, SerializableSerializer<?>> reconfiguredDefaultKryoSerializers,
	MergeResult<Class<?>, Class<? extends Serializer<?>>> reconfiguredDefaultKryoSerializerClasses,
	MergeResult<String, KryoRegistration> reconfiguredRegistrations) {

	if (reconfiguredDefaultKryoSerializers.isOrderedSubset() &&
		reconfiguredDefaultKryoSerializerClasses.isOrderedSubset() &&
		reconfiguredRegistrations.isOrderedSubset()) {

		return TypeSerializerSchemaCompatibility.compatibleAsIs();
	}

	// reconfigure a new KryoSerializer
	KryoSerializer<T> reconfiguredSerializer = new KryoSerializer<>(
		snapshotData.getTypeClass(),
		reconfiguredDefaultKryoSerializers.getMerged(),
		reconfiguredDefaultKryoSerializerClasses.getMerged(),
		reconfiguredRegistrations.getMerged());

	return TypeSerializerSchemaCompatibility.compatibleWithReconfiguredSerializer(reconfiguredSerializer);
}
 
Example #2
Source File: LinkedOptionalMapTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void demoMergeResult() {
	LinkedOptionalMap<Class<?>, String> left = new LinkedOptionalMap<>();
	left.put("b", null, null);
	left.put("c", String.class, null);

	LinkedOptionalMap<Class<?>, String> right = new LinkedOptionalMap<>();
	right.put("b", String.class, "bbb");
	right.put("c", Void.class, "ccc");
	right.put("a", Boolean.class, "aaa");
	right.put("d", Long.class, "ddd");

	MergeResult<Class<?>, String> result = LinkedOptionalMap.mergeRightIntoLeft(left, right);

	assertThat(result.hasMissingKeys(), is(false));
	assertThat(result.isOrderedSubset(), is(true));
	assertThat(result.missingKeys(), is(empty()));

	LinkedHashMap<Class<?>, String> merged = result.getMerged();
	assertThat(merged.keySet(), contains(String.class, Void.class, Boolean.class, Long.class));
}
 
Example #3
Source File: KryoSerializerSnapshot.java    From flink with Apache License 2.0 6 votes vote down vote up
private TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(
	MergeResult<Class<?>, SerializableSerializer<?>> reconfiguredDefaultKryoSerializers,
	MergeResult<Class<?>, Class<? extends Serializer<?>>> reconfiguredDefaultKryoSerializerClasses,
	MergeResult<String, KryoRegistration> reconfiguredRegistrations) {

	if (reconfiguredDefaultKryoSerializers.isOrderedSubset() &&
		reconfiguredDefaultKryoSerializerClasses.isOrderedSubset() &&
		reconfiguredRegistrations.isOrderedSubset()) {

		return TypeSerializerSchemaCompatibility.compatibleAsIs();
	}

	// reconfigure a new KryoSerializer
	KryoSerializer<T> reconfiguredSerializer = new KryoSerializer<>(
		snapshotData.getTypeClass(),
		reconfiguredDefaultKryoSerializers.getMerged(),
		reconfiguredDefaultKryoSerializerClasses.getMerged(),
		reconfiguredRegistrations.getMerged());

	return TypeSerializerSchemaCompatibility.compatibleWithReconfiguredSerializer(reconfiguredSerializer);
}
 
Example #4
Source File: LinkedOptionalMapTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void demoMergeResult() {
	LinkedOptionalMap<Class<?>, String> left = new LinkedOptionalMap<>();
	left.put("b", null, null);
	left.put("c", String.class, null);

	LinkedOptionalMap<Class<?>, String> right = new LinkedOptionalMap<>();
	right.put("b", String.class, "bbb");
	right.put("c", Void.class, "ccc");
	right.put("a", Boolean.class, "aaa");
	right.put("d", Long.class, "ddd");

	MergeResult<Class<?>, String> result = LinkedOptionalMap.mergeRightIntoLeft(left, right);

	assertThat(result.hasMissingKeys(), is(false));
	assertThat(result.isOrderedSubset(), is(true));
	assertThat(result.missingKeys(), is(empty()));

	LinkedHashMap<Class<?>, String> merged = result.getMerged();
	assertThat(merged.keySet(), contains(String.class, Void.class, Boolean.class, Long.class));
}
 
Example #5
Source File: KryoSerializerSnapshot.java    From flink with Apache License 2.0 6 votes vote down vote up
private TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(
	MergeResult<Class<?>, SerializableSerializer<?>> reconfiguredDefaultKryoSerializers,
	MergeResult<Class<?>, Class<? extends Serializer<?>>> reconfiguredDefaultKryoSerializerClasses,
	MergeResult<String, KryoRegistration> reconfiguredRegistrations) {

	if (reconfiguredDefaultKryoSerializers.isOrderedSubset() &&
		reconfiguredDefaultKryoSerializerClasses.isOrderedSubset() &&
		reconfiguredRegistrations.isOrderedSubset()) {

		return TypeSerializerSchemaCompatibility.compatibleAsIs();
	}

	// reconfigure a new KryoSerializer
	KryoSerializer<T> reconfiguredSerializer = new KryoSerializer<>(
		snapshotData.getTypeClass(),
		reconfiguredDefaultKryoSerializers.getMerged(),
		reconfiguredDefaultKryoSerializerClasses.getMerged(),
		reconfiguredRegistrations.getMerged());

	return TypeSerializerSchemaCompatibility.compatibleWithReconfiguredSerializer(reconfiguredSerializer);
}
 
Example #6
Source File: LinkedOptionalMapTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void demoMergeResult() {
	LinkedOptionalMap<Class<?>, String> left = new LinkedOptionalMap<>();
	left.put("b", null, null);
	left.put("c", String.class, null);

	LinkedOptionalMap<Class<?>, String> right = new LinkedOptionalMap<>();
	right.put("b", String.class, "bbb");
	right.put("c", Void.class, "ccc");
	right.put("a", Boolean.class, "aaa");
	right.put("d", Long.class, "ddd");

	MergeResult<Class<?>, String> result = LinkedOptionalMap.mergeRightIntoLeft(left, right);

	assertThat(result.hasMissingKeys(), is(false));
	assertThat(result.isOrderedSubset(), is(true));
	assertThat(result.missingKeys(), is(empty()));

	LinkedHashMap<Class<?>, String> merged = result.getMerged();
	assertThat(merged.keySet(), contains(String.class, Void.class, Boolean.class, Long.class));
}
 
Example #7
Source File: KryoSerializerSnapshot.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(KryoSerializer<T> newSerializer) {
	// merge the default serializers
	final MergeResult<Class<?>, SerializableSerializer<?>> reconfiguredDefaultKryoSerializers = mergeRightIntoLeft(
		snapshotData.getDefaultKryoSerializers(),
		optionalMapOf(newSerializer.getDefaultKryoSerializers(), Class::getName));

	if (reconfiguredDefaultKryoSerializers.hasMissingKeys()) {
		logMissingKeys(reconfiguredDefaultKryoSerializers);
		return TypeSerializerSchemaCompatibility.incompatible();
	}

	// merge default serializer classes
	final MergeResult<Class<?>, Class<? extends Serializer<?>>> reconfiguredDefaultKryoSerializerClasses = mergeRightIntoLeft(
		snapshotData.getDefaultKryoSerializerClasses(),
		optionalMapOf(newSerializer.getDefaultKryoSerializerClasses(), Class::getName));

	if (reconfiguredDefaultKryoSerializerClasses.hasMissingKeys()) {
		logMissingKeys(reconfiguredDefaultKryoSerializerClasses);
		return TypeSerializerSchemaCompatibility.incompatible();
	}

	// merge registration
	final MergeResult<String, KryoRegistration> reconfiguredRegistrations = mergeRightIntoLeft(
		snapshotData.getKryoRegistrations(),
		optionalMapOf(newSerializer.getKryoRegistrations(), Function.identity()));

	if (reconfiguredRegistrations.hasMissingKeys()) {
		logMissingKeys(reconfiguredRegistrations);
		return TypeSerializerSchemaCompatibility.incompatible();
	}

	// there are no missing keys, now we have to decide whether we are compatible as-is or we require reconfiguration.
	return resolveSchemaCompatibility(
		reconfiguredDefaultKryoSerializers,
		reconfiguredDefaultKryoSerializerClasses,
		reconfiguredRegistrations);
}
 
Example #8
Source File: KryoSerializerSnapshot.java    From flink with Apache License 2.0 5 votes vote down vote up
private TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(KryoSerializer<T> newSerializer) {
	// merge the default serializers
	final MergeResult<Class<?>, SerializableSerializer<?>> reconfiguredDefaultKryoSerializers = mergeRightIntoLeft(
		snapshotData.getDefaultKryoSerializers(),
		optionalMapOf(newSerializer.getDefaultKryoSerializers(), Class::getName));

	if (reconfiguredDefaultKryoSerializers.hasMissingKeys()) {
		logMissingKeys(reconfiguredDefaultKryoSerializers);
		return TypeSerializerSchemaCompatibility.incompatible();
	}

	// merge default serializer classes
	final MergeResult<Class<?>, Class<? extends Serializer<?>>> reconfiguredDefaultKryoSerializerClasses = mergeRightIntoLeft(
		snapshotData.getDefaultKryoSerializerClasses(),
		optionalMapOf(newSerializer.getDefaultKryoSerializerClasses(), Class::getName));

	if (reconfiguredDefaultKryoSerializerClasses.hasMissingKeys()) {
		logMissingKeys(reconfiguredDefaultKryoSerializerClasses);
		return TypeSerializerSchemaCompatibility.incompatible();
	}

	// merge registration
	final MergeResult<String, KryoRegistration> reconfiguredRegistrations = mergeRightIntoLeft(
		snapshotData.getKryoRegistrations(),
		optionalMapOf(newSerializer.getKryoRegistrations(), Function.identity()));

	if (reconfiguredRegistrations.hasMissingKeys()) {
		logMissingKeys(reconfiguredRegistrations);
		return TypeSerializerSchemaCompatibility.incompatible();
	}

	// there are no missing keys, now we have to decide whether we are compatible as-is or we require reconfiguration.
	return resolveSchemaCompatibility(
		reconfiguredDefaultKryoSerializers,
		reconfiguredDefaultKryoSerializerClasses,
		reconfiguredRegistrations);
}
 
Example #9
Source File: KryoSerializerSnapshot.java    From flink with Apache License 2.0 5 votes vote down vote up
private TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(KryoSerializer<T> newSerializer) {
	// merge the default serializers
	final MergeResult<Class<?>, SerializableSerializer<?>> reconfiguredDefaultKryoSerializers = mergeRightIntoLeft(
		snapshotData.getDefaultKryoSerializers(),
		optionalMapOf(newSerializer.getDefaultKryoSerializers(), Class::getName));

	if (reconfiguredDefaultKryoSerializers.hasMissingKeys()) {
		logMissingKeys(reconfiguredDefaultKryoSerializers);
		return TypeSerializerSchemaCompatibility.incompatible();
	}

	// merge default serializer classes
	final MergeResult<Class<?>, Class<? extends Serializer<?>>> reconfiguredDefaultKryoSerializerClasses = mergeRightIntoLeft(
		snapshotData.getDefaultKryoSerializerClasses(),
		optionalMapOf(newSerializer.getDefaultKryoSerializerClasses(), Class::getName));

	if (reconfiguredDefaultKryoSerializerClasses.hasMissingKeys()) {
		logMissingKeys(reconfiguredDefaultKryoSerializerClasses);
		return TypeSerializerSchemaCompatibility.incompatible();
	}

	// merge registration
	final MergeResult<String, KryoRegistration> reconfiguredRegistrations = mergeRightIntoLeft(
		snapshotData.getKryoRegistrations(),
		optionalMapOf(newSerializer.getKryoRegistrations(), Function.identity()));

	if (reconfiguredRegistrations.hasMissingKeys()) {
		logMissingKeys(reconfiguredRegistrations);
		return TypeSerializerSchemaCompatibility.incompatible();
	}

	// there are no missing keys, now we have to decide whether we are compatible as-is or we require reconfiguration.
	return resolveSchemaCompatibility(
		reconfiguredDefaultKryoSerializers,
		reconfiguredDefaultKryoSerializerClasses,
		reconfiguredRegistrations);
}
 
Example #10
Source File: KryoSerializerSnapshot.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
private void logMissingKeys(MergeResult<?, ?> mergeResult) {
	mergeResult.missingKeys().forEach(key -> LOG.warn("The Kryo registration for a previously registered class {} does not have a " +
		"proper serializer, because its previous serializer cannot be loaded or is no " +
		"longer valid but a new serializer is not available", key));
}
 
Example #11
Source File: KryoSerializerSnapshot.java    From flink with Apache License 2.0 4 votes vote down vote up
private void logMissingKeys(MergeResult<?, ?> mergeResult) {
	mergeResult.missingKeys().forEach(key -> LOG.warn("The Kryo registration for a previously registered class {} does not have a " +
		"proper serializer, because its previous serializer cannot be loaded or is no " +
		"longer valid but a new serializer is not available", key));
}
 
Example #12
Source File: KryoSerializerSnapshot.java    From flink with Apache License 2.0 4 votes vote down vote up
private void logMissingKeys(MergeResult<?, ?> mergeResult) {
	mergeResult.missingKeys().forEach(key -> LOG.warn("The Kryo registration for a previously registered class {} does not have a " +
		"proper serializer, because its previous serializer cannot be loaded or is no " +
		"longer valid but a new serializer is not available", key));
}