org.apache.flink.api.java.typeutils.runtime.kryo.KryoPojosForMigrationTests.Animal Java Examples
The following examples show how to use
org.apache.flink.api.java.typeutils.runtime.kryo.KryoPojosForMigrationTests.Animal.
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: KryoSerializerSnapshotTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * This method returns the bytes of a serialized {@link KryoSerializerSnapshot}, that contains a Kryo registration * of a class that does not exists in the current classpath. */ private static byte[] unLoadableSnapshotBytes() throws IOException { final ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); ClassLoader tempClassLoader = new URLClassLoader(new URL[0], KryoSerializerSnapshotTest.class.getClassLoader()); try { Thread.currentThread().setContextClassLoader(tempClassLoader); ExecutionConfig conf = registerClassThatIsNotInClassPath(tempClassLoader); KryoSerializer<Animal> previousSerializer = new KryoSerializer<>(Animal.class, conf); TypeSerializerSnapshot<Animal> previousSnapshot = previousSerializer.snapshotConfiguration(); DataOutputSerializer out = new DataOutputSerializer(4096); TypeSerializerSnapshot.writeVersionedSnapshot(out, previousSnapshot); return out.getCopyOfBuffer(); } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } }
Example #2
Source File: KryoSnapshotMigrationTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private static void add(List<Object[]> all, String name, Supplier<TypeSerializer<Animal>> supplier, TypeSerializerSchemaCompatibility<Animal> expected) { TestSpecification<Animal> flink16 = TestSpecification.<Animal>builder( MigrationVersion.v1_6 + " " + name, KryoSerializer.class, KryoSerializerSnapshot.class, MigrationVersion.v1_6) .withNewSerializerProvider(supplier, expected) .withSnapshotDataLocation("flink-1.6-" + name + "-snapshot") .withTestData("flink-1.6-" + name + "-data", 2); TestSpecification<Animal> flink17 = TestSpecification.<Animal>builder( MigrationVersion.v1_7 + " " + name, KryoSerializer.class, KryoSerializerSnapshot.class, MigrationVersion.v1_7) .withNewSerializerProvider(supplier, expected) .withSnapshotDataLocation("flink-1.7-" + name + "-snapshot") .withTestData("flink-1.7-" + name + "-data", 2); all.add(new Object[]{flink16}); all.add(new Object[]{flink17}); }
Example #3
Source File: KryoSerializerSnapshotTest.java From flink with Apache License 2.0 | 6 votes |
/** * This method returns the bytes of a serialized {@link KryoSerializerSnapshot}, that contains a Kryo registration * of a class that does not exists in the current classpath. */ private static byte[] unLoadableSnapshotBytes() throws IOException { final ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); final ClassLoaderUtils.ObjectAndClassLoader<Serializable> outsideClassLoading = ClassLoaderUtils.createSerializableObjectFromNewClassLoader(); try { Thread.currentThread().setContextClassLoader(outsideClassLoading.getClassLoader()); ExecutionConfig conf = new ExecutionConfig(); conf.registerKryoType(outsideClassLoading.getObject().getClass()); KryoSerializer<Animal> previousSerializer = new KryoSerializer<>(Animal.class, conf); TypeSerializerSnapshot<Animal> previousSnapshot = previousSerializer.snapshotConfiguration(); DataOutputSerializer out = new DataOutputSerializer(4096); TypeSerializerSnapshot.writeVersionedSnapshot(out, previousSnapshot); return out.getCopyOfBuffer(); } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } }
Example #4
Source File: KryoSerializerSnapshotTest.java From flink with Apache License 2.0 | 6 votes |
/** * This method returns the bytes of a serialized {@link KryoSerializerSnapshot}, that contains a Kryo registration * of a class that does not exists in the current classpath. */ private static byte[] unLoadableSnapshotBytes() throws IOException { final ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); final CommonTestUtils.ObjectAndClassLoader outsideClassLoading = CommonTestUtils.createObjectFromNewClassLoader(); try { Thread.currentThread().setContextClassLoader(outsideClassLoading.getClassLoader()); ExecutionConfig conf = new ExecutionConfig(); conf.registerKryoType(outsideClassLoading.getObject().getClass()); KryoSerializer<Animal> previousSerializer = new KryoSerializer<>(Animal.class, conf); TypeSerializerSnapshot<Animal> previousSnapshot = previousSerializer.snapshotConfiguration(); DataOutputSerializer out = new DataOutputSerializer(4096); TypeSerializerSnapshot.writeVersionedSnapshot(out, previousSnapshot); return out.getCopyOfBuffer(); } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } }
Example #5
Source File: KryoSnapshotMigrationTest.java From flink with Apache License 2.0 | 6 votes |
private static void add(List<Object[]> all, String name, Supplier<TypeSerializer<Animal>> supplier, TypeSerializerSchemaCompatibility<Animal> expected) { TestSpecification<Animal> flink16 = TestSpecification.<Animal>builder( MigrationVersion.v1_6 + " " + name, KryoSerializer.class, KryoSerializerSnapshot.class, MigrationVersion.v1_6) .withNewSerializerProvider(supplier, expected) .withSnapshotDataLocation("flink-1.6-" + name + "-snapshot") .withTestData("flink-1.6-" + name + "-data", 2); TestSpecification<Animal> flink17 = TestSpecification.<Animal>builder( MigrationVersion.v1_7 + " " + name, KryoSerializer.class, KryoSerializerSnapshot.class, MigrationVersion.v1_7) .withNewSerializerProvider(supplier, expected) .withSnapshotDataLocation("flink-1.7-" + name + "-snapshot") .withTestData("flink-1.7-" + name + "-data", 2); all.add(new Object[]{flink16}); all.add(new Object[]{flink17}); }
Example #6
Source File: KryoSerializerSnapshotTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void replacingKryoSerializersIsCompatibleAsIs() { oldConfig.registerKryoType(Animal.class); oldConfig.registerTypeWithKryoSerializer(Dog.class, DogKryoSerializer.class); newConfig.registerKryoType(Animal.class); newConfig.registerTypeWithKryoSerializer(Dog.class, DogV2KryoSerializer.class); // it is compatible as is, since Kryo does not expose compatibility API with KryoSerializers // so we can not know if DogKryoSerializer is compatible with DogV2KryoSerializer assertThat(resolveKryoCompatibility(oldConfig, newConfig), isCompatibleAsIs()); }
Example #7
Source File: KryoSerializerUpgradeTest.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeSerializer<Animal> createUpgradedSerializer() { ExecutionConfig executionConfig = new ExecutionConfig(); executionConfig.registerKryoType(DummyClassOne.class); executionConfig.registerTypeWithKryoSerializer( Dog.class, KryoPojosForMigrationTests.DogV2KryoSerializer.class); executionConfig.registerKryoType(DummyClassTwo.class); executionConfig.registerKryoType(Cat.class); executionConfig.registerTypeWithKryoSerializer( Parrot.class, KryoPojosForMigrationTests.ParrotKryoSerializer.class); return new KryoSerializer<>(Animal.class, executionConfig); }
Example #8
Source File: KryoSerializerUpgradeTest.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeSerializer<Animal> createPriorSerializer() { ExecutionConfig executionConfig = new ExecutionConfig(); executionConfig.registerTypeWithKryoSerializer( Dog.class, KryoPojosForMigrationTests.DogKryoSerializer.class); executionConfig.registerKryoType(Cat.class); executionConfig.registerTypeWithKryoSerializer( Parrot.class, KryoPojosForMigrationTests.ParrotKryoSerializer.class); return new KryoSerializer<>(Animal.class, executionConfig); }
Example #9
Source File: KryoSerializerUpgradeTest.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeSerializer<Animal> createUpgradedSerializer() { ExecutionConfig executionConfig = new ExecutionConfig(); executionConfig.registerKryoType(DummyClassOne.class); executionConfig.registerKryoType(Dog.class); executionConfig.registerKryoType(DummyClassTwo.class); executionConfig.registerKryoType(Cat.class); executionConfig.registerKryoType(Parrot.class); return new KryoSerializer<>(Animal.class, executionConfig); }
Example #10
Source File: KryoSerializerUpgradeTest.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeSerializer<Animal> createPriorSerializer() { ExecutionConfig executionConfig = new ExecutionConfig(); executionConfig.registerKryoType(Dog.class); executionConfig.registerKryoType(Cat.class); executionConfig.registerKryoType(Parrot.class); return new KryoSerializer<>(Animal.class, executionConfig); }
Example #11
Source File: KryoSerializerUpgradeTest.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeSerializer<Animal> createUpgradedSerializer() { ExecutionConfig executionConfig = new ExecutionConfig(); executionConfig.registerKryoType(DummyClassOne.class); executionConfig.registerTypeWithKryoSerializer( DummyClassTwo.class, DefaultSerializers.StringSerializer.class); return new KryoSerializer<>(Animal.class, executionConfig); }
Example #12
Source File: KryoSerializerSnapshotTest.java From flink with Apache License 2.0 | 5 votes |
private static TypeSerializerSchemaCompatibility<Animal> resolveKryoCompatibility(ExecutionConfig previous, ExecutionConfig current) { KryoSerializer<Animal> previousSerializer = new KryoSerializer<>(Animal.class, previous); TypeSerializerSnapshot<Animal> previousSnapshot = previousSerializer.snapshotConfiguration(); TypeSerializer<Animal> currentSerializer = new KryoSerializer<>(Animal.class, current); return previousSnapshot.resolveSchemaCompatibility(currentSerializer); }
Example #13
Source File: KryoSerializerSnapshotTest.java From flink with Apache License 2.0 | 5 votes |
private static TypeSerializerSnapshot<Animal> kryoSnapshotWithMissingClass() throws IOException { DataInputView in = new DataInputDeserializer(unLoadableSnapshotBytes()); return TypeSerializerSnapshot.readVersionedSnapshot( in, KryoSerializerSnapshotTest.class.getClassLoader()); }
Example #14
Source File: KryoSerializerSnapshotTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void tryingToRestoreWithNonExistingClassShouldBeIncompatible() throws IOException { TypeSerializerSnapshot<Animal> restoredSnapshot = kryoSnapshotWithMissingClass(); TypeSerializer<Animal> currentSerializer = new KryoSerializer<>(Animal.class, new ExecutionConfig()); assertThat(restoredSnapshot.resolveSchemaCompatibility(currentSerializer), isIncompatible()); }
Example #15
Source File: KryoSerializerSnapshotTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void replacingKryoSerializersIsCompatibleAsIs() { oldConfig.registerKryoType(Animal.class); oldConfig.registerTypeWithKryoSerializer(Dog.class, DogKryoSerializer.class); newConfig.registerKryoType(Animal.class); newConfig.registerTypeWithKryoSerializer(Dog.class, DogV2KryoSerializer.class); // it is compatible as is, since Kryo does not expose compatibility API with KryoSerializers // so we can not know if DogKryoSerializer is compatible with DogV2KryoSerializer assertThat(resolveKryoCompatibility(oldConfig, newConfig), isCompatibleAsIs()); }
Example #16
Source File: KryoSerializerSnapshotTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void addingTypesIsCompatibleAfterReconfiguration() { oldConfig.registerKryoType(Animal.class); newConfig.registerKryoType(Animal.class); newConfig.registerTypeWithKryoSerializer(Dog.class, DogKryoSerializer.class); assertThat(resolveKryoCompatibility(oldConfig, newConfig), isCompatibleWithReconfiguredSerializer()); }
Example #17
Source File: KryoSerializerSnapshotTest.java From flink with Apache License 2.0 | 5 votes |
private static TypeSerializerSchemaCompatibility<Animal> resolveKryoCompatibility(ExecutionConfig previous, ExecutionConfig current) { KryoSerializer<Animal> previousSerializer = new KryoSerializer<>(Animal.class, previous); TypeSerializerSnapshot<Animal> previousSnapshot = previousSerializer.snapshotConfiguration(); TypeSerializer<Animal> currentSerializer = new KryoSerializer<>(Animal.class, current); return previousSnapshot.resolveSchemaCompatibility(currentSerializer); }
Example #18
Source File: KryoSerializerSnapshotTest.java From flink with Apache License 2.0 | 5 votes |
private static TypeSerializerSnapshot<Animal> kryoSnapshotWithMissingClass() throws IOException { DataInputView in = new DataInputDeserializer(unLoadableSnapshotBytes()); return TypeSerializerSnapshot.readVersionedSnapshot( in, KryoSerializerSnapshotTest.class.getClassLoader()); }
Example #19
Source File: KryoSerializerSnapshotTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void tryingToRestoreWithNonExistingClassShouldBeIncompatible() throws IOException { TypeSerializerSnapshot<Animal> restoredSnapshot = kryoSnapshotWithMissingClass(); TypeSerializer<Animal> currentSerializer = new KryoSerializer<>(Animal.class, new ExecutionConfig()); assertThat(restoredSnapshot.resolveSchemaCompatibility(currentSerializer), isIncompatible()); }
Example #20
Source File: KryoSerializerSnapshotTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void replacingKryoSerializersIsCompatibleAsIs() { oldConfig.registerKryoType(Animal.class); oldConfig.registerTypeWithKryoSerializer(Dog.class, DogKryoSerializer.class); newConfig.registerKryoType(Animal.class); newConfig.registerTypeWithKryoSerializer(Dog.class, DogV2KryoSerializer.class); // it is compatible as is, since Kryo does not expose compatibility API with KryoSerializers // so we can not know if DogKryoSerializer is compatible with DogV2KryoSerializer assertThat(resolveKryoCompatibility(oldConfig, newConfig), isCompatibleAsIs()); }
Example #21
Source File: KryoSerializerSnapshotTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void addingTypesIsCompatibleAfterReconfiguration() { oldConfig.registerKryoType(Animal.class); newConfig.registerKryoType(Animal.class); newConfig.registerTypeWithKryoSerializer(Dog.class, DogKryoSerializer.class); assertThat(resolveKryoCompatibility(oldConfig, newConfig), isCompatibleWithReconfiguredSerializer()); }
Example #22
Source File: KryoSerializerSnapshotTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void addingTypesIsCompatibleAfterReconfiguration() { oldConfig.registerKryoType(Animal.class); newConfig.registerKryoType(Animal.class); newConfig.registerTypeWithKryoSerializer(Dog.class, DogKryoSerializer.class); assertThat(resolveKryoCompatibility(oldConfig, newConfig), isCompatibleWithReconfiguredSerializer()); }
Example #23
Source File: KryoSerializerSnapshotTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void tryingToRestoreWithNonExistingClassShouldBeIncompatible() throws IOException { TypeSerializerSnapshot<Animal> restoredSnapshot = kryoSnapshotWithMissingClass(); TypeSerializer<Animal> currentSerializer = new KryoSerializer<>(Animal.class, new ExecutionConfig()); assertThat(restoredSnapshot.resolveSchemaCompatibility(currentSerializer), isIncompatible()); }
Example #24
Source File: KryoSerializerSnapshotTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private static TypeSerializerSnapshot<Animal> kryoSnapshotWithMissingClass() throws IOException { DataInputView in = new DataInputDeserializer(unLoadableSnapshotBytes()); return TypeSerializerSnapshot.readVersionedSnapshot( in, KryoSerializerSnapshotTest.class.getClassLoader()); }
Example #25
Source File: KryoSerializerSnapshotTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private static TypeSerializerSchemaCompatibility<Animal> resolveKryoCompatibility(ExecutionConfig previous, ExecutionConfig current) { KryoSerializer<Animal> previousSerializer = new KryoSerializer<>(Animal.class, previous); TypeSerializerSnapshot<Animal> previousSnapshot = previousSerializer.snapshotConfiguration(); TypeSerializer<Animal> currentSerializer = new KryoSerializer<>(Animal.class, current); return previousSnapshot.resolveSchemaCompatibility(currentSerializer); }
Example #26
Source File: KryoSerializerUpgradeTest.java From flink with Apache License 2.0 | 4 votes |
@Override public Matcher<TypeSerializerSchemaCompatibility<Animal>> schemaCompatibilityMatcher(MigrationVersion version) { return hasSameCompatibilityAs(compatibleWithReconfiguredSerializer(new KryoSerializer<>( Animal.class, new ExecutionConfig()))); }
Example #27
Source File: KryoSnapshotMigrationTest.java From flink with Apache License 2.0 | 4 votes |
private static void add(List<Object[]> all, String name, Supplier<TypeSerializer<Animal>> supplier) { add(all, name, supplier, compatibleAsIs()); }
Example #28
Source File: KryoSerializerUpgradeTest.java From flink with Apache License 2.0 | 4 votes |
@Override public Matcher<Animal> testDataMatcher() { return is(new Dog("Hasso")); }
Example #29
Source File: KryoSerializerUpgradeTest.java From flink with Apache License 2.0 | 4 votes |
@Override public Animal createTestData() { return new Dog("Hasso"); }
Example #30
Source File: KryoSerializerUpgradeTest.java From flink with Apache License 2.0 | 4 votes |
@Override public Matcher<TypeSerializerSchemaCompatibility<Animal>> schemaCompatibilityMatcher(MigrationVersion version) { return hasSameCompatibilityAs(compatibleWithReconfiguredSerializer(new KryoSerializer<>( Animal.class, new ExecutionConfig()))); }