
cz.seznam.euphoria.inmem.TriggerScheduler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of euphoria-inmem Show documentation
Show all versions of euphoria-inmem Show documentation
An all-in-memory executing euphoria executor suitable
for executing flows in unit tests.
The newest version!
/**
* Copyright 2016-2017 Seznam.cz, a.s.
*
* Licensed 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 cz.seznam.euphoria.inmem;
import cz.seznam.euphoria.core.client.dataset.windowing.Window;
/**
* Schedules and fires registered triggers according to internal time.
*
* @param the type of windows this scheduler is able to handle
* @param the type of keys this scheduler is able to handle
*/
public interface TriggerScheduler {
/**
* Fire specific trigger on given time.
* Schedule the given trigger at the given stamp.
* The trigger will be fired as close to the time as possible.
*
* @param stamp the time stamp to schedule the action for
* @param window the window to be supplied when triggering the action
* @param trigger the function to be triggered when stamp has been reached
*
* @return true if the triggerable has been scheduled,
* false if the time already passed
*/
boolean scheduleAt(long stamp, KeyedWindow window, Triggerable trigger);
/**
* Retrieve current timestamp this triggering is on.
* This can be either a real system timestamp or the last
* timestamp updated by call to `updateStamp'.
*
* @return the current timestamp as seen by this scheduler
*/
long getCurrentTimestamp();
/**
* Cancel all scheduled tasks
*/
void cancelAll();
/**
* Cancel previously registered timer
*
* @param stamp the time stamp of a previously registered schedule
* @param window the window for this to cancel the timer
*/
void cancel(long stamp, KeyedWindow window);
/**
* Update the internal timestamp (optional operation).
*
* @param stamp the new, advanced time stamp
*/
default void updateStamp(long stamp) {
// nop
}
/**
* Close all triggers and destroy the triggering.
*/
void close();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy