Zakelly commented on code in PR #26071: URL: https://github.com/apache/flink/pull/26071#discussion_r1928083858
########## flink-runtime/src/main/java/org/apache/flink/streaming/api/operators/sorted/state/BatchExecutionInternalTimeServiceWithAsyncState.java: ########## @@ -0,0 +1,85 @@ +/* + * 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.streaming.api.operators.sorted.state; + +import org.apache.flink.runtime.asyncprocessing.AsyncExecutionController; +import org.apache.flink.runtime.asyncprocessing.RecordContext; +import org.apache.flink.streaming.api.operators.InternalTimer; +import org.apache.flink.streaming.api.operators.InternalTimerService; +import org.apache.flink.streaming.api.operators.Triggerable; +import org.apache.flink.streaming.runtime.tasks.ProcessingTimeService; +import org.apache.flink.util.function.ThrowingRunnable; + +/** + * An implementation of a {@link InternalTimerService} that manages timers with a single active key + * at a time. Can be used in a BATCH execution mode cooperating with async state operators. + */ +public class BatchExecutionInternalTimeServiceWithAsyncState<K, N> + extends BatchExecutionInternalTimeService<K, N> { + + private AsyncExecutionController<K> asyncExecutionController; + + BatchExecutionInternalTimeServiceWithAsyncState( + ProcessingTimeService processingTimeService, Triggerable<K, N> triggerTarget) { + super(processingTimeService, triggerTarget); + } + + /** Set up the async execution controller. */ + public void setup(AsyncExecutionController<K> asyncExecutionController) { + if (asyncExecutionController != null) { + this.asyncExecutionController = asyncExecutionController; + } + } + + /** + * Sets the current key. Timers that are due to be fired are collected and will be triggered. + */ + @Override + public void setCurrentKey(K currentKey) throws Exception { Review Comment: The core difference between timer service for async operators and the original one is here. Replace direct call of `triggerTarget.onXXXXXTime()` with a wrapper of `maintainContextAndProcess` -- 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