@Override public CompatibilityResult<T> ensureCompatibility(TypeSerializerConfigSnapshot<?> configSnapshot) { if (configSnapshot instanceof CopyableValueSerializerConfigSnapshot && valueClass.equals(((CopyableValueSerializerConfigSnapshot<?>) configSnapshot).getTypeClass())) { return CompatibilityResult.compatible(); } else { return CompatibilityResult.requiresMigration(); } }
@Override public CompatibilityResult<T> ensureCompatibility(TypeSerializerConfigSnapshot<?> configSnapshot) { if (configSnapshot instanceof WritableSerializerConfigSnapshot && typeClass.equals(((WritableSerializerConfigSnapshot<?>) configSnapshot).getTypeClass())) { return CompatibilityResult.compatible(); } else { return CompatibilityResult.requiresMigration(); } }
@SuppressWarnings("unchecked") @Override public CompatibilityResult<T> ensureCompatibility(TypeSerializerConfigSnapshot<?> configSnapshot) { if (configSnapshot instanceof ValueSerializerConfigSnapshot) { final ValueSerializerConfigSnapshot<T> config = (ValueSerializerConfigSnapshot<T>) configSnapshot; if (type.equals(config.getTypeClass())) { // currently, simply checking the type of the value class is sufficient; // in the future, if there are more Kryo registrations, we should try to resolve that return CompatibilityResult.compatible(); } } return CompatibilityResult.requiresMigration(); }
@Override public CompatibilityResult<T> ensureCompatibility(TypeSerializerConfigSnapshot configSnapshot) { // We can not remove this method, as long as we support restoring into CompositeTypeSerializerConfigSnapshot. // Previously (pre 1.8), multiple composite serializers were using this class directly as their snapshot class. if (configSnapshot instanceof ConfigSnapshot) { List<Tuple2<TypeSerializer<?>, TypeSerializerConfigSnapshot>> previousSerializersAndConfigs = ((CompositeTypeSerializerConfigSnapshot) configSnapshot).getNestedSerializersAndConfigs(); if (previousSerializersAndConfigs.size() == fieldSerializers.length) { return ensureFieldCompatibility(previousSerializersAndConfigs); } } return CompatibilityResult.requiresMigration(); }
private CompatibilityResult<T> createMigrationCompatResult(TypeSerializer<Object>[] convertSerializers) { PrecomputedParameters precomputed = PrecomputedParameters.precompute(this.precomputed.immutableTargetType, convertSerializers); return CompatibilityResult.requiresMigration(createSerializerInstance(precomputed, convertSerializers)); }
} catch (IllegalArgumentException e) { return CompatibilityResult.requiresMigration(); return CompatibilityResult.requiresMigration(); return CompatibilityResult.requiresMigration();
@SuppressWarnings("unchecked") @Override public CompatibilityResult<T> ensureCompatibility(TypeSerializerConfigSnapshot<?> configSnapshot) { if (configSnapshot instanceof KryoSerializerConfigSnapshot) { final KryoSerializerConfigSnapshot<T> config = (KryoSerializerConfigSnapshot<T>) configSnapshot; if (type.equals(config.getTypeClass())) { LinkedHashMap<String, KryoRegistration> reconfiguredRegistrations = config.getKryoRegistrations(); // reconfigure by assuring that classes which were previously registered are registered // again in the exact same order; new class registrations will be appended. // this also overwrites any dummy placeholders that the restored old configuration has reconfiguredRegistrations.putAll(kryoRegistrations); // check if there is still any dummy placeholders even after reconfiguration; // if so, then this new Kryo serializer cannot read old data and is therefore incompatible for (Map.Entry<String, KryoRegistration> reconfiguredRegistrationEntry : reconfiguredRegistrations.entrySet()) { if (reconfiguredRegistrationEntry.getValue().isDummy()) { 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", reconfiguredRegistrationEntry.getKey()); return CompatibilityResult.requiresMigration(); } } // there's actually no way to tell if new Kryo serializers are compatible with // the previous ones they overwrite; we can only signal compatibility and hope for the best this.kryoRegistrations = reconfiguredRegistrations; return CompatibilityResult.compatible(); } } return CompatibilityResult.requiresMigration(); }
/** * @deprecated this is kept around for backwards compatibility. * Can only be removed when {@link ParameterlessTypeSerializerConfig} is removed. */ @Override @Deprecated public CompatibilityResult<T> ensureCompatibility(TypeSerializerConfigSnapshot<?> configSnapshot) { if (configSnapshot instanceof ParameterlessTypeSerializerConfig && isCompatibleSerializationFormatIdentifier( ((ParameterlessTypeSerializerConfig<?>) configSnapshot).getSerializationFormatIdentifier())) { return CompatibilityResult.compatible(); } else { return CompatibilityResult.requiresMigration(); } }
@Override public CompatibilityResult<Object> ensureCompatibility(TypeSerializerConfigSnapshot<?> configSnapshot) { return compatible ? CompatibilityResult.compatible() : CompatibilityResult.requiresMigration(); } }
public static <T> CompatibilityResult<T> resolveCompatibilityResult( TypeSerializerSnapshot<T> precedingSerializerConfigSnapshot, TypeSerializer<T> newSerializer) { TypeSerializerSchemaCompatibility<T> compatibility = precedingSerializerConfigSnapshot.resolveSchemaCompatibility(newSerializer); // everything except "compatible" maps to "requires migration". // at the entry point of the new-to-old-bridge (in the TypeSerializerConfigSnapshot), we // interpret "requiresMigration" as 'incompatible'. That is a precaution because // serializers could previously not specify the 'incompatible' case. return compatibility.isCompatibleAsIs() ? CompatibilityResult.compatible() : CompatibilityResult.requiresMigration(); } }
return CompatibilityResult.requiresMigration((TypeSerializer<T>) precedingSerializer); } else {
new TypeDeserializerAdapter<>(compatResult.getConvertDeserializer()); } else { return CompatibilityResult.requiresMigration(); return CompatibilityResult.compatible(); } else { return CompatibilityResult.requiresMigration( createSerializerInstance(tupleClass, convertFieldSerializers)); return CompatibilityResult.requiresMigration();
/** * This cannot be removed until {@link TypeSerializerConfigSnapshot} is no longer supported. */ @Override public CompatibilityResult<Lockable<E>> ensureCompatibility(TypeSerializerConfigSnapshot<?> configSnapshot) { // backwards compatibility path CompatibilityResult<E> inputCompatibilityResult = CompatibilityUtil.resolveCompatibilityResult( configSnapshot.restoreSerializer(), UnloadableDummyTypeSerializer.class, configSnapshot, elementSerializer); return (inputCompatibilityResult.isRequiresMigration()) ? CompatibilityResult.requiresMigration() : CompatibilityResult.compatible(); }
reorderedFieldSerializers[i] = (TypeSerializer<Object>) compatResult.getConvertDeserializer(); } else { return CompatibilityResult.requiresMigration(); return CompatibilityResult.requiresMigration(); return CompatibilityResult.requiresMigration(); rebuiltCache.put(previousCachedEntry.getKey(), cachedSerializer); } else { return CompatibilityResult.requiresMigration(); return CompatibilityResult.requiresMigration( new PojoSerializer<>( clazz, return CompatibilityResult.requiresMigration();
@SuppressWarnings("unchecked") private CompatibilityResult<T> ensureFieldCompatibility( List<Tuple2<TypeSerializer<?>, TypeSerializerConfigSnapshot>> previousSerializersAndConfigs) { TypeSerializer<Object>[] convertSerializers = new TypeSerializer[fieldSerializers.length]; boolean requiresMigration = false; for (int index = 0; index < previousSerializersAndConfigs.size(); index++) { CompatibilityResult<Object> compatResult = resolveFieldCompatibility(previousSerializersAndConfigs, index); if (compatResult.isRequiresMigration()) { requiresMigration = true; if (compatResult.getConvertDeserializer() != null) { convertSerializers[index] = new TypeDeserializerAdapter<>(compatResult.getConvertDeserializer()); } else { return CompatibilityResult.requiresMigration(); } } } return requiresMigration ? createMigrationCompatResult(convertSerializers) : CompatibilityResult.compatible(); }
if (eventCompatResult.getConvertDeserializer() != null && sharedBufCompatResult.getConvertDeserializer() != null) { return CompatibilityResult.requiresMigration( new NFASerializer<>( new TypeDeserializerAdapter<>(eventCompatResult.getConvertDeserializer()), return CompatibilityResult.requiresMigration();
&& valueCompatResult.getConvertDeserializer() != null && versionCompatResult.getConvertDeserializer() != null) { return CompatibilityResult.requiresMigration( new SharedBufferSerializer<>( new TypeDeserializerAdapter<>(keyCompatResult.getConvertDeserializer()), return CompatibilityResult.requiresMigration();
@Override public CompatibilityResult<T> ensureCompatibility(TypeSerializerConfigSnapshot configSnapshot) { if (configSnapshot instanceof ConfigSnapshot) { List<Tuple2<TypeSerializer<?>, TypeSerializerConfigSnapshot>> previousSerializersAndConfigs = ((CompositeTypeSerializerConfigSnapshot) configSnapshot).getNestedSerializersAndConfigs(); if (previousSerializersAndConfigs.size() == fieldSerializers.length) { return ensureFieldCompatibility(previousSerializersAndConfigs); } } return CompatibilityResult.requiresMigration(); }
@Override public CompatibilityResult<Decimal> ensureCompatibility(TypeSerializerConfigSnapshot configSnapshot) { if (configSnapshot instanceof ParameterlessTypeSerializerConfig && isCompatibleSerializationFormatIdentifier( ((ParameterlessTypeSerializerConfig) configSnapshot).getSerializationFormatIdentifier())) { return CompatibilityResult.compatible(); } else { return CompatibilityResult.requiresMigration(); } }
@Override public CompatibilityResult<T> ensureCompatibility(TypeSerializerConfigSnapshot<?> configSnapshot) { if (configSnapshot instanceof ParameterlessTypeSerializerConfig && isCompatibleSerializationFormatIdentifier( ((ParameterlessTypeSerializerConfig<?>) configSnapshot).getSerializationFormatIdentifier())) { return CompatibilityResult.compatible(); } else { return CompatibilityResult.requiresMigration(); } }