pnowojski commented on a change in pull request #13234:
URL: https://github.com/apache/flink/pull/13234#discussion_r478496041



##########
File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/MultipleInputChainingOutput.java
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.streaming.runtime.tasks;
+
+import org.apache.flink.metrics.Counter;
+import org.apache.flink.metrics.Gauge;
+import org.apache.flink.metrics.SimpleCounter;
+import org.apache.flink.runtime.metrics.groups.OperatorIOMetricGroup;
+import org.apache.flink.runtime.metrics.groups.OperatorMetricGroup;
+import org.apache.flink.streaming.api.operators.Input;
+import org.apache.flink.streaming.api.watermark.Watermark;
+import org.apache.flink.streaming.runtime.metrics.WatermarkGauge;
+import org.apache.flink.streaming.runtime.streamrecord.LatencyMarker;
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.streaming.runtime.streamstatus.StreamStatusProvider;
+import org.apache.flink.util.OutputTag;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+class MultipleInputChainingOutput<T> implements 
WatermarkGaugeExposingOutput<StreamRecord<T>> {
+       private static final Logger LOG = 
LoggerFactory.getLogger(MultipleInputChainingOutput.class);
+
+       protected final Input<T> input;
+       protected final Counter numRecordsIn;
+       protected final WatermarkGauge watermarkGauge = new WatermarkGauge();
+       protected final StreamStatusProvider streamStatusProvider;
+       @Nullable protected final OutputTag<T> outputTag;
+
+       public MultipleInputChainingOutput(
+                       Input<T> input,
+                       OperatorMetricGroup operatorMetricGroup,
+                       StreamStatusProvider streamStatusProvider,
+                       @Nullable OutputTag<T> outputTag) {
+               this.input = input;
+
+               {
+                       Counter tmpNumRecordsIn;
+                       try {
+                               OperatorIOMetricGroup ioMetricGroup = 
operatorMetricGroup.getIOMetricGroup();
+                               tmpNumRecordsIn = 
ioMetricGroup.getNumRecordsInCounter();
+                       } catch (Exception e) {
+                               LOG.warn("An exception occurred during the 
metrics setup.", e);
+                               tmpNumRecordsIn = new SimpleCounter();
+                       }
+                       numRecordsIn = tmpNumRecordsIn;
+               }
+
+               this.streamStatusProvider = streamStatusProvider;
+               this.outputTag = outputTag;
+       }
+
+       @Override
+       public void collect(StreamRecord<T> record) {
+               if (this.outputTag != null) {
+                       // we are not responsible for emitting to the main 
output.
+                       return;
+               }
+
+               pushToOperator(record);
+       }
+
+       @Override
+       public <X> void collect(OutputTag<X> outputTag, StreamRecord<X> record) 
{
+               if (this.outputTag == null || 
!this.outputTag.equals(outputTag)) {

Review comment:
       In that case user should be calling `Output.collect(record)`, as 
`outputTag` is `@NonNull` (by default).
   
   I mean, we could do it but do we want to support nullable `outputTag`? Keep 
in mind that's a public api, so we would need to change the behaviour of the 
public api and then keep supporting incorrect calls in the future.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to