Package org.drools.core.time.impl
Class PseudoClockScheduler
java.lang.Object
org.drools.core.time.impl.PseudoClockScheduler
- All Implemented Interfaces:
Externalizable,Serializable,InternalSchedulerService,SchedulerService,SessionPseudoClock,TimerService,SessionClock,SessionPseudoClock
public class PseudoClockScheduler
extends Object
implements TimerService, SessionPseudoClock, Externalizable, InternalSchedulerService
A PseudoClockScheduler is a scheduler based on a user controlled clock
that allows the user to explicitly control current time.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AtomicLongprotected PriorityQueue<TimerJobInstance>protected AtomicLong -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongadvanceTime(long amount, TimeUnit unit) longReturns the current time from the scheduler clockgetTimerJobInstances(long id) This method may return null for some TimerService implementations that do not want the overhead of maintain this.longReturns the number of time units (usually ms) to the next scheduled jobvoidinternalSchedule(TimerJobInstance timerJobInstance) voidvoidRemove the job identified by the given job handle from the scheduled queuevoidreset()Reset this servicescheduleJob(Job job, JobContext ctx, Trigger trigger) Schedule a job for later executionvoidsetStartupTime(long i) voidsetTimerJobFactoryManager(TimerJobFactoryManager timerJobFactoryManager) voidshutdown()Shuts the service downvoid
-
Field Details
-
timer
-
queue
-
idCounter
-
-
Constructor Details
-
PseudoClockScheduler
public PseudoClockScheduler()
-
-
Method Details
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
setTimerJobFactoryManager
- Specified by:
setTimerJobFactoryManagerin interfaceTimerService
-
getTimerJobFactoryManager
- Specified by:
getTimerJobFactoryManagerin interfaceTimerService
-
getCurrentTime
public long getCurrentTime()Description copied from interface:TimerServiceReturns the current time from the scheduler clock- Specified by:
getCurrentTimein interfaceSessionClock- Specified by:
getCurrentTimein interfaceTimerService- Returns:
- the current timestamp
-
scheduleJob
Description copied from interface:SchedulerServiceSchedule a job for later execution- Specified by:
scheduleJobin interfaceSchedulerService- Returns:
-
internalSchedule
- Specified by:
internalSchedulein interfaceInternalSchedulerService
-
removeJob
Description copied from interface:SchedulerServiceRemove the job identified by the given job handle from the scheduled queue- Specified by:
removeJobin interfaceSchedulerService- Parameters:
jobHandle- the job identity handle
-
advanceTime
- Specified by:
advanceTimein interfaceSessionPseudoClock
-
setStartupTime
public void setStartupTime(long i) -
reset
public void reset()Description copied from interface:TimerServiceReset this service- Specified by:
resetin interfaceTimerService
-
shutdown
public void shutdown()Description copied from interface:TimerServiceShuts the service down- Specified by:
shutdownin interfaceTimerService
-
getTimeToNextJob
public long getTimeToNextJob()Description copied from interface:TimerServiceReturns the number of time units (usually ms) to the next scheduled job- Specified by:
getTimeToNextJobin interfaceTimerService- Returns:
- the number of time units until the next scheduled job or -1 if there is no job scheduled
-
getTimerJobInstances
Description copied from interface:TimerServiceThis method may return null for some TimerService implementations that do not want the overhead of maintain this.- Specified by:
getTimerJobInstancesin interfaceTimerService- Returns:
-