yanghua commented on a change in pull request #8322: [FLINK-12364] Introduce a 
CheckpointFailureManager to centralized manage checkpoint failure
URL: https://github.com/apache/flink/pull/8322#discussion_r283090199
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/CheckpointFailureManager.java
 ##########
 @@ -0,0 +1,164 @@
+/*
+ * 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.runtime.checkpoint;
+
+import org.apache.flink.util.FlinkRuntimeException;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+import static org.apache.flink.util.Preconditions.checkArgument;
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * The checkpoint failure manager which centralized manage checkpoint failure 
processing logic.
+ */
+public class CheckpointFailureManager {
+
+       private final static int MAXIMUM_TOLERABLE_FAILURE_NUMBER = 
Integer.MAX_VALUE;
+
+       private final static short IGNORE_FLAG = 0;
+       private final static short COUNT_FLAG = 1;
+       private final static short SUCCEED_FLAG = -1;
+
+       private final int tolerableCpFailureNumber;
+       private final FailJobCallback failureCallback;
+       private final TreeMap<Long, Short> serialCheckpointResultTable;
+
+       public CheckpointFailureManager(int tolerableCpFailureNumber, 
FailJobCallback failureCallback) {
+               checkArgument(tolerableCpFailureNumber >= 0
+                               && tolerableCpFailureNumber < 
MAXIMUM_TOLERABLE_FAILURE_NUMBER,
+                       "The tolerable checkpoint failure number is illegal, " +
+                               "it must be greater than or equal to 0 and less 
than " + MAXIMUM_TOLERABLE_FAILURE_NUMBER + ".");
+               this.tolerableCpFailureNumber = tolerableCpFailureNumber;
+               this.failureCallback = checkNotNull(failureCallback);
+               this.serialCheckpointResultTable = new 
TreeMap<>(Collections.reverseOrder());
+       }
+
+       /**
+        * Handle checkpoint exception with a handler callback.
+        *
+        * @param exception the checkpoint exception.
+        */
+       public void handleCheckpointException(CheckpointException exception, 
long checkpointId) {
 
 Review comment:
   Hi @StefanRRichter I have refactored the mechanism of counting based on your 
suggestion, it considers the checkpoint id's sequence. But when I am 
implementing, I meet a problem: the `CheckpointException` caused by **Trigger** 
phase may not get the checkpoint id.
   
   Currently, the method `triggerCheckpoint` has two results:
   
   * Gets a pending checkpoint (can get the checkpoint id)
   * Throws a `CheckpointException` (whether could get checkpoint id or not 
depends on the exception's throw-point in this method)
   
   So, I can not get the checkpoint id 
[here](https://github.com/apache/flink/pull/8322/files#diff-a38ea0fa799bdaa0b354d80cd8368c60R442).
   
   My thought is that we could inject the checkpoint id into the 
`CheckpointException`(it seems the semantic looks strange?), if we can not 
inject it, we can use a default value(-1). Then in `CheckpointFailureManager`, 
if we can not get a normal checkpoint (we get `-1` which means the checkpoint 
is not been generated in trigger phase), we would ignore this case. Actually, 
it seems this case is not the scene which we want to tolerance.
   
   What do you think?

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