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,org.kie.api.time.SessionClock,org.kie.api.time.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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PseudoClockScheduler()PseudoClockScheduler(InternalWorkingMemory session)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longadvanceTime(long amount, TimeUnit unit)longgetCurrentTime()Returns the current time from the scheduler clockInternalWorkingMemorygetSession()TimerJobFactoryManagergetTimerJobFactoryManager()Collection<TimerJobInstance>getTimerJobInstances(long id)This method may return null for some TimerService implementations that do not want the overhead of maintain this.longgetTimeToNextJob()Returns the number of time units (usually ms) to the next scheduled jobvoidinternalSchedule(TimerJobInstance timerJobInstance)voidreadExternal(ObjectInput in)booleanremoveJob(JobHandle jobHandle)Remove the job identified by the given job handle from the scheduled queuevoidreset()Reset this serviceJobHandlescheduleJob(Job job, JobContext ctx, Trigger trigger)Schedule a job for later executionvoidsetSession(InternalWorkingMemory session)voidsetStartupTime(long i)voidsetTimerJobFactoryManager(TimerJobFactoryManager timerJobFactoryManager)voidshutdown()Shuts the service downvoidwriteExternal(ObjectOutput out)
-
-
-
Constructor Detail
-
PseudoClockScheduler
public PseudoClockScheduler()
-
PseudoClockScheduler
public PseudoClockScheduler(InternalWorkingMemory session)
-
-
Method Detail
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
setTimerJobFactoryManager
public void setTimerJobFactoryManager(TimerJobFactoryManager timerJobFactoryManager)
- Specified by:
setTimerJobFactoryManagerin interfaceTimerService
-
getTimerJobFactoryManager
public TimerJobFactoryManager getTimerJobFactoryManager()
- Specified by:
getTimerJobFactoryManagerin interfaceTimerService
-
getCurrentTime
public long getCurrentTime()
Description copied from interface:TimerServiceReturns the current time from the scheduler clock- Specified by:
getCurrentTimein interfaceorg.kie.api.time.SessionClock- Specified by:
getCurrentTimein interfaceTimerService- Returns:
- the current timestamp
-
scheduleJob
public JobHandle scheduleJob(Job job, JobContext ctx, Trigger trigger)
Description copied from interface:SchedulerServiceSchedule a job for later execution- Specified by:
scheduleJobin interfaceSchedulerService- Returns:
-
internalSchedule
public void internalSchedule(TimerJobInstance timerJobInstance)
- Specified by:
internalSchedulein interfaceInternalSchedulerService
-
removeJob
public boolean removeJob(JobHandle jobHandle)
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- Returns:
-
advanceTime
public long advanceTime(long amount, TimeUnit unit)- Specified by:
advanceTimein interfaceorg.kie.api.time.SessionPseudoClock
-
setStartupTime
public void setStartupTime(long i)
-
getSession
public InternalWorkingMemory getSession()
- Returns:
- the session
-
setSession
public void setSession(InternalWorkingMemory session)
- Parameters:
session- the session to set
-
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
public Collection<TimerJobInstance> getTimerJobInstances(long id)
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:
-
-