Java Code Examples for org.apache.flink.api.common.typeutils.TypeSerializerSchemaCompatibility#incompatible()
The following examples show how to use
org.apache.flink.api.common.typeutils.TypeSerializerSchemaCompatibility#incompatible() .
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: ArrayListSerializer.java From flink with Apache License 2.0 | 6 votes |
/** * We need to implement this method as a {@link TypeSerializerConfigSnapshot.SelfResolvingTypeSerializer} * because this serializer was previously returning a shared {@link CollectionSerializerConfigSnapshot} * as its snapshot. * * <p>When the {@link CollectionSerializerConfigSnapshot} is restored, it is incapable of redirecting * the compatibility check to {@link ArrayListSerializerSnapshot}, so we do it here. */ @Override public TypeSerializerSchemaCompatibility<ArrayList<T>> resolveSchemaCompatibilityViaRedirectingToNewSnapshotClass( TypeSerializerConfigSnapshot<ArrayList<T>> deprecatedConfigSnapshot) { if (deprecatedConfigSnapshot instanceof CollectionSerializerConfigSnapshot) { CollectionSerializerConfigSnapshot<ArrayList<T>, T> castedLegacySnapshot = (CollectionSerializerConfigSnapshot<ArrayList<T>, T>) deprecatedConfigSnapshot; ArrayListSerializerSnapshot<T> newSnapshot = new ArrayListSerializerSnapshot<>(); return CompositeTypeSerializerUtil.delegateCompatibilityCheckToNewSnapshot( this, newSnapshot, castedLegacySnapshot.getNestedSerializerSnapshots()); } return TypeSerializerSchemaCompatibility.incompatible(); }
Example 2
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 3
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 4
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 5
Source File: MessageTypeSerializer.java From stateful-functions with Apache License 2.0 | 5 votes |
@Override public TypeSerializerSchemaCompatibility<Message> resolveSchemaCompatibility( TypeSerializer<Message> typeSerializer) { if (!(typeSerializer instanceof MessageTypeSerializer)) { return TypeSerializerSchemaCompatibility.incompatible(); } MessageTypeSerializer casted = (MessageTypeSerializer) typeSerializer; if (casted.messageFactoryType == messageFactoryType) { return TypeSerializerSchemaCompatibility.compatibleAsIs(); } return TypeSerializerSchemaCompatibility.incompatible(); }
Example 6
Source File: SortedMapSerializerSnapshot.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeSerializerSchemaCompatibility<SortedMap<K, V>> resolveSchemaCompatibility( TypeSerializer<SortedMap<K, V>> newSerializer) { if (!(newSerializer instanceof SortedMapSerializer)) { return TypeSerializerSchemaCompatibility.incompatible(); } SortedMapSerializer newSortedMapSerializer = (SortedMapSerializer) newSerializer; if (!comparator.equals(newSortedMapSerializer.getComparator())) { return TypeSerializerSchemaCompatibility.incompatible(); } else { return TypeSerializerSchemaCompatibility.compatibleAsIs(); } }
Example 7
Source File: DecimalDataSerializer.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeSerializerSchemaCompatibility<DecimalData> resolveSchemaCompatibility(TypeSerializer<DecimalData> newSerializer) { if (!(newSerializer instanceof DecimalDataSerializer)) { return TypeSerializerSchemaCompatibility.incompatible(); } DecimalDataSerializer newDecimalDataSerializer = (DecimalDataSerializer) newSerializer; if (previousPrecision != newDecimalDataSerializer.precision || previousScale != newDecimalDataSerializer.scale) { return TypeSerializerSchemaCompatibility.incompatible(); } else { return TypeSerializerSchemaCompatibility.compatibleAsIs(); } }
Example 8
Source File: KryoSerializerSnapshot.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(TypeSerializer<T> newSerializer) { if (!(newSerializer instanceof KryoSerializer)) { return TypeSerializerSchemaCompatibility.incompatible(); } KryoSerializer<T> kryoSerializer = (KryoSerializer<T>) newSerializer; if (kryoSerializer.getType() != snapshotData.getTypeClass()) { return TypeSerializerSchemaCompatibility.incompatible(); } return resolveSchemaCompatibility(kryoSerializer); }
Example 9
Source File: AvroSerializerSnapshot.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(TypeSerializer<T> newSerializer) { if (!(newSerializer instanceof AvroSerializer)) { return TypeSerializerSchemaCompatibility.incompatible(); } AvroSerializer<?> newAvroSerializer = (AvroSerializer<?>) newSerializer; return resolveSchemaCompatibility(schema, newAvroSerializer.getAvroSchema()); }
Example 10
Source File: GenericArraySerializerConfigSnapshot.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeSerializerSchemaCompatibility<C[]> resolveSchemaCompatibility(TypeSerializer<C[]> newSerializer) { checkState(nestedSnapshot != null); if (!(newSerializer instanceof GenericArraySerializer)) { return TypeSerializerSchemaCompatibility.incompatible(); } // delegate to the new snapshot class return CompositeTypeSerializerUtil.delegateCompatibilityCheckToNewSnapshot( newSerializer, new GenericArraySerializerSnapshot<>(componentClass), nestedSnapshot.getNestedSerializerSnapshots()); }
Example 11
Source File: DecimalDataSerializer.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeSerializerSchemaCompatibility<DecimalData> resolveSchemaCompatibility(TypeSerializer<DecimalData> newSerializer) { if (!(newSerializer instanceof DecimalDataSerializer)) { return TypeSerializerSchemaCompatibility.incompatible(); } DecimalDataSerializer newDecimalDataSerializer = (DecimalDataSerializer) newSerializer; if (previousPrecision != newDecimalDataSerializer.precision || previousScale != newDecimalDataSerializer.scale) { return TypeSerializerSchemaCompatibility.incompatible(); } else { return TypeSerializerSchemaCompatibility.compatibleAsIs(); } }
Example 12
Source File: MessageTypeSerializer.java From flink-statefun with Apache License 2.0 | 5 votes |
@Override public TypeSerializerSchemaCompatibility<Message> resolveSchemaCompatibility( TypeSerializer<Message> typeSerializer) { if (!(typeSerializer instanceof MessageTypeSerializer)) { return TypeSerializerSchemaCompatibility.incompatible(); } MessageTypeSerializer casted = (MessageTypeSerializer) typeSerializer; if (casted.messageFactoryType == messageFactoryType) { return TypeSerializerSchemaCompatibility.compatibleAsIs(); } return TypeSerializerSchemaCompatibility.incompatible(); }
Example 13
Source File: ProtobufTypeSerializerSnapshot.java From flink-statefun with Apache License 2.0 | 5 votes |
@Override public TypeSerializerSchemaCompatibility<M> resolveSchemaCompatibility( TypeSerializer<M> newSerializer) { if (!(newSerializer instanceof ProtobufTypeSerializer)) { return TypeSerializerSchemaCompatibility.incompatible(); } ProtobufTypeSerializer<?> casted = (ProtobufTypeSerializer<?>) newSerializer; return resolveSchemaCompatibility(casted); }
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: AvroSerializerSnapshot.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(TypeSerializer<T> newSerializer) { if (!(newSerializer instanceof AvroSerializer)) { return TypeSerializerSchemaCompatibility.incompatible(); } AvroSerializer<?> newAvroSerializer = (AvroSerializer<?>) newSerializer; return resolveSchemaCompatibility(schema, newAvroSerializer.getAvroSchema()); }
Example 16
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 17
Source File: SchemaCompatibilityTestingSerializer.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public static SchemaCompatibilityTestingSnapshot thatIsIncompatibleWithTheNextSerializer(String tokenForEqualityChecks) { return new SchemaCompatibilityTestingSnapshot(tokenForEqualityChecks, unused -> TypeSerializerSchemaCompatibility.incompatible()); }
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: 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(); }
Example 20
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(); }