1996fanrui commented on code in PR #21923:
URL: https://github.com/apache/flink/pull/21923#discussion_r1114505785


##########
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java:
##########
@@ -256,19 +259,27 @@
     private final StreamTaskAsyncExceptionHandler asyncExceptionHandler;
 
     /**
-     * Flag to mark the task "in operation", in which case check needs to be 
initialized to true, so
-     * that early cancel() before invoke() behaves correctly.
+     * INITIALIZED: task constructor was called or on init state. RUNNING: 
task is in operation.
+     * FAILING: task is failing e.g., if an exception has occurred inside 
{@link #invoke()}.
+     * CANCELED: when this task is canceled. FINISHED: task successfully 
terminated.
      */
-    private volatile boolean isRunning;
+    private enum TaskState {
+        FINISHED(Arrays.asList(new TaskState[] {})),
+        CANCELED(Arrays.asList(new TaskState[] {})),
+        RUNNING(Arrays.asList(new TaskState[] {CANCELED, FINISHED})),
+        INITIALIZED(Arrays.asList(new TaskState[] {RUNNING, CANCELED, 
FINISHED}));
 
-    /** Flag to mark this task as canceled. */
-    private volatile boolean canceled;
+        private List<TaskState> validFromStates;
+        private boolean failing = false;

Review Comment:
   After read the comment, I understand it. 
   
   However, it isn't clear for other developers. I'm not sure it's the best way 
address the `failing` and `running`. Let me think more.
   
   If so, I suggest add some comments in the code.



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

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to