public final class SchedulingServiceImpl extends Object implements SchedulingServiceSPI
Synchronized since statement creation and event evaluation by multiple (event send) threads can lead to callbacks added/removed asynchronously.
Constructor and Description |
---|
SchedulingServiceImpl(TimeSourceService timeSourceService)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
add(long afterTime,
ScheduleHandle handle,
long slot)
Add a callback for after the given milliseconds from the current time.
|
void |
apply(ScheduleSet scheduleSet)
Apply the set of schedules.
|
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.
|
String |
getFurthestTimeHandleDate() |
Long |
getNearestTimeHandle() |
String |
getNearestTimeHandleDate() |
int |
getScheduleHandleCount()
Returns count of handles.
|
long |
getTime()
Returns the current engine time.
|
int |
getTimeHandleCount()
Returns time handle count.
|
void |
init()
Initialization is optional and provides a chance to preload things after statements are available.
|
boolean |
isScheduled(ScheduleHandle handle)
Returns true if the handle has been scheduled already.
|
void |
remove(ScheduleHandle handle,
long slot)
Remove a handle.
|
void |
setTime(long currentTime)
Set the time based upon which the evaluation of events invokes callbacks.
|
ScheduleSet |
take(Set<Integer> statementIds)
Take a statement's schedules out of the currently active set of schedules.
|
void |
visitSchedules(ScheduleVisitor visitor) |
public SchedulingServiceImpl(TimeSourceService timeSourceService)
timeSourceService
- time source providerpublic void destroy()
SchedulingService
destroy
in interface SchedulingService
public long getTime()
TimeProvider
getTime
in interface TimeProvider
public final void setTime(long currentTime)
SchedulingService
setTime
in interface SchedulingService
currentTime
- to setpublic final void add(long afterTime, ScheduleHandle handle, long slot) throws ScheduleServiceException
SchedulingService
add
in interface SchedulingService
afterTime
- number of millisec to get a callbackhandle
- to addslot
- allows ordering of concurrent callbacksScheduleServiceException
- thrown if the add operation did not completepublic final void remove(ScheduleHandle handle, long slot)
SchedulingService
remove
in interface SchedulingService
handle
- to removeslot
- for which the callback was addedpublic final void evaluate(Collection<ScheduleHandle> handles)
SchedulingService
evaluate
in interface SchedulingService
handles
- is a collection of handles populated by the service with any callbacks due
for the current timepublic ScheduleSet take(Set<Integer> statementIds)
SchedulingServiceSPI
take
in interface SchedulingServiceSPI
statementIds
- statements to take outpublic void apply(ScheduleSet scheduleSet)
SchedulingServiceSPI
apply
in interface SchedulingServiceSPI
scheduleSet
- to applypublic void init()
SchedulingServiceSPI
init
in interface SchedulingServiceSPI
public int getTimeHandleCount()
SchedulingService
getTimeHandleCount
in interface SchedulingService
public String getFurthestTimeHandleDate()
public String getNearestTimeHandleDate()
public Long getFurthestTimeHandle()
SchedulingService
getFurthestTimeHandle
in interface SchedulingService
public int getScheduleHandleCount()
SchedulingService
getScheduleHandleCount
in interface SchedulingService
public boolean isScheduled(ScheduleHandle handle)
SchedulingService
isScheduled
in interface SchedulingService
handle
- to checkpublic Long getNearestTimeHandle()
getNearestTimeHandle
in interface SchedulingServiceSPI
public void visitSchedules(ScheduleVisitor visitor)
visitSchedules
in interface SchedulingServiceSPI