You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/04/02 09:34:35 UTC

[GitHub] [flink] rkhachatryan commented on a change in pull request #11507: [FLINK-16587] Add basic CheckpointBarrierHandler for unaligned checkpoint

rkhachatryan commented on a change in pull request #11507: [FLINK-16587] Add basic CheckpointBarrierHandler for unaligned checkpoint
URL: https://github.com/apache/flink/pull/11507#discussion_r402179750
 
 

 ##########
 File path: flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/io/CheckpointBarrierUnaligner.java
 ##########
 @@ -0,0 +1,242 @@
+/*
+ * 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.runtime.checkpoint.channel.ChannelStateWriter;
+import org.apache.flink.runtime.checkpoint.channel.InputChannelInfo;
+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.buffer.Buffer;
+import org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import java.util.Arrays;
+import java.util.concurrent.CompletableFuture;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * {@link CheckpointBarrierUnaligner} is used for triggering checkpoint while reading the first barrier
+ * and keeping track of the number of received barriers and consumed barriers.
+ */
+@Internal
+public class CheckpointBarrierUnaligner extends CheckpointBarrierHandler {
+
+	private static final Logger LOG = LoggerFactory.getLogger(CheckpointBarrierUnaligner.class);
+
+	private final String taskName;
+
+	/**
+	 * Tag the state of which input channel has read the barrier. If one channel has read the barrier by task,
+	 * the respective in-flight input buffers should be empty when triggering unaligned checkpoint.
+	 */
+	private final boolean[] barrierConsumedChannels;
+
+	/**
+	 * Tag the state of which input channel has received the barrier. Until the barrier of a specific channel is
+	 * received, all new buffers need to be persisted after unaligned checkpointing has been started.
+	 */
+	private final boolean[] barrierReceivedChannels;
+
+	/**
+	 * Contains the offsets of the channel indices for each gate when flattening the channels of all gates.
+	 *
+	 * <p>For example, consider 3 gates with 4 channels, {@code gateChannelOffsets = [0, 4, 8]}.
+	 */
+	private final int[] gateChannelOffsets;
+
+	/**
+	 * The number of input channels which has read the barrier by task.
+	 */
+	private int numBarriersReceived;
+
+	/**
+	 * The checkpoint id to guarantee that we would trigger only one checkpoint when reading the same barrier from
+	 * different channels.
+	 */
+	private long currentCheckpointId = -1L;
+
+	private final ChannelStateWriter channelStateWriter;
+
+	private CompletableFuture<?> allBarriersReceivedFuture;
 
 Review comment:
   > \<?> is more general 
   > \<Void> means that there can not be any result 
   
   Agree, and this is why I'd choose `<Void>` here.
   
   > it means "result doesn't matter, it can be anything". 
   
   To me, `<?>` means result **does** matter and it can either be anything; or we just couldn't express it better (usually the case).
   
   > might cause some conversion issues (if you already have some future that you could re-use directly, but instead you have to change it's type)
   
   Currently, it's always completed with `null`s and I don't see why would we want to pass some value here or use some other future with a result.

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


With regards,
Apache Git Services