org.apache.flink.streaming.runtime.io.RecordWriterOutput Java Examples
The following examples show how to use
org.apache.flink.streaming.runtime.io.RecordWriterOutput.
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: OperatorChain.java From flink with Apache License 2.0 | 6 votes |
private RecordWriterOutput<OUT> createStreamOutput( RecordWriter<SerializationDelegate<StreamRecord<OUT>>> recordWriter, StreamEdge edge, StreamConfig upStreamConfig, Environment taskEnvironment) { OutputTag sideOutputTag = edge.getOutputTag(); // OutputTag, return null if not sideOutput TypeSerializer outSerializer = null; if (edge.getOutputTag() != null) { // side output outSerializer = upStreamConfig.getTypeSerializerSideOut( edge.getOutputTag(), taskEnvironment.getUserClassLoader()); } else { // main output outSerializer = upStreamConfig.getTypeSerializerOut(taskEnvironment.getUserClassLoader()); } return new RecordWriterOutput<>(recordWriter, outSerializer, sideOutputTag, this); }
Example #2
Source File: OperatorChain.java From flink with Apache License 2.0 | 6 votes |
private RecordWriterOutput<OUT> createStreamOutput( RecordWriter<SerializationDelegate<StreamRecord<OUT>>> recordWriter, StreamEdge edge, StreamConfig upStreamConfig, Environment taskEnvironment) { OutputTag sideOutputTag = edge.getOutputTag(); // OutputTag, return null if not sideOutput TypeSerializer outSerializer = null; if (edge.getOutputTag() != null) { // side output outSerializer = upStreamConfig.getTypeSerializerSideOut( edge.getOutputTag(), taskEnvironment.getUserClassLoader()); } else { // main output outSerializer = upStreamConfig.getTypeSerializerOut(taskEnvironment.getUserClassLoader()); } return new RecordWriterOutput<>(recordWriter, outSerializer, sideOutputTag, this); }
Example #3
Source File: StreamIterationHead.java From flink with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override public void init() { // offer the queue for the tail BlockingQueueBroker.INSTANCE.handIn(brokerID, dataChannel); LOG.info("Iteration head {} added feedback queue under {}", getName(), brokerID); this.streamOutputs = (RecordWriterOutput<OUT>[]) getStreamOutputs(); // If timestamps are enabled we make sure to remove cyclic watermark dependencies if (isSerializingTimestamps()) { for (RecordWriterOutput<OUT> output : streamOutputs) { output.emitWatermark(new Watermark(Long.MAX_VALUE)); } } }
Example #4
Source File: OperatorChain.java From flink with Apache License 2.0 | 6 votes |
@VisibleForTesting OperatorChain( List<StreamOperatorWrapper<?, ?>> allOperatorWrappers, RecordWriterOutput<?>[] streamOutputs, WatermarkGaugeExposingOutput<StreamRecord<OUT>> chainEntryPoint, StreamOperatorWrapper<OUT, OP> headOperatorWrapper) { this.streamOutputs = checkNotNull(streamOutputs); this.chainEntryPoint = checkNotNull(chainEntryPoint); this.operatorEventDispatcher = null; checkState(allOperatorWrappers != null && allOperatorWrappers.size() > 0); this.headOperatorWrapper = checkNotNull(headOperatorWrapper); this.tailOperatorWrapper = allOperatorWrappers.get(0); this.numOperators = allOperatorWrappers.size(); linkOperatorWrappers(allOperatorWrappers); }
Example #5
Source File: OperatorChain.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private RecordWriterOutput<OUT> createStreamOutput( RecordWriter<SerializationDelegate<StreamRecord<OUT>>> recordWriter, StreamEdge edge, StreamConfig upStreamConfig, Environment taskEnvironment) { OutputTag sideOutputTag = edge.getOutputTag(); // OutputTag, return null if not sideOutput TypeSerializer outSerializer = null; if (edge.getOutputTag() != null) { // side output outSerializer = upStreamConfig.getTypeSerializerSideOut( edge.getOutputTag(), taskEnvironment.getUserClassLoader()); } else { // main output outSerializer = upStreamConfig.getTypeSerializerOut(taskEnvironment.getUserClassLoader()); } return new RecordWriterOutput<>(recordWriter, outSerializer, sideOutputTag, this); }
Example #6
Source File: StreamIterationHead.java From flink with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override public void init() { // offer the queue for the tail BlockingQueueBroker.INSTANCE.handIn(brokerID, dataChannel); LOG.info("Iteration head {} added feedback queue under {}", getName(), brokerID); this.streamOutputs = (RecordWriterOutput<OUT>[]) getStreamOutputs(); // If timestamps are enabled we make sure to remove cyclic watermark dependencies if (isSerializingTimestamps()) { synchronized (getCheckpointLock()) { for (RecordWriterOutput<OUT> output : streamOutputs) { output.emitWatermark(new Watermark(Long.MAX_VALUE)); } } } }
Example #7
Source File: StreamIterationHead.java From flink with Apache License 2.0 | 6 votes |
@Override protected void performDefaultAction(DefaultActionContext context) throws Exception { StreamRecord<OUT> nextRecord = shouldWait ? dataChannel.poll(iterationWaitTime, TimeUnit.MILLISECONDS) : dataChannel.take(); if (nextRecord != null) { synchronized (getCheckpointLock()) { for (RecordWriterOutput<OUT> output : streamOutputs) { output.collect(nextRecord); } } } else { context.allActionsCompleted(); } }
Example #8
Source File: OperatorChain.java From flink with Apache License 2.0 | 5 votes |
@Override public void toggleStreamStatus(StreamStatus status) { if (!status.equals(this.streamStatus)) { this.streamStatus = status; // try and forward the stream status change to all outgoing connections for (RecordWriterOutput<?> streamOutput : streamOutputs) { streamOutput.emitStreamStatus(status); } } }
Example #9
Source File: OperatorChain.java From flink with Apache License 2.0 | 5 votes |
private <IN, OUT> WatermarkGaugeExposingOutput<StreamRecord<IN>> createChainedOperator( StreamTask<?, ?> containingTask, StreamConfig operatorConfig, Map<Integer, StreamConfig> chainedConfigs, ClassLoader userCodeClassloader, Map<StreamEdge, RecordWriterOutput<?>> streamOutputs, List<StreamOperator<?>> allOperators, OutputTag<IN> outputTag) { // create the output that the operator writes to first. this may recursively create more operators WatermarkGaugeExposingOutput<StreamRecord<OUT>> chainedOperatorOutput = createOutputCollector( containingTask, operatorConfig, chainedConfigs, userCodeClassloader, streamOutputs, allOperators); // now create the operator and give it the output collector to write its output to StreamOperatorFactory<OUT> chainedOperatorFactory = operatorConfig.getStreamOperatorFactory(userCodeClassloader); OneInputStreamOperator<IN, OUT> chainedOperator = chainedOperatorFactory.createStreamOperator( containingTask, operatorConfig, chainedOperatorOutput); allOperators.add(chainedOperator); WatermarkGaugeExposingOutput<StreamRecord<IN>> currentOperatorOutput; if (containingTask.getExecutionConfig().isObjectReuseEnabled()) { currentOperatorOutput = new ChainingOutput<>(chainedOperator, this, outputTag); } else { TypeSerializer<IN> inSerializer = operatorConfig.getTypeSerializerIn1(userCodeClassloader); currentOperatorOutput = new CopyingChainingOutput<>(chainedOperator, inSerializer, outputTag, this); } // wrap watermark gauges since registered metrics must be unique chainedOperator.getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_WATERMARK, currentOperatorOutput.getWatermarkGauge()::getValue); chainedOperator.getMetricGroup().gauge(MetricNames.IO_CURRENT_OUTPUT_WATERMARK, chainedOperatorOutput.getWatermarkGauge()::getValue); return currentOperatorOutput; }
Example #10
Source File: StreamIterationHead.java From flink with Apache License 2.0 | 5 votes |
@Override protected void processInput(MailboxDefaultAction.Controller controller) throws Exception { StreamRecord<OUT> nextRecord = shouldWait ? dataChannel.poll(iterationWaitTime, TimeUnit.MILLISECONDS) : dataChannel.take(); if (nextRecord != null) { for (RecordWriterOutput<OUT> output : streamOutputs) { output.collect(nextRecord); } } else { controller.allActionsCompleted(); } }
Example #11
Source File: OperatorChain.java From flink with Apache License 2.0 | 5 votes |
@Override public void toggleStreamStatus(StreamStatus status) { if (!status.equals(this.streamStatus)) { this.streamStatus = status; // try and forward the stream status change to all outgoing connections for (RecordWriterOutput<?> streamOutput : streamOutputs) { streamOutput.emitStreamStatus(status); } } }
Example #12
Source File: OperatorChain.java From flink with Apache License 2.0 | 5 votes |
@VisibleForTesting OperatorChain( StreamOperator<?>[] allOperators, RecordWriterOutput<?>[] streamOutputs, WatermarkGaugeExposingOutput<StreamRecord<OUT>> chainEntryPoint, OP headOperator) { this.allOperators = checkNotNull(allOperators); this.streamOutputs = checkNotNull(streamOutputs); this.chainEntryPoint = checkNotNull(chainEntryPoint); this.headOperator = checkNotNull(headOperator); }
Example #13
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 #14
Source File: OperatorChain.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private <IN, OUT> WatermarkGaugeExposingOutput<StreamRecord<IN>> createChainedOperator( StreamTask<?, ?> containingTask, StreamConfig operatorConfig, Map<Integer, StreamConfig> chainedConfigs, ClassLoader userCodeClassloader, Map<StreamEdge, RecordWriterOutput<?>> streamOutputs, List<StreamOperator<?>> allOperators, OutputTag<IN> outputTag) { // create the output that the operator writes to first. this may recursively create more operators WatermarkGaugeExposingOutput<StreamRecord<OUT>> chainedOperatorOutput = createOutputCollector( containingTask, operatorConfig, chainedConfigs, userCodeClassloader, streamOutputs, allOperators); // now create the operator and give it the output collector to write its output to OneInputStreamOperator<IN, OUT> chainedOperator = operatorConfig.getStreamOperator(userCodeClassloader); chainedOperator.setup(containingTask, operatorConfig, chainedOperatorOutput); allOperators.add(chainedOperator); WatermarkGaugeExposingOutput<StreamRecord<IN>> currentOperatorOutput; if (containingTask.getExecutionConfig().isObjectReuseEnabled()) { currentOperatorOutput = new ChainingOutput<>(chainedOperator, this, outputTag); } else { TypeSerializer<IN> inSerializer = operatorConfig.getTypeSerializerIn1(userCodeClassloader); currentOperatorOutput = new CopyingChainingOutput<>(chainedOperator, inSerializer, outputTag, this); } // wrap watermark gauges since registered metrics must be unique chainedOperator.getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_WATERMARK, currentOperatorOutput.getWatermarkGauge()::getValue); chainedOperator.getMetricGroup().gauge(MetricNames.IO_CURRENT_OUTPUT_WATERMARK, chainedOperatorOutput.getWatermarkGauge()::getValue); return currentOperatorOutput; }
Example #15
Source File: OperatorChain.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public void toggleStreamStatus(StreamStatus status) { if (!status.equals(this.streamStatus)) { this.streamStatus = status; // try and forward the stream status change to all outgoing connections for (RecordWriterOutput<?> streamOutput : streamOutputs) { streamOutput.emitStreamStatus(status); } } }
Example #16
Source File: OperatorChain.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@VisibleForTesting OperatorChain( StreamOperator<?>[] allOperators, RecordWriterOutput<?>[] streamOutputs, WatermarkGaugeExposingOutput<StreamRecord<OUT>> chainEntryPoint, OP headOperator) { this.allOperators = checkNotNull(allOperators); this.streamOutputs = checkNotNull(streamOutputs); this.chainEntryPoint = checkNotNull(chainEntryPoint); this.headOperator = checkNotNull(headOperator); }
Example #17
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); } }
Example #18
Source File: OperatorChain.java From flink with Apache License 2.0 | 4 votes |
public void broadcastEvent(AbstractEvent event, boolean isPriorityEvent) throws IOException { for (RecordWriterOutput<?> streamOutput : streamOutputs) { streamOutput.broadcastEvent(event, isPriorityEvent); } }
Example #19
Source File: OperatorChain.java From flink with Apache License 2.0 | 4 votes |
public RecordWriterOutput<?>[] getStreamOutputs() { return streamOutputs; }
Example #20
Source File: OperatorChain.java From flink with Apache License 2.0 | 4 votes |
private <IN, OUT> WatermarkGaugeExposingOutput<StreamRecord<IN>> createChainedOperator( StreamTask<OUT, ?> containingTask, StreamConfig operatorConfig, Map<Integer, StreamConfig> chainedConfigs, ClassLoader userCodeClassloader, Map<StreamEdge, RecordWriterOutput<?>> streamOutputs, List<StreamOperatorWrapper<?, ?>> allOperatorWrappers, OutputTag<IN> outputTag, MailboxExecutorFactory mailboxExecutorFactory) { // create the output that the operator writes to first. this may recursively create more operators WatermarkGaugeExposingOutput<StreamRecord<OUT>> chainedOperatorOutput = createOutputCollector( containingTask, operatorConfig, chainedConfigs, userCodeClassloader, streamOutputs, allOperatorWrappers, mailboxExecutorFactory); // now create the operator and give it the output collector to write its output to Tuple2<OneInputStreamOperator<IN, OUT>, Optional<ProcessingTimeService>> chainedOperatorAndTimeService = StreamOperatorFactoryUtil.createOperator( operatorConfig.getStreamOperatorFactory(userCodeClassloader), containingTask, operatorConfig, chainedOperatorOutput, operatorEventDispatcher); OneInputStreamOperator<IN, OUT> chainedOperator = chainedOperatorAndTimeService.f0; allOperatorWrappers.add(createOperatorWrapper(chainedOperator, containingTask, operatorConfig, chainedOperatorAndTimeService.f1)); WatermarkGaugeExposingOutput<StreamRecord<IN>> currentOperatorOutput; if (containingTask.getExecutionConfig().isObjectReuseEnabled()) { currentOperatorOutput = new ChainingOutput<>(chainedOperator, this, outputTag); } else { TypeSerializer<IN> inSerializer = operatorConfig.getTypeSerializerIn1(userCodeClassloader); currentOperatorOutput = new CopyingChainingOutput<>(chainedOperator, inSerializer, outputTag, this); } // wrap watermark gauges since registered metrics must be unique chainedOperator.getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_WATERMARK, currentOperatorOutput.getWatermarkGauge()::getValue); chainedOperator.getMetricGroup().gauge(MetricNames.IO_CURRENT_OUTPUT_WATERMARK, chainedOperatorOutput.getWatermarkGauge()::getValue); return currentOperatorOutput; }
Example #21
Source File: StreamTask.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
RecordWriterOutput<?>[] getStreamOutputs() { return operatorChain.getStreamOutputs(); }
Example #22
Source File: StreamTask.java From flink with Apache License 2.0 | 4 votes |
RecordWriterOutput<?>[] getStreamOutputs() { return operatorChain.getStreamOutputs(); }
Example #23
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 #24
Source File: OperatorChain.java From flink with Apache License 2.0 | 4 votes |
public RecordWriterOutput<?>[] getStreamOutputs() { return streamOutputs; }
Example #25
Source File: OperatorChain.java From flink with Apache License 2.0 | 4 votes |
public void broadcastCheckpointCancelMarker(long id) throws IOException { CancelCheckpointMarker barrier = new CancelCheckpointMarker(id); for (RecordWriterOutput<?> streamOutput : streamOutputs) { streamOutput.broadcastEvent(barrier); } }
Example #26
Source File: OperatorChain.java From flink with Apache License 2.0 | 4 votes |
public void broadcastCheckpointBarrier(long id, long timestamp, CheckpointOptions checkpointOptions) throws IOException { CheckpointBarrier barrier = new CheckpointBarrier(id, timestamp, checkpointOptions); for (RecordWriterOutput<?> streamOutput : streamOutputs) { streamOutput.broadcastEvent(barrier); } }
Example #27
Source File: StreamTask.java From flink with Apache License 2.0 | 4 votes |
RecordWriterOutput<?>[] getStreamOutputs() { return operatorChain.getStreamOutputs(); }
Example #28
Source File: OperatorChain.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public RecordWriterOutput<?>[] getStreamOutputs() { return streamOutputs; }
Example #29
Source File: OperatorChain.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public void broadcastCheckpointCancelMarker(long id) throws IOException { CancelCheckpointMarker barrier = new CancelCheckpointMarker(id); for (RecordWriterOutput<?> streamOutput : streamOutputs) { streamOutput.broadcastEvent(barrier); } }
Example #30
Source File: OperatorChain.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public void broadcastCheckpointBarrier(long id, long timestamp, CheckpointOptions checkpointOptions) throws IOException { CheckpointBarrier barrier = new CheckpointBarrier(id, timestamp, checkpointOptions); for (RecordWriterOutput<?> streamOutput : streamOutputs) { streamOutput.broadcastEvent(barrier); } }