@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(); }
@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(); }
@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(); }
@Override public boolean equals(Object obj) { return super.equals(obj) && kryoRegistrations.equals(((KryoSerializer.KryoSerializerConfigSnapshot) obj).getKryoRegistrations()); }
@Override public boolean equals(Object obj) { return super.equals(obj) && kryoRegistrations.equals(((KryoSerializer.KryoSerializerConfigSnapshot) obj).getKryoRegistrations()); }
@Override public boolean equals(Object obj) { return super.equals(obj) && kryoRegistrations.equals(((KryoSerializer.KryoSerializerConfigSnapshot) obj).getKryoRegistrations()); }