dawidwys commented on a change in pull request #14754:
URL: https://github.com/apache/flink/pull/14754#discussion_r643141598



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/metadata/MetadataV2Serializer.java
##########
@@ -71,6 +73,10 @@ public CheckpointMetadata deserialize(
     @Override
     protected void serializeOperatorState(OperatorState operatorState, 
DataOutputStream dos)
             throws IOException {
+        checkState(
+                !operatorState.isFullyFinished(),
+                "Could not support finished Operator state in stale 
serializers.");

Review comment:
       ```suggestion
                   "Could not support finished Operator state in state 
serializers.");
   ```

##########
File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/PendingCheckpointTest.java
##########
@@ -544,6 +546,69 @@ public void testDisposeDisposesCoordinatorStates() throws 
Exception {
         assertTrue(handle2.isDisposed());
     }
 
+    @Test
+    public void testFinalizeCheckpointWithFullyFinishedOperators() throws 
Exception {
+        JobVertexID finishedJobVertexID = new JobVertexID();
+        JobVertexID runningJobVertexID = new JobVertexID();
+        OperatorID finishedOperatorID = new OperatorID();
+        OperatorID runningOperatorID = new OperatorID();
+
+        ExecutionGraph executionGraph =
+                new 
CheckpointCoordinatorTestingUtils.CheckpointExecutionGraphBuilder()
+                        .addJobVertex(
+                                finishedJobVertexID,
+                                1,
+                                256,
+                                Collections.singletonList(
+                                        
OperatorIDPair.generatedIDOnly(finishedOperatorID)),
+                                true)
+                        .addJobVertex(
+                                runningJobVertexID,
+                                1,
+                                256,
+                                Collections.singletonList(
+                                        
OperatorIDPair.generatedIDOnly(runningOperatorID)),
+                                true)
+                        .build();
+        executionGraph
+                .getJobVertex(finishedJobVertexID)
+                .getTaskVertices()[0]
+                .getCurrentExecutionAttempt()
+                .markFinished();
+        PendingCheckpoint pendingCheckpoint = 
createPendingCheckpoint(executionGraph);
+        assertEquals(1, 
pendingCheckpoint.getCheckpointPlan().getFullyFinishedJobVertex().size());
+        assertEquals(
+                finishedJobVertexID,
+                pendingCheckpoint
+                        .getCheckpointPlan()
+                        .getFullyFinishedJobVertex()
+                        .get(0)
+                        .getJobVertexId());
+
+        // Report the state for the running operator
+        ExecutionAttemptID runningTaskId =
+                executionGraph
+                        .getJobVertex(runningJobVertexID)
+                        .getTaskVertices()[0]
+                        .getCurrentExecutionAttempt()
+                        .getAttemptId();
+        TaskStateSnapshot taskStateSnapshot = new TaskStateSnapshot();
+        taskStateSnapshot.putSubtaskStateByOperatorID(
+                runningOperatorID, new OperatorSubtaskState());
+        TaskAcknowledgeResult result =
+                pendingCheckpoint.acknowledgeTask(
+                        runningTaskId, taskStateSnapshot, new 
CheckpointMetrics(), null);
+        assertEquals(TaskAcknowledgeResult.SUCCESS, result);

Review comment:
       nit: We prefer `assertThat` as it gives a nicer description in case of a 
failure.

##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/metadata/MetadataV3Serializer.java
##########
@@ -103,11 +105,16 @@ protected void serializeOperatorState(OperatorState 
operatorState, DataOutputStr
         serializeStreamStateHandle(operatorState.getCoordinatorState(), dos);
 
         // Sub task states
-        final Map<Integer, OperatorSubtaskState> subtaskStateMap = 
operatorState.getSubtaskStates();
-        dos.writeInt(subtaskStateMap.size());
-        for (Map.Entry<Integer, OperatorSubtaskState> entry : 
subtaskStateMap.entrySet()) {
-            dos.writeInt(entry.getKey());
-            serializeSubtaskState(entry.getValue(), dos);
+        if (operatorState.isFullyFinished()) {
+            dos.writeInt(-1);

Review comment:
       I see @gaoyunhaii concerns. I'd be fine with using `-1` here.

##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/FullyFinishedOperatorState.java
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.runtime.jobgraph.OperatorID;
+import org.apache.flink.runtime.state.memory.ByteStreamStateHandle;
+
+import javax.annotation.Nullable;
+
+/**
+ * A special operator state implementation representing the operators whose 
instances are all
+ * finished.
+ */
+public class FullyFinishedOperatorState extends OperatorState {
+
+    private static final long serialVersionUID = -7094972830573632176L;

Review comment:
       Please use `1L` for `serialVersionUID` as recommended in our coding 
guidelines: 
https://flink.apache.org/contributing/code-style-and-quality-java.html




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


Reply via email to