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());
}
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());
}
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());
}
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));
}
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));
}
Aggregations