Java Code Examples for org.apache.flink.api.common.typeutils.TypeSerializerSchemaCompatibility#compatibleWithReconfiguredSerializer()
The following examples show how to use
org.apache.flink.api.common.typeutils.TypeSerializerSchemaCompatibility#compatibleWithReconfiguredSerializer() .
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: V2TestTypeSerializerSnapshot.java From flink with Apache License 2.0 | 6 votes |
@Override public TypeSerializerSchemaCompatibility<TestType> resolveSchemaCompatibility(TypeSerializer<TestType> newSerializer) { if (newSerializer instanceof TestType.V2TestTypeSerializer) { return TypeSerializerSchemaCompatibility.compatibleAsIs(); } else if (newSerializer instanceof TestType.ReconfigurationRequiringTestTypeSerializer) { // we mimic the reconfiguration by just re-instantiating the correct serializer return TypeSerializerSchemaCompatibility.compatibleWithReconfiguredSerializer(new TestType.V2TestTypeSerializer()); } else if ( // migrating from V2 -> V1 is not supported newSerializer instanceof TestType.V1TestTypeSerializer || newSerializer instanceof TestType.IncompatibleTestTypeSerializer) { return TypeSerializerSchemaCompatibility.incompatible(); } else { throw new IllegalStateException("Unknown serializer class for TestType."); } }
Example 2
Source File: V2TestTypeSerializerSnapshot.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public TypeSerializerSchemaCompatibility<TestType> resolveSchemaCompatibility(TypeSerializer<TestType> newSerializer) { if (newSerializer instanceof TestType.V2TestTypeSerializer) { return TypeSerializerSchemaCompatibility.compatibleAsIs(); } else if (newSerializer instanceof TestType.ReconfigurationRequiringTestTypeSerializer) { // we mimic the reconfiguration by just re-instantiating the correct serializer return TypeSerializerSchemaCompatibility.compatibleWithReconfiguredSerializer(new TestType.V2TestTypeSerializer()); } else if ( // migrating from V2 -> V1 is not supported newSerializer instanceof TestType.V1TestTypeSerializer || newSerializer instanceof TestType.IncompatibleTestTypeSerializer) { return TypeSerializerSchemaCompatibility.incompatible(); } else { throw new IllegalStateException("Unknown serializer class for TestType."); } }
Example 3
Source File: BaseRowSerializer.java From flink with Apache License 2.0 | 6 votes |
@Override public TypeSerializerSchemaCompatibility<BaseRow> resolveSchemaCompatibility(TypeSerializer<BaseRow> newSerializer) { if (!(newSerializer instanceof BaseRowSerializer)) { return TypeSerializerSchemaCompatibility.incompatible(); } BaseRowSerializer newRowSerializer = (BaseRowSerializer) newSerializer; if (!Arrays.equals(previousTypes, newRowSerializer.types)) { return TypeSerializerSchemaCompatibility.incompatible(); } CompositeTypeSerializerUtil.IntermediateCompatibilityResult<BaseRow> intermediateResult = CompositeTypeSerializerUtil.constructIntermediateCompatibilityResult( newRowSerializer.fieldSerializers, nestedSerializersSnapshotDelegate.getNestedSerializerSnapshots() ); if (intermediateResult.isCompatibleWithReconfiguredSerializer()) { BaseRowSerializer reconfiguredCompositeSerializer = restoreSerializer(); return TypeSerializerSchemaCompatibility.compatibleWithReconfiguredSerializer( reconfiguredCompositeSerializer); } return intermediateResult.getFinalResult(); }
Example 4
Source File: KryoSerializerSnapshot.java From flink with Apache License 2.0 | 6 votes |
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 5
Source File: KryoSerializerSnapshot.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
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: V2TestTypeSerializerSnapshot.java From flink with Apache License 2.0 | 6 votes |
@Override public TypeSerializerSchemaCompatibility<TestType> resolveSchemaCompatibility(TypeSerializer<TestType> newSerializer) { if (newSerializer instanceof TestType.V2TestTypeSerializer) { return TypeSerializerSchemaCompatibility.compatibleAsIs(); } else if (newSerializer instanceof TestType.ReconfigurationRequiringTestTypeSerializer) { // we mimic the reconfiguration by just re-instantiating the correct serializer return TypeSerializerSchemaCompatibility.compatibleWithReconfiguredSerializer(new TestType.V2TestTypeSerializer()); } else if ( // migrating from V2 -> V1 is not supported newSerializer instanceof TestType.V1TestTypeSerializer || newSerializer instanceof TestType.IncompatibleTestTypeSerializer) { return TypeSerializerSchemaCompatibility.incompatible(); } else { throw new IllegalStateException("Unknown serializer class for TestType."); } }
Example 7
Source File: RowDataSerializer.java From flink with Apache License 2.0 | 6 votes |
@Override public TypeSerializerSchemaCompatibility<RowData> resolveSchemaCompatibility(TypeSerializer<RowData> newSerializer) { if (!(newSerializer instanceof RowDataSerializer)) { return TypeSerializerSchemaCompatibility.incompatible(); } RowDataSerializer newRowSerializer = (RowDataSerializer) newSerializer; if (!Arrays.equals(previousTypes, newRowSerializer.types)) { return TypeSerializerSchemaCompatibility.incompatible(); } CompositeTypeSerializerUtil.IntermediateCompatibilityResult<RowData> intermediateResult = CompositeTypeSerializerUtil.constructIntermediateCompatibilityResult( newRowSerializer.fieldSerializers, nestedSerializersSnapshotDelegate.getNestedSerializerSnapshots() ); if (intermediateResult.isCompatibleWithReconfiguredSerializer()) { RowDataSerializer reconfiguredCompositeSerializer = restoreSerializer(); return TypeSerializerSchemaCompatibility.compatibleWithReconfiguredSerializer( reconfiguredCompositeSerializer); } return intermediateResult.getFinalResult(); }
Example 8
Source File: RowDataSerializer.java From flink with Apache License 2.0 | 6 votes |
@Override public TypeSerializerSchemaCompatibility<RowData> resolveSchemaCompatibility(TypeSerializer<RowData> newSerializer) { if (!(newSerializer instanceof RowDataSerializer)) { return TypeSerializerSchemaCompatibility.incompatible(); } RowDataSerializer newRowSerializer = (RowDataSerializer) newSerializer; if (!Arrays.equals(previousTypes, newRowSerializer.fieldTypes)) { return TypeSerializerSchemaCompatibility.incompatible(); } CompositeTypeSerializerUtil.IntermediateCompatibilityResult<RowData> intermediateResult = CompositeTypeSerializerUtil.constructIntermediateCompatibilityResult( newRowSerializer.fieldSerializers, nestedSerializersSnapshotDelegate.getNestedSerializerSnapshots() ); if (intermediateResult.isCompatibleWithReconfiguredSerializer()) { RowDataSerializer reconfiguredCompositeSerializer = restoreSerializer(); return TypeSerializerSchemaCompatibility.compatibleWithReconfiguredSerializer( reconfiguredCompositeSerializer); } return intermediateResult.getFinalResult(); }
Example 9
Source File: KryoSerializerSnapshot.java From flink with Apache License 2.0 | 6 votes |
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 10
Source File: V1TestTypeSerializerSnapshot.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeSerializerSchemaCompatibility<TestType> resolveSchemaCompatibility(TypeSerializer<TestType> newSerializer) { if (newSerializer instanceof TestType.V1TestTypeSerializer) { return TypeSerializerSchemaCompatibility.compatibleAsIs(); } else if (newSerializer instanceof TestType.V2TestTypeSerializer) { return TypeSerializerSchemaCompatibility.compatibleAfterMigration(); } else if (newSerializer instanceof TestType.ReconfigurationRequiringTestTypeSerializer) { // we mimic the reconfiguration by just re-instantiating the correct serializer return TypeSerializerSchemaCompatibility.compatibleWithReconfiguredSerializer(new TestType.V1TestTypeSerializer()); } else if (newSerializer instanceof TestType.IncompatibleTestTypeSerializer) { return TypeSerializerSchemaCompatibility.incompatible(); } else { throw new IllegalStateException("Unknown serializer class for TestType."); } }
Example 11
Source File: EnumSerializer.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(TypeSerializer<T> newSerializer) { if (!(newSerializer instanceof EnumSerializer)) { return TypeSerializerSchemaCompatibility.incompatible(); } EnumSerializer<T> newEnumSerializer = (EnumSerializer<T>) newSerializer; if (!enumClass.equals(newEnumSerializer.enumClass)) { return TypeSerializerSchemaCompatibility.incompatible(); } T[] currentEnums = enumClass.getEnumConstants(); if (Arrays.equals(previousEnums, currentEnums)) { return TypeSerializerSchemaCompatibility.compatibleAsIs(); } Set<T> reconfiguredEnumSet = new LinkedHashSet<>(Arrays.asList(previousEnums)); reconfiguredEnumSet.addAll(Arrays.asList(currentEnums)); @SuppressWarnings("unchecked") T[] reconfiguredEnums = reconfiguredEnumSet.toArray( (T[]) Array.newInstance(enumClass, reconfiguredEnumSet.size())); EnumSerializer<T> reconfiguredSerializer = new EnumSerializer<>( enumClass, reconfiguredEnums); return TypeSerializerSchemaCompatibility.compatibleWithReconfiguredSerializer( reconfiguredSerializer); }
Example 12
Source File: V1TestTypeSerializerSnapshot.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public TypeSerializerSchemaCompatibility<TestType> resolveSchemaCompatibility(TypeSerializer<TestType> newSerializer) { if (newSerializer instanceof TestType.V1TestTypeSerializer) { return TypeSerializerSchemaCompatibility.compatibleAsIs(); } else if (newSerializer instanceof TestType.V2TestTypeSerializer) { return TypeSerializerSchemaCompatibility.compatibleAfterMigration(); } else if (newSerializer instanceof TestType.ReconfigurationRequiringTestTypeSerializer) { // we mimic the reconfiguration by just re-instantiating the correct serializer return TypeSerializerSchemaCompatibility.compatibleWithReconfiguredSerializer(new TestType.V1TestTypeSerializer()); } else if (newSerializer instanceof TestType.IncompatibleTestTypeSerializer) { return TypeSerializerSchemaCompatibility.incompatible(); } else { throw new IllegalStateException("Unknown serializer class for TestType."); } }
Example 13
Source File: EnumSerializer.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(TypeSerializer<T> newSerializer) { if (!(newSerializer instanceof EnumSerializer)) { return TypeSerializerSchemaCompatibility.incompatible(); } EnumSerializer<T> newEnumSerializer = (EnumSerializer<T>) newSerializer; if (!enumClass.equals(newEnumSerializer.enumClass)) { return TypeSerializerSchemaCompatibility.incompatible(); } T[] currentEnums = enumClass.getEnumConstants(); if (Arrays.equals(previousEnums, currentEnums)) { return TypeSerializerSchemaCompatibility.compatibleAsIs(); } Set<T> reconfiguredEnumSet = new LinkedHashSet<>(Arrays.asList(previousEnums)); reconfiguredEnumSet.addAll(Arrays.asList(currentEnums)); @SuppressWarnings("unchecked") T[] reconfiguredEnums = reconfiguredEnumSet.toArray( (T[]) Array.newInstance(enumClass, reconfiguredEnumSet.size())); EnumSerializer<T> reconfiguredSerializer = new EnumSerializer<>( enumClass, reconfiguredEnums); return TypeSerializerSchemaCompatibility.compatibleWithReconfiguredSerializer( reconfiguredSerializer); }
Example 14
Source File: EnumSerializer.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(TypeSerializer<T> newSerializer) { if (!(newSerializer instanceof EnumSerializer)) { return TypeSerializerSchemaCompatibility.incompatible(); } EnumSerializer<T> newEnumSerializer = (EnumSerializer<T>) newSerializer; if (!enumClass.equals(newEnumSerializer.enumClass)) { return TypeSerializerSchemaCompatibility.incompatible(); } T[] currentEnums = enumClass.getEnumConstants(); if (Arrays.equals(previousEnums, currentEnums)) { return TypeSerializerSchemaCompatibility.compatibleAsIs(); } Set<T> reconfiguredEnumSet = new LinkedHashSet<>(Arrays.asList(previousEnums)); reconfiguredEnumSet.addAll(Arrays.asList(currentEnums)); @SuppressWarnings("unchecked") T[] reconfiguredEnums = reconfiguredEnumSet.toArray( (T[]) Array.newInstance(enumClass, reconfiguredEnumSet.size())); EnumSerializer<T> reconfiguredSerializer = new EnumSerializer<>( enumClass, reconfiguredEnums); return TypeSerializerSchemaCompatibility.compatibleWithReconfiguredSerializer( reconfiguredSerializer); }
Example 15
Source File: V1TestTypeSerializerSnapshot.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeSerializerSchemaCompatibility<TestType> resolveSchemaCompatibility(TypeSerializer<TestType> newSerializer) { if (newSerializer instanceof TestType.V1TestTypeSerializer) { return TypeSerializerSchemaCompatibility.compatibleAsIs(); } else if (newSerializer instanceof TestType.V2TestTypeSerializer) { return TypeSerializerSchemaCompatibility.compatibleAfterMigration(); } else if (newSerializer instanceof TestType.ReconfigurationRequiringTestTypeSerializer) { // we mimic the reconfiguration by just re-instantiating the correct serializer return TypeSerializerSchemaCompatibility.compatibleWithReconfiguredSerializer(new TestType.V1TestTypeSerializer()); } else if (newSerializer instanceof TestType.IncompatibleTestTypeSerializer) { return TypeSerializerSchemaCompatibility.incompatible(); } else { throw new IllegalStateException("Unknown serializer class for TestType."); } }
Example 16
Source File: SchemaCompatibilityTestingSerializer.java From flink with Apache License 2.0 | 4 votes |
public static SchemaCompatibilityTestingSnapshot thatIsCompatibleWithNextSerializerAfterReconfiguration(String tokenForEqualityChecks) { SchemaCompatibilityTestingSerializer reconfiguredSerializer = new SchemaCompatibilityTestingSerializer(tokenForEqualityChecks, ALWAYS_COMPATIBLE); return new SchemaCompatibilityTestingSnapshot(tokenForEqualityChecks, unused -> TypeSerializerSchemaCompatibility.compatibleWithReconfiguredSerializer(reconfiguredSerializer)); }
Example 17
Source File: PojoSerializerSnapshot.java From flink with Apache License 2.0 | 4 votes |
@Override public TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(TypeSerializer<T> newSerializer) { if (newSerializer.getClass() != PojoSerializer.class) { return TypeSerializerSchemaCompatibility.incompatible(); } final PojoSerializer<T> newPojoSerializer = (PojoSerializer<T>) newSerializer; final Class<T> previousPojoClass = snapshotData.getPojoClass(); final LinkedOptionalMap<Field, TypeSerializerSnapshot<?>> fieldSerializerSnapshots = snapshotData.getFieldSerializerSnapshots(); final LinkedOptionalMap<Class<?>, TypeSerializerSnapshot<?>> registeredSubclassSerializerSnapshots = snapshotData.getRegisteredSubclassSerializerSnapshots(); final LinkedOptionalMap<Class<?>, TypeSerializerSnapshot<?>> nonRegisteredSubclassSerializerSnapshots = snapshotData.getNonRegisteredSubclassSerializerSnapshots(); if (previousPojoClass != newPojoSerializer.getPojoClass()) { return TypeSerializerSchemaCompatibility.incompatible(); } if (registeredSubclassSerializerSnapshots.hasAbsentKeysOrValues()) { return TypeSerializerSchemaCompatibility.incompatible(); } if (nonRegisteredSubclassSerializerSnapshots.hasAbsentKeysOrValues()) { return TypeSerializerSchemaCompatibility.incompatible(); } final IntermediateCompatibilityResult<T> preExistingFieldSerializersCompatibility = getCompatibilityOfPreExistingFields(newPojoSerializer, fieldSerializerSnapshots); if (preExistingFieldSerializersCompatibility.isIncompatible()) { return TypeSerializerSchemaCompatibility.incompatible(); } final IntermediateCompatibilityResult<T> preExistingRegistrationsCompatibility = getCompatibilityOfPreExistingRegisteredSubclasses(newPojoSerializer, registeredSubclassSerializerSnapshots); if (preExistingRegistrationsCompatibility.isIncompatible()) { return TypeSerializerSchemaCompatibility.incompatible(); } if (newPojoSerializerIsCompatibleAfterMigration( newPojoSerializer, preExistingFieldSerializersCompatibility, preExistingRegistrationsCompatibility, fieldSerializerSnapshots)) { return TypeSerializerSchemaCompatibility.compatibleAfterMigration(); } if (newPojoSerializerIsCompatibleWithReconfiguredSerializer( newPojoSerializer, preExistingFieldSerializersCompatibility, preExistingRegistrationsCompatibility, registeredSubclassSerializerSnapshots, nonRegisteredSubclassSerializerSnapshots)) { return TypeSerializerSchemaCompatibility.compatibleWithReconfiguredSerializer( constructReconfiguredPojoSerializer( newPojoSerializer, preExistingFieldSerializersCompatibility, registeredSubclassSerializerSnapshots, preExistingRegistrationsCompatibility, nonRegisteredSubclassSerializerSnapshots)); } return TypeSerializerSchemaCompatibility.compatibleAsIs(); }
Example 18
Source File: PojoSerializerSnapshot.java From flink with Apache License 2.0 | 4 votes |
@Override public TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(TypeSerializer<T> newSerializer) { if (newSerializer.getClass() != PojoSerializer.class) { return TypeSerializerSchemaCompatibility.incompatible(); } final PojoSerializer<T> newPojoSerializer = (PojoSerializer<T>) newSerializer; final Class<T> previousPojoClass = snapshotData.getPojoClass(); final LinkedOptionalMap<Field, TypeSerializerSnapshot<?>> fieldSerializerSnapshots = snapshotData.getFieldSerializerSnapshots(); final LinkedOptionalMap<Class<?>, TypeSerializerSnapshot<?>> registeredSubclassSerializerSnapshots = snapshotData.getRegisteredSubclassSerializerSnapshots(); final LinkedOptionalMap<Class<?>, TypeSerializerSnapshot<?>> nonRegisteredSubclassSerializerSnapshots = snapshotData.getNonRegisteredSubclassSerializerSnapshots(); if (previousPojoClass != newPojoSerializer.getPojoClass()) { return TypeSerializerSchemaCompatibility.incompatible(); } if (registeredSubclassSerializerSnapshots.hasAbsentKeysOrValues()) { return TypeSerializerSchemaCompatibility.incompatible(); } if (nonRegisteredSubclassSerializerSnapshots.hasAbsentKeysOrValues()) { return TypeSerializerSchemaCompatibility.incompatible(); } final IntermediateCompatibilityResult<T> preExistingFieldSerializersCompatibility = getCompatibilityOfPreExistingFields(newPojoSerializer, fieldSerializerSnapshots); if (preExistingFieldSerializersCompatibility.isIncompatible()) { return TypeSerializerSchemaCompatibility.incompatible(); } final IntermediateCompatibilityResult<T> preExistingRegistrationsCompatibility = getCompatibilityOfPreExistingRegisteredSubclasses(newPojoSerializer, registeredSubclassSerializerSnapshots); if (preExistingRegistrationsCompatibility.isIncompatible()) { return TypeSerializerSchemaCompatibility.incompatible(); } if (newPojoSerializerIsCompatibleAfterMigration( newPojoSerializer, preExistingFieldSerializersCompatibility, preExistingRegistrationsCompatibility, fieldSerializerSnapshots)) { return TypeSerializerSchemaCompatibility.compatibleAfterMigration(); } if (newPojoSerializerIsCompatibleWithReconfiguredSerializer( newPojoSerializer, preExistingFieldSerializersCompatibility, preExistingRegistrationsCompatibility, registeredSubclassSerializerSnapshots, nonRegisteredSubclassSerializerSnapshots)) { return TypeSerializerSchemaCompatibility.compatibleWithReconfiguredSerializer( constructReconfiguredPojoSerializer( newPojoSerializer, preExistingFieldSerializersCompatibility, registeredSubclassSerializerSnapshots, preExistingRegistrationsCompatibility, nonRegisteredSubclassSerializerSnapshots)); } return TypeSerializerSchemaCompatibility.compatibleAsIs(); }
Example 19
Source File: SchemaCompatibilityTestingSerializer.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public static SchemaCompatibilityTestingSnapshot thatIsCompatibleWithNextSerializerAfterReconfiguration(String tokenForEqualityChecks) { SchemaCompatibilityTestingSerializer reconfiguredSerializer = new SchemaCompatibilityTestingSerializer(tokenForEqualityChecks, ALWAYS_COMPATIBLE); return new SchemaCompatibilityTestingSnapshot(tokenForEqualityChecks, unused -> TypeSerializerSchemaCompatibility.compatibleWithReconfiguredSerializer(reconfiguredSerializer)); }
Example 20
Source File: PojoSerializerSnapshot.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(TypeSerializer<T> newSerializer) { if (newSerializer.getClass() != PojoSerializer.class) { return TypeSerializerSchemaCompatibility.incompatible(); } final PojoSerializer<T> newPojoSerializer = (PojoSerializer<T>) newSerializer; final Class<T> previousPojoClass = snapshotData.getPojoClass(); final LinkedOptionalMap<Field, TypeSerializerSnapshot<?>> fieldSerializerSnapshots = snapshotData.getFieldSerializerSnapshots(); final LinkedOptionalMap<Class<?>, TypeSerializerSnapshot<?>> registeredSubclassSerializerSnapshots = snapshotData.getRegisteredSubclassSerializerSnapshots(); final LinkedOptionalMap<Class<?>, TypeSerializerSnapshot<?>> nonRegisteredSubclassSerializerSnapshots = snapshotData.getNonRegisteredSubclassSerializerSnapshots(); if (previousPojoClass != newPojoSerializer.getPojoClass()) { return TypeSerializerSchemaCompatibility.incompatible(); } if (registeredSubclassSerializerSnapshots.hasAbsentKeysOrValues()) { return TypeSerializerSchemaCompatibility.incompatible(); } if (nonRegisteredSubclassSerializerSnapshots.hasAbsentKeysOrValues()) { return TypeSerializerSchemaCompatibility.incompatible(); } final IntermediateCompatibilityResult<T> preExistingFieldSerializersCompatibility = getCompatibilityOfPreExistingFields(newPojoSerializer, fieldSerializerSnapshots); if (preExistingFieldSerializersCompatibility.isIncompatible()) { return TypeSerializerSchemaCompatibility.incompatible(); } final IntermediateCompatibilityResult<T> preExistingRegistrationsCompatibility = getCompatibilityOfPreExistingRegisteredSubclasses(newPojoSerializer, registeredSubclassSerializerSnapshots); if (preExistingRegistrationsCompatibility.isIncompatible()) { return TypeSerializerSchemaCompatibility.incompatible(); } if (newPojoSerializerIsCompatibleAfterMigration( newPojoSerializer, preExistingFieldSerializersCompatibility, preExistingRegistrationsCompatibility, fieldSerializerSnapshots)) { return TypeSerializerSchemaCompatibility.compatibleAfterMigration(); } if (newPojoSerializerIsCompatibleWithReconfiguredSerializer( newPojoSerializer, preExistingFieldSerializersCompatibility, preExistingRegistrationsCompatibility, registeredSubclassSerializerSnapshots, nonRegisteredSubclassSerializerSnapshots)) { return TypeSerializerSchemaCompatibility.compatibleWithReconfiguredSerializer( constructReconfiguredPojoSerializer( newPojoSerializer, preExistingFieldSerializersCompatibility, registeredSubclassSerializerSnapshots, preExistingRegistrationsCompatibility, nonRegisteredSubclassSerializerSnapshots)); } return TypeSerializerSchemaCompatibility.compatibleAsIs(); }