1u0 commented on a change in pull request #9478: [FLINK-13766][task] Refactor 
the implementation of StreamInputProcessor based on StreamTaskInput#emitNext
URL: https://github.com/apache/flink/pull/9478#discussion_r322659847
 
 

 ##########
 File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/OneInputStreamTask.java
 ##########
 @@ -68,31 +86,115 @@ public OneInputStreamTask(
        @Override
        public void init() throws Exception {
                StreamConfig configuration = getConfiguration();
-
-               TypeSerializer<IN> inSerializer = 
configuration.getTypeSerializerIn1(getUserCodeClassLoader());
                int numberOfInputs = configuration.getNumberOfInputs();
 
                if (numberOfInputs > 0) {
-                       InputGate[] inputGates = 
getEnvironment().getAllInputGates();
+                       CheckpointedInputGate inputGate = 
createCheckpointedInputGate();
+                       TaskIOMetricGroup taskIOMetricGroup = 
getEnvironment().getMetricGroup().getIOMetricGroup();
+                       taskIOMetricGroup.gauge("checkpointAlignmentTime", 
inputGate::getAlignmentDurationNanos);
 
+                       DataOutput<IN> output = createDataOutput();
+                       StreamTaskInput<IN> input = createTaskInput(inputGate, 
output);
                        inputProcessor = new StreamOneInputProcessor<>(
-                               inputGates,
-                               inSerializer,
-                               this,
-                               configuration.getCheckpointMode(),
+                               input,
+                               output,
                                getCheckpointLock(),
-                               getEnvironment().getIOManager(),
-                               
getEnvironment().getTaskManagerInfo().getConfiguration(),
-                               getStreamStatusMaintainer(),
-                               headOperator,
-                               
getEnvironment().getMetricGroup().getIOMetricGroup(),
-                               inputWatermarkGauge,
-                               getTaskNameWithSubtaskAndId(),
-                               operatorChain,
-                               setupNumRecordsInCounter(headOperator));
+                               operatorChain);
                }
                
headOperator.getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_WATERMARK, 
this.inputWatermarkGauge);
                // wrap watermark gauge since registered metrics must be unique
                
getEnvironment().getMetricGroup().gauge(MetricNames.IO_CURRENT_INPUT_WATERMARK, 
this.inputWatermarkGauge::getValue);
        }
+
+       private CheckpointedInputGate createCheckpointedInputGate() throws 
IOException {
+               InputGate[] inputGates = getEnvironment().getAllInputGates();
+               InputGate inputGate = InputGateUtil.createInputGate(inputGates);
+
+               return InputProcessorUtil.createCheckpointedInputGate(
+                       this,
+                       configuration.getCheckpointMode(),
+                       getEnvironment().getIOManager(),
+                       inputGate,
+                       
getEnvironment().getTaskManagerInfo().getConfiguration(),
+                       getTaskNameWithSubtaskAndId());
+       }
+
+       private DataOutput<IN> createDataOutput() {
+               return new StreamTaskNetworkOutput<>(
+                       headOperator,
+                       getStreamStatusMaintainer(),
+                       getCheckpointLock(),
+                       inputWatermarkGauge,
+                       setupNumRecordsInCounter(headOperator));
+       }
+
+       private StreamTaskInput<IN> createTaskInput(CheckpointedInputGate 
inputGate, DataOutput<IN> output) {
+               TypeSerializer<IN> inSerializer = 
configuration.getTypeSerializerIn1(getUserCodeClassLoader());
+
+               StatusWatermarkValve statusWatermarkValve = new 
StatusWatermarkValve(
+                       inputGate.getNumberOfInputChannels(), output);
+
+               return new StreamTaskNetworkInput<>(
+                       inputGate, inSerializer, 
getEnvironment().getIOManager(), statusWatermarkValve, 0);
 
 Review comment:
   Same note for code formatting (and a few lines above).

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to