Myasuka commented on a change in pull request #8693:
URL: https://github.com/apache/flink/pull/8693#discussion_r427241152



##########
File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/AsyncCheckpointRunnables.java
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.annotation.Internal;
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.util.IOUtils;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Track the {@link AsyncCheckpointRunnable}s in {@link 
SubtaskCheckpointCoordinator}.
+ */
+@Internal
+public class AsyncCheckpointRunnables implements Closeable {
+       private final Map<Long, AsyncCheckpointRunnable> checkpoints;
+       /** Lock that guards state of this registry. **/
+       private final Object lock;
+
+       public AsyncCheckpointRunnables() {
+               this.checkpoints = new HashMap<>();
+               this.lock = new Object();
+       }
+
+       public void registerAsyncCheckpointRunnable(long checkpointId, 
AsyncCheckpointRunnable asyncCheckpointRunnable) {
+               synchronized (lock) {
+                       checkpoints.put(checkpointId, asyncCheckpointRunnable);

Review comment:
       > Can we add a check that we don't already have this checkpointId?
   
   The checkpoint ids should be unique on task side, and I think adding a check 
here could be safer, if the `checkpointId` already registered, we should throw 
exception out.
   
   > Ideally, we should also check that this registry was not closed yet
   
   I think this is reasonable, which is similar to `AbstractCloseableRegistry`.




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


Reply via email to