pnowojski commented on a change in pull request #8811: [FLINK-12777][network] Support CheckpointBarrierHandler in StreamTwoInputSelectableProcessor URL: https://github.com/apache/flink/pull/8811#discussion_r297726473
########## File path: flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/io/CheckpointedInputGate.java ########## @@ -0,0 +1,273 @@ +/* + * 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.annotation.VisibleForTesting; +import org.apache.flink.runtime.io.AsyncDataInput; +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.partition.consumer.BufferOrEvent; +import org.apache.flink.runtime.io.network.partition.consumer.InputGate; +import org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.Nullable; + +import java.io.IOException; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +import static org.apache.flink.util.Preconditions.checkNotNull; + +/** + * The {@link CheckpointedInputGate} uses {@link CheckpointBarrierHandler} to handle incoming + * {@link CheckpointBarrier} from the {@link InputGate}. + */ +@Internal +public class CheckpointedInputGate implements AsyncDataInput<BufferOrEvent> { + + private static final Logger LOG = LoggerFactory.getLogger(CheckpointedInputGate.class); + + private final CheckpointBarrierHandler barrierHandler; + + /** The gate that the buffer draws its input from. */ + private final InputGate inputGate; + + private final int channelIndexOffset; + + private final BufferStorage bufferStorage; + + /** Flag to indicate whether we have drawn all available input. */ + private boolean endOfInputGate; + + /** Indicate end of the input. Set to true after encountering {@link #endOfInputGate} and depleting + * {@link #bufferStorage}. */ + private boolean isFinished; + + /** + * Creates a new checkpoint stream aligner. + * + * <p>There is no limit to how much data may be buffered during an alignment. + * + * @param inputGate The input gate to draw the buffers and events from. + * @param bufferStorage The storage to hold the buffers and events for blocked channels. + */ + @VisibleForTesting + CheckpointedInputGate(InputGate inputGate, BufferStorage bufferStorage) { + this (inputGate, bufferStorage, "Testing: No task associated", null); + } + + @VisibleForTesting + CheckpointedInputGate( Review comment: I removed `@VisibleForTesting` from this one, at least for now. Maybe it would be better to move this constructor to a static test factory method, but I'm not that sure about that (from the code it's quite obvious that this is just a shortcut/simplified version of more complex constructors). ---------------------------------------------------------------- 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
