StefanRRichter commented on a change in pull request #8124: [FLINK-11877] 
Implement the runtime handling of the InputSelectable interface
URL: https://github.com/apache/flink/pull/8124#discussion_r274513130
 
 

 ##########
 File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/io/NetworkInput.java
 ##########
 @@ -0,0 +1,260 @@
+/*
+ * 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.io;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.runtime.event.AbstractEvent;
+import org.apache.flink.runtime.io.disk.iomanager.IOManager;
+import org.apache.flink.runtime.io.network.api.CancelCheckpointMarker;
+import org.apache.flink.runtime.io.network.api.CheckpointBarrier;
+import org.apache.flink.runtime.io.network.api.EndOfPartitionEvent;
+import 
org.apache.flink.runtime.io.network.api.serialization.RecordDeserializer;
+import 
org.apache.flink.runtime.io.network.api.serialization.RecordDeserializer.DeserializationResult;
+import 
org.apache.flink.runtime.io.network.api.serialization.SpillingAdaptiveSpanningRecordDeserializer;
+import org.apache.flink.runtime.io.network.buffer.Buffer;
+import org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent;
+import org.apache.flink.runtime.io.network.partition.consumer.InputGate;
+import 
org.apache.flink.runtime.io.network.partition.consumer.InputGateListener;
+import org.apache.flink.runtime.plugable.DeserializationDelegate;
+import org.apache.flink.runtime.plugable.NonReusingDeserializationDelegate;
+import org.apache.flink.streaming.api.watermark.Watermark;
+import org.apache.flink.streaming.runtime.streamrecord.StreamElement;
+import org.apache.flink.streaming.runtime.streamrecord.StreamElementSerializer;
+import org.apache.flink.streaming.runtime.streamstatus.StatusWatermarkValve;
+import org.apache.flink.streaming.runtime.streamstatus.StreamStatus;
+
+import java.io.IOException;
+import java.util.BitSet;
+import java.util.Collection;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+import static org.apache.flink.util.Preconditions.checkState;
+
+/**
+ * Implementation of taking {@link InputGate} as {@link Input}.
+ */
+@Internal
+public final class NetworkInput implements Input, InputGateListener {
+
+       private final int inputId;
+
+       private final InputGate inputGate;
+
+       private final DeserializationDelegate<StreamElement> 
deserializationDelegate;
+
+       private final 
RecordDeserializer<DeserializationDelegate<StreamElement>>[] 
recordDeserializers;
+
+       /**
+        * Valves that control how watermarks and stream statuses from the 
input are forwarded.
+        */
+       private final StatusWatermarkValve statusWatermarkValve;
+
+       private final StreamStatusHandler streamStatusHandler;
+
+       /** Registered listener to forward input notifications to. */
+       private volatile CompletableFuture<?> inputListener = null;
+
+       /**
+        * The channel from which a buffer came, tracked so that we can 
appropriately map
+        * the watermarks and watermark statuses to the correct channel index 
of the correct valve.
+        */
+       private int currentChannel = -1;
+
+       private RecordDeserializer<DeserializationDelegate<StreamElement>> 
currentRecordDeserializer = null;
+
+       /** The new overall watermark aggregated on all aligned input channels. 
*/
+       private Watermark alignedWatermark = null;
+
+       private final BitSet finishedChannels;
+
+       private boolean isFinished = false;
+
+       public NetworkInput(
+               int inputId,
+               Collection<InputGate> inputGates,
+               TypeSerializer<?> inputSerializer,
+               StreamStatusHandler streamStatusHandler,
+               IOManager ioManager) {
+
+               this.inputId = inputId;
+
+               this.inputGate = 
InputGateUtil.createInputGate(inputGates.toArray(new 
InputGate[inputGates.size()]));
 
 Review comment:
   It is recommended to pass `new InputGate[0]` since ~Java1.6, the call is 
using intrinics.

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to