Search in sources :

Example 1 with StreamConfig

use of org.apache.flink.streaming.api.graph.StreamConfig in project flink by apache.

the class StreamTaskTest method testCancellationNotBlockedOnLock.

@Test
public void testCancellationNotBlockedOnLock() throws Exception {
    SYNC_LATCH = new OneShotLatch();
    StreamConfig cfg = new StreamConfig(new Configuration());
    Task task = createTask(CancelLockingTask.class, cfg, new Configuration());
    // start the task and wait until it runs
    // execution state RUNNING is not enough, we need to wait until the stream task's run() method
    // is entered
    task.startTaskThread();
    SYNC_LATCH.await();
    // cancel the execution - this should lead to smooth shutdown
    task.cancelExecution();
    task.getExecutingThread().join();
    assertEquals(ExecutionState.CANCELED, task.getExecutionState());
}
Also used : Task(org.apache.flink.runtime.taskmanager.Task) Configuration(org.apache.flink.configuration.Configuration) OneShotLatch(org.apache.flink.core.testutils.OneShotLatch) StreamConfig(org.apache.flink.streaming.api.graph.StreamConfig) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with StreamConfig

use of org.apache.flink.streaming.api.graph.StreamConfig in project flink by apache.

the class StreamTaskTest method testCancellationFailsWithBlockingLock.

@Test
public void testCancellationFailsWithBlockingLock() throws Exception {
    SYNC_LATCH = new OneShotLatch();
    StreamConfig cfg = new StreamConfig(new Configuration());
    Task task = createTask(CancelFailingTask.class, cfg, new Configuration());
    // start the task and wait until it runs
    // execution state RUNNING is not enough, we need to wait until the stream task's run() method
    // is entered
    task.startTaskThread();
    SYNC_LATCH.await();
    // cancel the execution - this should lead to smooth shutdown
    task.cancelExecution();
    task.getExecutingThread().join();
    assertEquals(ExecutionState.CANCELED, task.getExecutionState());
}
Also used : Task(org.apache.flink.runtime.taskmanager.Task) Configuration(org.apache.flink.configuration.Configuration) OneShotLatch(org.apache.flink.core.testutils.OneShotLatch) StreamConfig(org.apache.flink.streaming.api.graph.StreamConfig) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with StreamConfig

use of org.apache.flink.streaming.api.graph.StreamConfig in project flink by apache.

the class BlockingCheckpointsTest method testBlockingNonInterruptibleCheckpoint.

@Test
public void testBlockingNonInterruptibleCheckpoint() throws Exception {
    Configuration taskConfig = new Configuration();
    StreamConfig cfg = new StreamConfig(taskConfig);
    cfg.setStreamOperator(new TestOperator());
    cfg.setStateBackend(new LockingStreamStateBackend());
    Task task = createTask(taskConfig);
    // start the task and wait until it is in "restore"
    task.startTaskThread();
    IN_CHECKPOINT_LATCH.await();
    // cancel the task and wait. unless cancellation properly closes
    // the streams, this will never terminate
    task.cancelExecution();
    task.getExecutingThread().join();
    assertEquals(ExecutionState.CANCELED, task.getExecutionState());
    assertNull(task.getFailureCause());
}
Also used : Task(org.apache.flink.runtime.taskmanager.Task) Configuration(org.apache.flink.configuration.Configuration) StreamConfig(org.apache.flink.streaming.api.graph.StreamConfig) Test(org.junit.Test)

Example 4 with StreamConfig

use of org.apache.flink.streaming.api.graph.StreamConfig in project flink by apache.

