
org.apache.flink.streaming.runtime.tasks.TimerService Maven / Gradle / Ivy
/*
* 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;
/**
* A common timer service interface with life cycle methods.
*
* The registration of timers follows a life cycle of three phases:
*
*
* - In the initial state, it accepts timer registrations and triggers when the time is reached.
*
- 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.
*
- After a call to {@link #shutdownService()}, all calls to {@link #registerTimer(long,
* ProcessingTimeCallback)} will result in a hard exception.
*
*/
@Internal
public interface TimerService extends ProcessingTimeService {
/** Returns true if the service has been shut down, false otherwise. */
boolean isTerminated();
/**
* Shuts down and clean up the timer service provider hard and immediately. This does not wait
* for any timer to complete. Any further call to {@link #registerTimer(long,
* ProcessingTimeCallback)} will result in a hard exception.
*/
void shutdownService();
/**
* Shuts down and clean up the timer service provider hard and immediately. This does not wait
* for any timer to complete. Any further call to {@link #registerTimer(long,
* ProcessingTimeCallback)} will result in a hard exception. This call cannot be interrupted and
* will block until the shutdown is completed or the timeout is exceeded.
*
* @param timeoutMs timeout for blocking on the service shutdown in milliseconds.
* @return returns true iff the shutdown was completed.
*/
boolean shutdownServiceUninterruptible(long timeoutMs);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy