Search in sources :

Example 1 with SerializedPipelineOptions

use of org.apache.beam.runners.flink.translation.utils.SerializedPipelineOptions in project beam by apache.

the class PipelineOptionsTest method beforeTest.

@BeforeClass
public static void beforeTest() {
    options = PipelineOptionsFactory.fromArgs(args).as(MyOptions.class);
    serializedOptions = new SerializedPipelineOptions(options);
}
Also used : SerializedPipelineOptions(org.apache.beam.runners.flink.translation.utils.SerializedPipelineOptions) BeforeClass(org.junit.BeforeClass)

Example 2 with SerializedPipelineOptions

use of org.apache.beam.runners.flink.translation.utils.SerializedPipelineOptions in project beam by apache.

the class PipelineOptionsTest method testSerializingPipelineOptionsWithCustomUserType.

@Test
public void testSerializingPipelineOptionsWithCustomUserType() throws Exception {
    String expectedValue = "testValue";
    PipelineOptions options = PipelineOptionsFactory.fromArgs("--jacksonIncompatible=\"" + expectedValue + "\"").as(JacksonIncompatibleOptions.class);
    SerializedPipelineOptions context = new SerializedPipelineOptions(options);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (ObjectOutputStream outputStream = new ObjectOutputStream(baos)) {
        outputStream.writeObject(context);
    }
    try (ObjectInputStream inputStream = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) {
        SerializedPipelineOptions copy = (SerializedPipelineOptions) inputStream.readObject();
        assertEquals(expectedValue, copy.getPipelineOptions().as(JacksonIncompatibleOptions.class).getJacksonIncompatible().value);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) PipelineOptions(org.apache.beam.sdk.options.PipelineOptions) SerializedPipelineOptions(org.apache.beam.runners.flink.translation.utils.SerializedPipelineOptions) SerializedPipelineOptions(org.apache.beam.runners.flink.translation.utils.SerializedPipelineOptions) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Example 3 with SerializedPipelineOptions

use of org.apache.beam.runners.flink.translation.utils.SerializedPipelineOptions in project beam by apache.

the class PipelineOptionsTest method testIgnoredFieldSerialization.

@Test
public void testIgnoredFieldSerialization() {
    FlinkPipelineOptions options = PipelineOptionsFactory.as(FlinkPipelineOptions.class);
    options.setStateBackend(new MemoryStateBackend());
    FlinkPipelineOptions deserialized = new SerializedPipelineOptions(options).getPipelineOptions().as(FlinkPipelineOptions.class);
    assertNull(deserialized.getStateBackend());
}
Also used : MemoryStateBackend(org.apache.flink.runtime.state.memory.MemoryStateBackend) SerializedPipelineOptions(org.apache.beam.runners.flink.translation.utils.SerializedPipelineOptions) Test(org.junit.Test)

Aggregations

SerializedPipelineOptions (org.apache.beam.runners.flink.translation.utils.SerializedPipelineOptions)3 Test (org.junit.Test)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 PipelineOptions (org.apache.beam.sdk.options.PipelineOptions)1 MemoryStateBackend (org.apache.flink.runtime.state.memory.MemoryStateBackend)1 BeforeClass (org.junit.BeforeClass)1