Class BasicExecutionEngine
java.lang.Object
com.inductiveautomation.ignition.common.execution.impl.BasicExecutionEngine
- All Implemented Interfaces:
ExecutionManager
The ExecutionEngine is a wrapper around a scheduled executor service. Callers are able to create named tasks, and
this class keeps track of associating those names with the ScheduledFutures that represent the actual execution
tasks.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
class
-
Constructor Summary
ConstructorsConstructorDescriptionBasicExecutionEngine
(int threadCount, String name) BasicExecutionEngine
(int threadCount, String name, boolean daemon) BasicExecutionEngine
(int threadCount, String name, ThreadFactory threadFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoid
executeOnce
(Runnable command) Executes a runnable one time as soon as possible.void
executeOnce
(Runnable command, long delay) Excutes a runnable one time after a delay, specified in millisecondsexecuteOnce
(Runnable command, long delay, TimeUnit unit) Executes a runnable after a fixed delaygetName()
void
Modifies the execution rate of the given execution unit.void
modifyFixedRate
(String owner, String name, Runnable command, int newRate, TimeUnit newUnit) void
register
(String owner, String name, SelfSchedulingRunnable command) Registers a self scheduling command to be executed.void
Registers a command to be executing repeatedly at the specified rate.void
Registers a command to be executing repeatedly at the specified rate.void
registerAtFixedRate
(String owner, String name, Runnable command, int rate, TimeUnit unit) Registers a command to be executed with a fixed rate rather than a fixed delay.void
registerAtFixedRateWithInitialDelay
(String owner, String name, Runnable command, int rate, TimeUnit unit, int initialDelay) Registers a command to be executed with a fixed rate after some initial delay.void
registerWithInitialDelay
(String owner, String name, Runnable command, int rate, int initialDelay) Registers a command to be executing repeatedly at the specified rate with an initial delay.void
registerWithInitialDelay
(String owner, String name, Runnable command, int rate, TimeUnit unit, int initialDelay) Registers a command to be executing repeatedly at the specified rate with an initial delay.protected void
scheduleWithFixedDelay
(Runnable command, long initialDelay, long delay, TimeUnit unit) Schedules a runnable to execute with a fixed delay, and after an initial delay, much likeExecutionManager.registerWithInitialDelay(String, String, Runnable, int, TimeUnit, int)
.void
shutdown()
Stops all execution gracefully.protected void
synchedUpdateTaskMap
(String owner, String name, ScheduledFuture<?> future) Updates the task map.toString()
void
unRegister
(String owner, String name) De-registers the execution unit.void
unRegister
(String owner, String name, boolean interrupt) De-registers the execution unit.void
unRegisterAll
(String owner) Unregisters all tasks for a given owner.void
unSchedule
(String taskId)
-
Constructor Details
-
BasicExecutionEngine
public BasicExecutionEngine() -
BasicExecutionEngine
-
BasicExecutionEngine
-
BasicExecutionEngine
-
-
Method Details
-
getName
-
shutdown
public void shutdown()Description copied from interface:ExecutionManager
Stops all execution gracefully.- Specified by:
shutdown
in interfaceExecutionManager
-
schedule
public String schedule(String taskName, Runnable task, String cronPattern) throws it.sauronsoftware.cron4j.InvalidPatternException - Throws:
it.sauronsoftware.cron4j.InvalidPatternException
-
unSchedule
-
register
Description copied from interface:ExecutionManager
Registers a command to be executing repeatedly at the specified rate. If the name is already registered, the existing execution unit will be modified.- Specified by:
register
in interfaceExecutionManager
- Parameters:
owner
- name of the "owner"- just a string qualifier for the command name.name
- identifier used in conjunction with the owner to identify the command.command
- Runnable to be called at the specified rate.rate
- The amount of time to wait in between invocations of the command, in milliseconds.
-
register
Description copied from interface:ExecutionManager
Registers a command to be executing repeatedly at the specified rate. If the name is already registered, the existing execution unit will be modified.- Specified by:
register
in interfaceExecutionManager
- Parameters:
owner
- name of the "owner"- just a string qualifier for the command name.name
- identifier used in conjunction with the owner to identify the command.command
- Runnable to be called at the specified rate.
-
registerAtFixedRate
public void registerAtFixedRate(String owner, String name, Runnable command, int rate, TimeUnit unit) Description copied from interface:ExecutionManager
Registers a command to be executed with a fixed rate rather than a fixed delay.- Specified by:
registerAtFixedRate
in interfaceExecutionManager
-
registerAtFixedRateWithInitialDelay
public void registerAtFixedRateWithInitialDelay(String owner, String name, Runnable command, int rate, TimeUnit unit, int initialDelay) Description copied from interface:ExecutionManager
Registers a command to be executed with a fixed rate after some initial delay.- Specified by:
registerAtFixedRateWithInitialDelay
in interfaceExecutionManager
-
synchedUpdateTaskMap
Updates the task map. Task map MUST be synchronized before calling this. -
registerWithInitialDelay
public void registerWithInitialDelay(String owner, String name, Runnable command, int rate, int initialDelay) Description copied from interface:ExecutionManager
Registers a command to be executing repeatedly at the specified rate with an initial delay.- Specified by:
registerWithInitialDelay
in interfaceExecutionManager
-
registerWithInitialDelay
public void registerWithInitialDelay(String owner, String name, Runnable command, int rate, TimeUnit unit, int initialDelay) Description copied from interface:ExecutionManager
Registers a command to be executing repeatedly at the specified rate with an initial delay.- Specified by:
registerWithInitialDelay
in interfaceExecutionManager
-
modify
Modifies the execution rate of the given execution unit. Basically just unregisters and registers. Can also be used to modify the Runnable associated with the name. -
modifyFixedRate
-
unRegister
De-registers the execution unit. If the unit is in the process of running, it will be interrupted.- Specified by:
unRegister
in interfaceExecutionManager
-
unRegister
De-registers the execution unit.- Specified by:
unRegister
in interfaceExecutionManager
- Parameters:
interrupt
- Interrupts the execution if it is currently occurring. If false, waits for completion.
-
unRegisterAll
Unregisters all tasks for a given owner.- Specified by:
unRegisterAll
in interfaceExecutionManager
-
executeOnce
Executes a runnable one time as soon as possible.- Specified by:
executeOnce
in interfaceExecutionManager
-
executeOnce
Description copied from interface:ExecutionManager
Excutes a runnable one time after a delay, specified in milliseconds- Specified by:
executeOnce
in interfaceExecutionManager
-
executeOnce
public ScheduledFuture<?> executeOnce(Runnable command, long delay, TimeUnit unit) throws RejectedExecutionException Executes a runnable after a fixed delay- Specified by:
executeOnce
in interfaceExecutionManager
- Throws:
RejectedExecutionException
-
register
Description copied from interface:ExecutionManager
Registers a self scheduling command to be executed. Self scheduling commands provide their own execution delay, which can change from exec to exec.- Specified by:
register
in interfaceExecutionManager
-
scheduleNext
-
scheduleWithFixedDelay
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) Description copied from interface:ExecutionManager
Schedules a runnable to execute with a fixed delay, and after an initial delay, much likeExecutionManager.registerWithInitialDelay(String, String, Runnable, int, TimeUnit, int)
. The difference is that this method returns a ScheduledFuture that can be used to cancel the task.- Specified by:
scheduleWithFixedDelay
in interfaceExecutionManager
-
getTaskOwners
-
getTasks
-
toString
-