1u0 commented on a change in pull request #9735: [FLINK-14156][runtime] Submit timer trigger letters to task's mailbox with operator's precedence URL: https://github.com/apache/flink/pull/9735#discussion_r330543800
########## File path: flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/TimerService.java ########## @@ -0,0 +1,77 @@ +/* + * 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.runtime.tasks; + +import org.apache.flink.annotation.Internal; + +/** + * + * <p>The registration of timers follows a life cycle of three phases: + * <ol> + * <li>In the initial state, it accepts timer registrations and triggers when the time is reached.</li> + * <li>After calling {@link #quiesce()}, further calls to + * {@link #registerTimer(long, ProcessingTimeCallback)} will not register any further timers, and will + * return a "dummy" future as a result. This is used for clean shutdown, where currently firing + * timers are waited for and no future timers can be scheduled, without causing hard exceptions.</li> + * <li>After a call to {@link #shutdownService()}, all calls to {@link #registerTimer(long, ProcessingTimeCallback)} + * will result in a hard exception.</li> + * </ol> + */ +@Internal +public interface TimerService extends ProcessingTimeService { Review comment: Although, the commit message says that the lifecycle methods were extracted into a separate interface, my main motivation was to separate "application level api" (`ProcessingTimeService` that exposed to operators) from the system timer provider (implementation of `TimerService`). It just happens that currently in this PR `TimerService` piggybacks on `ProcessingTimeService` interface (and `ProcessingTimeCallback`) to define the system timer api. I can introduce a new, separate timer api for `TimerService` to explicitly separate them. It should not make big changes in the runtime code, only some tests should be affected to be more explicit what they are testing against. I'd like to hear from others if you are ok with this direction. Regarding the naming, `ProcessingTimeService` is simply the preserved name that operators see and `TimerService` is a common name in Flink code base for classes with similar functionality. Introducing a common "life-cycle" interface may be too early generalization on my side. Also, unifying/consolidating the `TimerService` classes may be a separate effort on it's own. ---------------------------------------------------------------- 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
