org.apache.flink.streaming.runtime.tasks.OperatorChain.WatermarkGaugeExposingOutput Java Examples
The following examples show how to use
org.apache.flink.streaming.runtime.tasks.OperatorChain.WatermarkGaugeExposingOutput.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OperatorChainTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@SafeVarargs private static <T, OP extends StreamOperator<T>> OperatorChain<T, OP> setupOperatorChain( OneInputStreamOperator<T, T>... operators) { checkNotNull(operators); checkArgument(operators.length > 0); try (MockEnvironment env = MockEnvironment.builder().build()) { final StreamTask<?, ?> containingTask = new OneInputStreamTask<T, OneInputStreamOperator<T, T>>(env); final StreamStatusProvider statusProvider = mock(StreamStatusProvider.class); final StreamConfig cfg = new StreamConfig(new Configuration()); final StreamOperator<?>[] ops = new StreamOperator<?>[operators.length]; // initial output goes to nowhere @SuppressWarnings({"unchecked", "rawtypes"}) WatermarkGaugeExposingOutput<StreamRecord<T>> lastWriter = new BroadcastingOutputCollector<>( new Output[0], statusProvider); // build the reverse operators array for (int i = 0; i < ops.length; i++) { OneInputStreamOperator<T, T> op = operators[ops.length - i - 1]; op.setup(containingTask, cfg, lastWriter); lastWriter = new ChainingOutput<>(op, statusProvider, null); ops[i] = op; } @SuppressWarnings("unchecked") final OP head = (OP) operators[0]; return new OperatorChain<>( ops, new RecordWriterOutput<?>[0], lastWriter, head); } }
Example #2
Source File: OperatorChainTest.java From flink with Apache License 2.0 | 4 votes |
@SafeVarargs private static <T, OP extends StreamOperator<T>> OperatorChain<T, OP> setupOperatorChain( OneInputStreamOperator<T, T>... operators) throws Exception { checkNotNull(operators); checkArgument(operators.length > 0); try (MockEnvironment env = MockEnvironment.builder().build()) { final StreamTask<?, ?> containingTask = new OneInputStreamTask<T, OneInputStreamOperator<T, T>>(env); final StreamStatusProvider statusProvider = mock(StreamStatusProvider.class); final StreamConfig cfg = new StreamConfig(new Configuration()); final StreamOperator<?>[] ops = new StreamOperator<?>[operators.length]; // initial output goes to nowhere @SuppressWarnings({"unchecked", "rawtypes"}) WatermarkGaugeExposingOutput<StreamRecord<T>> lastWriter = new BroadcastingOutputCollector<>( new Output[0], statusProvider); // build the reverse operators array for (int i = 0; i < ops.length; i++) { OneInputStreamOperator<T, T> op = operators[ops.length - i - 1]; if (op instanceof SetupableStreamOperator) { ((SetupableStreamOperator) op).setup(containingTask, cfg, lastWriter); } lastWriter = new ChainingOutput<>(op, statusProvider, null); ops[i] = op; } @SuppressWarnings("unchecked") final OP head = (OP) operators[0]; return new OperatorChain<>( ops, new RecordWriterOutput<?>[0], lastWriter, head); } }
Example #3
Source File: OperatorChainTest.java From flink with Apache License 2.0 | 4 votes |
@SafeVarargs public static <T, OP extends StreamOperator<T>> OperatorChain<T, OP> setupOperatorChain( OneInputStreamOperator<T, T>... operators) throws Exception { checkNotNull(operators); checkArgument(operators.length > 0); try (MockEnvironment env = MockEnvironment.builder().build()) { final StreamTask<?, ?> containingTask = new MockStreamTaskBuilder(env).build(); final StreamStatusProvider statusProvider = mock(StreamStatusProvider.class); final StreamConfig cfg = new StreamConfig(new Configuration()); final List<StreamOperatorWrapper<?, ?>> operatorWrappers = new ArrayList<>(); // initial output goes to nowhere @SuppressWarnings({"unchecked", "rawtypes"}) WatermarkGaugeExposingOutput<StreamRecord<T>> lastWriter = new BroadcastingOutputCollector<>( new Output[0], statusProvider); // build the reverse operators array for (int i = 0; i < operators.length; i++) { OneInputStreamOperator<T, T> op = operators[operators.length - i - 1]; if (op instanceof SetupableStreamOperator) { ((SetupableStreamOperator) op).setup(containingTask, cfg, lastWriter); } lastWriter = new ChainingOutput<>(op, statusProvider, null); ProcessingTimeService processingTimeService = null; if (op instanceof AbstractStreamOperator) { processingTimeService = ((AbstractStreamOperator) op).getProcessingTimeService(); } operatorWrappers.add(new StreamOperatorWrapper<>( op, Optional.ofNullable(processingTimeService), containingTask.getMailboxExecutorFactory().createExecutor(i))); } @SuppressWarnings("unchecked") final StreamOperatorWrapper<T, OP> headOperatorWrapper = (StreamOperatorWrapper<T, OP>) operatorWrappers.get(operatorWrappers.size() - 1); return new OperatorChain<>( operatorWrappers, new RecordWriterOutput<?>[0], lastWriter, headOperatorWrapper); } }