the class BoltWrapperTest method testMultipleOutputStreams.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testMultipleOutputStreams() throws Exception {
    final boolean rawOutType1 = super.r.nextBoolean();
    final boolean rawOutType2 = super.r.nextBoolean();
    final StreamRecord record = mock(StreamRecord.class);
    when(record.getValue()).thenReturn(2).thenReturn(3);
    final Output output = mock(Output.class);
    final TestBolt bolt = new TestBolt();
    final HashSet<String> raw = new HashSet<String>();
    if (rawOutType1) {
        raw.add("stream1");
    }
    if (rawOutType2) {
        raw.add("stream2");
    }
    final BoltWrapper wrapper = new BoltWrapper(bolt, null, raw);
    wrapper.setup(createMockStreamTask(), new StreamConfig(new Configuration()), output);
    wrapper.open();
    final SplitStreamType splitRecord = new SplitStreamType<Integer>();
    if (rawOutType1) {
        splitRecord.streamId = "stream1";
        splitRecord.value = 2;
    } else {
        splitRecord.streamId = "stream1";
        splitRecord.value = new Tuple1<Integer>(2);
    }
    wrapper.processElement(record);
    verify(output).collect(new StreamRecord<SplitStreamType>(splitRecord));
    if (rawOutType2) {
        splitRecord.streamId = "stream2";
        splitRecord.value = 3;
    } else {
        splitRecord.streamId = "stream2";
        splitRecord.value = new Tuple1<Integer>(3);
    }
    wrapper.processElement(record);
    verify(output, times(2)).collect(new StreamRecord<SplitStreamType>(splitRecord));
}
Also used : StreamRecord(org.apache.flink.streaming.runtime.streamrecord.StreamRecord) UnmodifiableConfiguration(org.apache.flink.configuration.UnmodifiableConfiguration) Configuration(org.apache.flink.configuration.Configuration) StreamConfig(org.apache.flink.streaming.api.graph.StreamConfig) Output(org.apache.flink.streaming.api.operators.Output) HashSet(java.util.HashSet) SplitStreamType(org.apache.flink.storm.util.SplitStreamType) AbstractTest(org.apache.flink.storm.util.AbstractTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 5 with StreamConfig

use of org.apache.flink.streaming.api.graph.StreamConfig in project flink by apache.

the class BoltWrapperTest method testOpenSink.

@SuppressWarnings("unchecked")
@Test
public void testOpenSink() throws Exception {
    final StormConfig stormConfig = new StormConfig();
    final Configuration flinkConfig = new Configuration();
    final ExecutionConfig taskConfig = mock(ExecutionConfig.class);
    when(taskConfig.getGlobalJobParameters()).thenReturn(null).thenReturn(stormConfig).thenReturn(flinkConfig);
    final StreamingRuntimeContext taskContext = mock(StreamingRuntimeContext.class);
    when(taskContext.getExecutionConfig()).thenReturn(taskConfig);
    when(taskContext.getTaskName()).thenReturn("name");
    when(taskContext.getMetricGroup()).thenReturn(new UnregisteredMetricsGroup());
    final IRichBolt bolt = mock(IRichBolt.class);
    BoltWrapper<Object, Object> wrapper = new BoltWrapper<Object, Object>(bolt);
    wrapper.setup(createMockStreamTask(), new StreamConfig(new Configuration()), mock(Output.class));
    wrapper.open();
    verify(bolt).prepare(any(Map.class), any(TopologyContext.class), isNotNull(OutputCollector.class));
}
Also used : StormConfig(org.apache.flink.storm.util.StormConfig) IRichBolt(org.apache.storm.topology.IRichBolt) OutputCollector(org.apache.storm.task.OutputCollector) UnregisteredMetricsGroup(org.apache.flink.metrics.groups.UnregisteredMetricsGroup) UnmodifiableConfiguration(org.apache.flink.configuration.UnmodifiableConfiguration) Configuration(org.apache.flink.configuration.Configuration) StreamingRuntimeContext(org.apache.flink.streaming.api.operators.StreamingRuntimeContext) StreamConfig(org.apache.flink.streaming.api.graph.StreamConfig) ExecutionConfig(org.apache.flink.api.common.ExecutionConfig) Output(org.apache.flink.streaming.api.operators.Output) TopologyContext(org.apache.storm.task.TopologyContext) Map(java.util.Map) AbstractTest(org.apache.flink.storm.util.AbstractTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

StreamConfig (org.apache.flink.streaming.api.graph.StreamConfig)98 Test (org.junit.Test)57 Configuration (org.apache.flink.configuration.Configuration)41 OperatorID (org.apache.flink.runtime.jobgraph.OperatorID)40 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)16 Task (org.apache.flink.runtime.taskmanager.Task)16 StreamRecord (org.apache.flink.streaming.runtime.streamrecord.StreamRecord)14 ArrayList (java.util.ArrayList)13 StreamEdge (org.apache.flink.streaming.api.graph.StreamEdge)13 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)12 NettyShuffleEnvironmentBuilder (org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder)12 StreamMap (org.apache.flink.streaming.api.operators.StreamMap)12 Environment (org.apache.flink.runtime.execution.Environment)9 CheckpointMetaData (org.apache.flink.runtime.checkpoint.CheckpointMetaData)8 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)8 StreamOperator (org.apache.flink.streaming.api.operators.StreamOperator)8 CoStreamMap (org.apache.flink.streaming.api.operators.co.CoStreamMap)8 OneInputStreamTaskTestHarness (org.apache.flink.streaming.runtime.tasks.OneInputStreamTaskTestHarness)8 MockStreamTaskBuilder (org.apache.flink.streaming.util.MockStreamTaskBuilder)8 TypeSerializer (org.apache.flink.api.common.typeutils.TypeSerializer)7