rkhachatryan commented on a change in pull request #10151: [FLINK-14231] Handle 
the processing-time timers when closing operators to make endInput semantics on 
the operator chain strict
URL: https://github.com/apache/flink/pull/10151#discussion_r356034601
 
 

 ##########
 File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java
 ##########
 @@ -1011,10 +989,25 @@ TimerService getTimerService() {
                return timerService;
        }
 
-       public ProcessingTimeService getProcessingTimeService(int 
operatorIndex) {
+       @VisibleForTesting
+       StreamOperator<?> getHeadOperator() {
+               return operatorChain.getHeadOperator();
+       }
+
+       public ProcessingTimeService getProcessingTimeService(OperatorID 
operatorID) {
+               Preconditions.checkNotNull(operatorID);
                Preconditions.checkState(timerService != null, "The timer 
service has not been initialized.");
-               MailboxExecutor mailboxExecutor = 
mailboxProcessor.getMailboxExecutor(operatorIndex);
-               return new ProcessingTimeServiceImpl(timerService, callback -> 
deferCallbackToMailbox(mailboxExecutor, callback));
+               Preconditions.checkState(operatorChain != null, "operatorChain 
has not been initialized.");
+
+               ProcessingTimeService processingTimeService = 
operatorChain.getOperatorProcessingTimeService(operatorID);
+               if (processingTimeService == null) {
+                       processingTimeService = new ProcessingTimeServiceImpl(
+                               timerService,
+                               callback -> 
deferCallbackToMailbox(operatorChain.getOperatorMailboxExecutor(operatorID), 
callback));
+                       
operatorChain.setOperatorProcessingTimeService(operatorID, 
(ProcessingTimeServiceImpl) processingTimeService);
+               }
 
 Review comment:
   And neither `StreamTask` nor `OperatorChain` need `ProcessingTimeService` - 
they only return it back to `StreamOperator`.

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