com.espertech.esper.schedule
Interface SchedulingService

All Superinterfaces:
TimeProvider
All Known Subinterfaces:
SchedulingServiceSPI
All Known Implementing Classes:
SchedulingServiceAudit, SchedulingServiceImpl

public interface SchedulingService
extends TimeProvider

Interface for a service that allows to add and remove handles (typically storing callbacks) for a certain time which are returned when the evaluate method is invoked and the current time is on or after the handle's registered time. It is the expectation that the setTime method is called with same or ascending values for each subsequent call. Handles with are triggered are automatically removed by implementations.


Method Summary
 void add(long afterMSec, ScheduleHandle handle, ScheduleSlot slot)
          Add a callback for after the given milliseconds from the current time.
 void destroy()
          Destroy the service.
 void evaluate(java.util.Collection<ScheduleHandle> handles)
          Evaluate the current time and add to the collection any handles scheduled for execution.
 java.lang.Long getFurthestTimeHandle()
          Returns furthest in the future handle.
 int getScheduleHandleCount()
          Returns count of handles.
 int getTimeHandleCount()
          Returns time handle count.
 boolean isScheduled(ScheduleHandle handle)
          Returns true if the handle has been scheduled already.
 void remove(ScheduleHandle handle, ScheduleSlot slot)
          Remove a handle.
 void setTime(long timestamp)
          Set the time based upon which the evaluation of events invokes callbacks.
 
Methods inherited from interface com.espertech.esper.schedule.TimeProvider
getTime
 

Method Detail

add

void add(long afterMSec,
         ScheduleHandle handle,
         ScheduleSlot slot)
         throws ScheduleServiceException
Add a callback for after the given milliseconds from the current time. If the same callback (equals) was already added before, the method will not add a new callback or change the existing callback to a new time, but throw an exception.

Parameters:
afterMSec - number of millisec to get a callback
handle - to add
slot - allows ordering of concurrent callbacks
Throws:
ScheduleServiceException - thrown if the add operation did not complete

remove

void remove(ScheduleHandle handle,
            ScheduleSlot slot)
            throws ScheduleServiceException
Remove a handle. If the handle to be removed was not found an exception is thrown.

Parameters:
handle - to remove
slot - for which the callback was added
Throws:
ScheduleServiceException - thrown if the callback was not located

setTime

void setTime(long timestamp)
Set the time based upon which the evaluation of events invokes callbacks.

Parameters:
timestamp - to set

evaluate

void evaluate(java.util.Collection<ScheduleHandle> handles)
Evaluate the current time and add to the collection any handles scheduled for execution.

Parameters:
handles - is a collection of handles populated by the service with any callbacks due for the current time

destroy

void destroy()
Destroy the service.


getTimeHandleCount

int getTimeHandleCount()
Returns time handle count.

Returns:
count

getFurthestTimeHandle

java.lang.Long getFurthestTimeHandle()
Returns furthest in the future handle.

Returns:
future handle

getScheduleHandleCount

int getScheduleHandleCount()
Returns count of handles.

Returns:
count

isScheduled

boolean isScheduled(ScheduleHandle handle)
Returns true if the handle has been scheduled already.

Parameters:
handle - to check
Returns:
indicator whether the handle is in use

© 2006-2015 EsperTech Inc.
All rights reserved.
Visit us at espertech.com