zhuzhurk commented on a change in pull request #13766:
URL: https://github.com/apache/flink/pull/13766#discussion_r514952083



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/TaskExecutionStateWrapper.java
##########
@@ -0,0 +1,102 @@
+/*
+ * 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.executiongraph;
+
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.runtime.accumulators.AccumulatorSnapshot;
+import org.apache.flink.runtime.execution.ExecutionState;
+import org.apache.flink.runtime.taskmanager.TaskExecutionState;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+import static org.apache.flink.util.Preconditions.checkState;
+
+/**
+ * Wraps {@link TaskExecutionState}, along with actions to take
+ * if it is FAILED state.
+ */
+public class TaskExecutionStateWrapper {
+
+       private final TaskExecutionState taskExecutionState;
+
+       /**
+        * Indicating whether to send a PRC call to remove task from 
TaskManager.
+        * True if the failure is fired by JobManager and the execution is 
already
+        * deployed. Otherwise it should be false.
+        */
+       private final boolean cancelTask;
+
+       private final boolean releasePartitions;
+
+       private TaskExecutionStateWrapper(
+                       final TaskExecutionState taskExecutionState,
+                       final boolean cancelTask,
+                       final boolean releasePartitions) {
+
+               this.taskExecutionState = checkNotNull(taskExecutionState);
+               this.cancelTask = cancelTask;
+               this.releasePartitions = releasePartitions;
+       }
+
+       public Throwable getError(ClassLoader userCodeClassloader) {
+               return taskExecutionState.getError(userCodeClassloader);
+       }
+
+       public ExecutionAttemptID getID() {
+               return taskExecutionState.getID();
+       }
+
+       public ExecutionState getExecutionState() {
+               return taskExecutionState.getExecutionState();
+       }
+
+       public JobID getJobID() {
+               return taskExecutionState.getJobID();
+       }
+
+       public AccumulatorSnapshot getAccumulators() {
+               return taskExecutionState.getAccumulators();
+       }
+
+       public IOMetrics getIOMetrics() {
+               return taskExecutionState.getIOMetrics();
+       }
+
+       public boolean getCancelTask() {
+               checkState(taskExecutionState.getExecutionState() == 
ExecutionState.FAILED);

Review comment:
       Ok. I will remove the check. Also regarding your other comments, I think 
we do not need factory methods to differentiate whether it is created for 
FAILED state. I will add 2 constructors instead. One needs to specify the 
`cancelTask/releasePartitions` flags if the they need to be `true`.




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