pnowojski commented on a change in pull request #11486: [FLINK-16712][task] 
Refactor StreamTask to construct final fields
URL: https://github.com/apache/flink/pull/11486#discussion_r396385124
 
 

 ##########
 File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java
 ##########
 @@ -260,17 +258,28 @@ protected StreamTask(
                        @Nullable TimerService timerService,
                        Thread.UncaughtExceptionHandler 
uncaughtExceptionHandler,
                        StreamTaskActionExecutor actionExecutor,
-                       TaskMailbox mailbox) {
+                       TaskMailbox mailbox) throws Exception {
 
                super(environment);
 
-               this.timerService = timerService;
-               this.uncaughtExceptionHandler = 
Preconditions.checkNotNull(uncaughtExceptionHandler);
                this.configuration = new StreamConfig(getTaskConfiguration());
                this.recordWriter = createRecordWriterDelegate(configuration, 
environment);
                this.actionExecutor = 
Preconditions.checkNotNull(actionExecutor);
                this.mailboxProcessor = new 
MailboxProcessor(this::processInput, mailbox, actionExecutor);
                this.asyncExceptionHandler = new 
StreamTaskAsyncExceptionHandler(environment);
+               this.asyncOperationsThreadPool = Executors.newCachedThreadPool(
+                       new ExecutorThreadFactory("AsyncOperations", 
uncaughtExceptionHandler));
+
+               this.stateBackend = createStateBackend();
+               this.checkpointStorage = 
stateBackend.createCheckpointStorage(getEnvironment().getJobID());
 
 Review comment:
   How long running are those calls? If they are touching some IO files, they 
might take quite some time and with your change, they would happen before the 
following lines in `Task` class:
   ```
                        // switch to the RUNNING state, if that fails, we have 
been canceled/failed in the meantime
                        if (!transitionState(ExecutionState.DEPLOYING, 
ExecutionState.RUNNING)) {
                                throw new CancelTaskException();
                        }
   
                        // notify everyone that we switched to running
                        taskManagerActions.updateTaskExecutionState(new 
TaskExecutionState(jobId, executionId, ExecutionState.RUNNING));
   
                        // make sure the user code classloader is accessible 
thread-locally
                        
executingThread.setContextClassLoader(userCodeClassLoader);
   ```
   as oppose to running after them, as it is now. I'm not sure what could be 
the side effects?

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


With regards,
Apache Git Services

Reply via email to