Search in sources :

Example 31 with MemoryStateBackend

use of org.apache.flink.runtime.state.memory.MemoryStateBackend in project flink by apache.

the class JobSnapshottingSettingsTest method testIsJavaSerializable.

/**
	 * Tests that the settings are actually serializable.
	 */
@Test
public void testIsJavaSerializable() throws Exception {
    JobSnapshottingSettings settings = new JobSnapshottingSettings(Arrays.asList(new JobVertexID(), new JobVertexID()), Arrays.asList(new JobVertexID(), new JobVertexID()), Arrays.asList(new JobVertexID(), new JobVertexID()), 1231231, 1231, 112, 12, ExternalizedCheckpointSettings.externalizeCheckpoints(true), new MemoryStateBackend(), false);
    JobSnapshottingSettings copy = CommonTestUtils.createCopySerializable(settings);
    assertEquals(settings.getVerticesToAcknowledge(), copy.getVerticesToAcknowledge());
    assertEquals(settings.getVerticesToConfirm(), copy.getVerticesToConfirm());
    assertEquals(settings.getVerticesToTrigger(), copy.getVerticesToTrigger());
    assertEquals(settings.getCheckpointInterval(), copy.getCheckpointInterval());
    assertEquals(settings.getCheckpointTimeout(), copy.getCheckpointTimeout());
    assertEquals(settings.getMinPauseBetweenCheckpoints(), copy.getMinPauseBetweenCheckpoints());
    assertEquals(settings.getMaxConcurrentCheckpoints(), copy.getMaxConcurrentCheckpoints());
    assertEquals(settings.getExternalizedCheckpointSettings().externalizeCheckpoints(), copy.getExternalizedCheckpointSettings().externalizeCheckpoints());
    assertEquals(settings.getExternalizedCheckpointSettings().deleteOnCancellation(), copy.getExternalizedCheckpointSettings().deleteOnCancellation());
    assertEquals(settings.isExactlyOnce(), copy.isExactlyOnce());
    assertNotNull(copy.getDefaultStateBackend());
    assertTrue(copy.getDefaultStateBackend().getClass() == MemoryStateBackend.class);
}
Also used : JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) MemoryStateBackend(org.apache.flink.runtime.state.memory.MemoryStateBackend) Test(org.junit.Test)

Example 32 with MemoryStateBackend

use of org.apache.flink.runtime.state.memory.MemoryStateBackend in project flink by apache.

the class ManualWindowSpeedITCase method testTumblingIngestionTimeWindowsWithRocksDBBackendWithLateness.

@Test
public void testTumblingIngestionTimeWindowsWithRocksDBBackendWithLateness() throws Exception {
    final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    env.setStreamTimeCharacteristic(TimeCharacteristic.IngestionTime);
    env.setParallelism(1);
    env.setStateBackend(new RocksDBStateBackend(new MemoryStateBackend()));
    env.addSource(new InfiniteTupleSource(10_000)).keyBy(0).timeWindow(Time.seconds(3)).allowedLateness(Time.seconds(1)).reduce(new ReduceFunction<Tuple2<String, Integer>>() {

        private static final long serialVersionUID = 1L;

        @Override
        public Tuple2<String, Integer> reduce(Tuple2<String, Integer> value1, Tuple2<String, Integer> value2) throws Exception {
            return Tuple2.of(value1.f0, value1.f1 + value2.f1);
        }
    }).filter(new FilterFunction<Tuple2<String, Integer>>() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean filter(Tuple2<String, Integer> value) throws Exception {
            return value.f0.startsWith("Tuple 0");
        }
    }).print();
    env.execute();
}
Also used : FilterFunction(org.apache.flink.api.common.functions.FilterFunction) RocksDBStateBackend(org.apache.flink.contrib.streaming.state.RocksDBStateBackend) MemoryStateBackend(org.apache.flink.runtime.state.memory.MemoryStateBackend) Tuple2(org.apache.flink.api.java.tuple.Tuple2) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) Test(org.junit.Test)

Example 33 with MemoryStateBackend

use of org.apache.flink.runtime.state.memory.MemoryStateBackend 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

MemoryStateBackend (org.apache.flink.runtime.state.memory.MemoryStateBackend)33 Test (org.junit.Test)24 JobID (org.apache.flink.api.common.JobID)16 DummyEnvironment (org.apache.flink.runtime.operators.testutils.DummyEnvironment)15 KvStateRegistry (org.apache.flink.runtime.query.KvStateRegistry)11 KeyGroupRange (org.apache.flink.runtime.state.KeyGroupRange)11 ValueStateDescriptor (org.apache.flink.api.common.state.ValueStateDescriptor)8 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)8 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)7 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)7 ByteBuf (io.netty.buffer.ByteBuf)6 RocksDBStateBackend (org.apache.flink.contrib.streaming.state.RocksDBStateBackend)6 AbstractStateBackend (org.apache.flink.runtime.state.AbstractStateBackend)6 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)5 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)5 IOException (java.io.IOException)4 ObjectOutputStream (java.io.ObjectOutputStream)4 HashMap (java.util.HashMap)4 TypeHint (org.apache.flink.api.common.typeinfo.TypeHint)4 FilterFunction (org.apache.flink.api.common.functions.FilterFunction)3