com.espertech.esper.schedule
Interface SchedulingService

All Superinterfaces:
TimeProvider
All Known Implementing Classes:
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 add(ScheduleSpec scheduleSpec, ScheduleHandle handle, ScheduleSlot slot)
          Add a callback for a time specified by the schedule specification passed in based on the current time.
 ScheduleBucket allocateBucket()
          Returns a bucket from which slots can be allocated for ordering concurrent callbacks.
 void destroy()
          Destroy the service.
 void evaluate(Collection<ScheduleHandle> handles)
          Evaluate the current time and add to the collection any handles scheduled for execution.
 long getFurthestTimeHandle()
          Returns furthest in the future handle.
 int getScheduleHandleCount()
          Returns count of handles.
 int getTimeHandleCount()
          Returns time handle count.
 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
ScheduleHandleExistsException - to indicate the handle already existed

add

void add(ScheduleSpec scheduleSpec,
         ScheduleHandle handle,
         ScheduleSlot slot)
         throws ScheduleServiceException
Add a callback for a time specified by the schedule specification passed in based on 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:
scheduleSpec - holds the crontab-like information defining the next occurance
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(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

allocateBucket

ScheduleBucket allocateBucket()
Returns a bucket from which slots can be allocated for ordering concurrent callbacks.

Returns:
bucket

destroy

void destroy()
Destroy the service.


getTimeHandleCount

int getTimeHandleCount()
Returns time handle count.

Returns:
count

getFurthestTimeHandle

long getFurthestTimeHandle()
Returns furthest in the future handle.

Returns:
future handle

getScheduleHandleCount

int getScheduleHandleCount()
Returns count of handles.

Returns:
count

© 2007 EsperTech Inc.
All rights reserved.
Visit us at espertech.com