akalash commented on code in PR #21923:
URL: https://github.com/apache/flink/pull/21923#discussion_r1114433452


##########
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:
   @1996fanrui , or if your question is why at all do we need to have `failing` 
as a field rather than as enum. it's because nobody wants to change the current 
logic in this PR. but currently `running` and `failing` can be `true` at the 
same time. (see this thread 
-https://github.com/apache/flink/pull/21923#discussion_r1111988132 )



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