pnowojski commented on a change in pull request #14953:
URL: https://github.com/apache/flink/pull/14953#discussion_r580130536



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/CheckpointSubsumeHelper.java
##########
@@ -0,0 +1,47 @@
+/*
+ * 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.function.ThrowingConsumer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Deque;
+
+class CheckpointSubsumeHelper {
+    private static final Logger LOG = 
LoggerFactory.getLogger(CheckpointSubsumeHelper.class);
+
+    public static void subsume(
+            Deque<CompletedCheckpoint> checkpoints,
+            int numRetain,
+            ThrowingConsumer<CompletedCheckpoint, Exception> subsumeAction)

Review comment:
       Maybe one last try from my side to avoid functional interfaces here
   
   > non-obvious contract that the original queue is modified too (or needs to 
be replaced);
   
   With the method name like `findAndRemoveCheckpointsToSubsume()` or something 
like that, it would be relatively obvious. Also in your current code it's 
(maybe even more) unclear that this `subsume()` is modifying 
`Deque<CompletedCheckpoint> checkpoints`.
   
   > a) duplicated error handling
   
   That would be small and simple duplication: 4 lines of code (only one 
meaningful) in two 5 LOC methods, so de facto only single line (error logging) 
would be duplicated.
   
   
   For me 1 <<< 2 < 3. If you still prefer 2 over 3, let's go with that. 
   
   The difference between 2 and 3 is not that large, but I'm afraid in the 
future I would be regretting it :( Similarly how I didn't like 1. in other 
places that we introduced them in the last year or so, but once I had to 
debug/analyse this newly added code a couple of times I changed my mind from 
"slightly against" to "strongly against". If you want, let's see, maybe 2. will 
be good enough.




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