Search in sources :

Example 1 with JavaSerializer

use of com.esotericsoftware.kryo.serializers.JavaSerializer in project flink by apache.

the class StateDescriptorPassingTest method validateStateDescriptorConfigured.

// ------------------------------------------------------------------------
//  generic validation
// ------------------------------------------------------------------------
private void validateStateDescriptorConfigured(SingleOutputStreamOperator<?> result) {
    OneInputTransformation<?, ?> transform = (OneInputTransformation<?, ?>) result.getTransformation();
    WindowOperator<?, ?, ?, ?, ?> op = (WindowOperator<?, ?, ?, ?, ?>) transform.getOperator();
    StateDescriptor<?, ?> descr = op.getStateDescriptor();
    // this would be the first statement to fail if state descriptors were not properly initialized
    TypeSerializer<?> serializer = descr.getSerializer();
    assertTrue(serializer instanceof KryoSerializer);
    Kryo kryo = ((KryoSerializer<?>) serializer).getKryo();
    assertTrue("serializer registration was not properly passed on", kryo.getSerializer(File.class) instanceof JavaSerializer);
}
Also used : WindowOperator(org.apache.flink.streaming.runtime.operators.windowing.WindowOperator) OneInputTransformation(org.apache.flink.streaming.api.transformations.OneInputTransformation) JavaSerializer(com.esotericsoftware.kryo.serializers.JavaSerializer) Kryo(com.esotericsoftware.kryo.Kryo) KryoSerializer(org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer)

Example 2 with JavaSerializer

use of com.esotericsoftware.kryo.serializers.JavaSerializer in project flink by apache.

the class StateDescriptorPassingTest method validateListStateDescriptorConfigured.

private void validateListStateDescriptorConfigured(SingleOutputStreamOperator<?> result) {
    OneInputTransformation<?, ?> transform = (OneInputTransformation<?, ?>) result.getTransformation();
    WindowOperator<?, ?, ?, ?, ?> op = (WindowOperator<?, ?, ?, ?, ?>) transform.getOperator();
    StateDescriptor<?, ?> descr = op.getStateDescriptor();
    assertTrue(descr instanceof ListStateDescriptor);
    ListStateDescriptor<?> listDescr = (ListStateDescriptor<?>) descr;
    // this would be the first statement to fail if state descriptors were not properly initialized
    TypeSerializer<?> serializer = listDescr.getSerializer();
    assertTrue(serializer instanceof ListSerializer);
    TypeSerializer<?> elementSerializer = listDescr.getElementSerializer();
    assertTrue(elementSerializer instanceof KryoSerializer);
    Kryo kryo = ((KryoSerializer<?>) elementSerializer).getKryo();
    assertTrue("serializer registration was not properly passed on", kryo.getSerializer(File.class) instanceof JavaSerializer);
}
Also used : WindowOperator(org.apache.flink.streaming.runtime.operators.windowing.WindowOperator) ListSerializer(org.apache.flink.api.common.typeutils.base.ListSerializer) ListStateDescriptor(org.apache.flink.api.common.state.ListStateDescriptor) OneInputTransformation(org.apache.flink.streaming.api.transformations.OneInputTransformation) JavaSerializer(com.esotericsoftware.kryo.serializers.JavaSerializer) Kryo(com.esotericsoftware.kryo.Kryo) KryoSerializer(org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer)

Aggregations

Kryo (com.esotericsoftware.kryo.Kryo)2 JavaSerializer (com.esotericsoftware.kryo.serializers.JavaSerializer)2 KryoSerializer (org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer)2 OneInputTransformation (org.apache.flink.streaming.api.transformations.OneInputTransformation)2 WindowOperator (org.apache.flink.streaming.runtime.operators.windowing.WindowOperator)2 ListStateDescriptor (org.apache.flink.api.common.state.ListStateDescriptor)1 ListSerializer (org.apache.flink.api.common.typeutils.base.ListSerializer)1