public class BasicExecutionEngine extends java.lang.Object implements ExecutionManager
Modifier and Type | Class and Description |
---|---|
protected class |
BasicExecutionEngine.SelfSchedulingRunner |
class |
BasicExecutionEngine.ThrowableCatchingRunnable |
Constructor and Description |
---|
BasicExecutionEngine() |
BasicExecutionEngine(int threadCount,
java.lang.String name) |
BasicExecutionEngine(int threadCount,
java.lang.String name,
boolean daemon) |
BasicExecutionEngine(int threadCount,
java.lang.String name,
java.util.concurrent.ThreadFactory threadFactory) |
Modifier and Type | Method and Description |
---|---|
void |
executeOnce(java.lang.Runnable command)
Executes a runnable one time as soon as possible.
|
void |
executeOnce(java.lang.Runnable command,
long delay)
Excutes a runnable one time after a delay, specified in milliseconds
|
java.util.concurrent.ScheduledFuture<?> |
executeOnce(java.lang.Runnable command,
long delay,
java.util.concurrent.TimeUnit unit)
Executes a runnable after a fixed delay
|
java.lang.String |
getName() |
java.util.List<java.lang.String> |
getTaskOwners() |
java.util.List<TaskStats> |
getTasks(java.lang.String owner) |
void |
modify(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int newRate,
java.util.concurrent.TimeUnit newUnit)
Modifies the execution rate of the given execution unit.
|
void |
modifyFixedRate(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int newRate,
java.util.concurrent.TimeUnit newUnit) |
void |
register(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int rate)
Registers a command to be executing repeatedly at the specified rate.
|
void |
register(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int rate,
java.util.concurrent.TimeUnit unit)
Registers a command to be executing repeatedly at the specified rate.
|
void |
register(java.lang.String owner,
java.lang.String name,
SelfSchedulingRunnable command)
Registers a self scheduling command to be executed.
|
void |
registerAtFixedRate(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int rate,
java.util.concurrent.TimeUnit unit)
Registers a command to be executed with a fixed rate rather than a fixed delay.
|
void |
registerAtFixedRateWithInitialDelay(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int rate,
java.util.concurrent.TimeUnit unit,
int initialDelay)
Registers a command to be executed with a fixed rate after some initial delay.
|
void |
registerWithInitialDelay(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int rate,
int initialDelay)
Registers a command to be executing repeatedly at the specified rate with an initial delay.
|
void |
registerWithInitialDelay(java.lang.String owner,
java.lang.String name,
java.lang.Runnable command,
int rate,
java.util.concurrent.TimeUnit unit,
int initialDelay)
Registers a command to be executing repeatedly at the specified rate with an initial delay.
|
java.lang.String |
schedule(java.lang.String taskName,
java.lang.Runnable task,
java.lang.String cronPattern) |
protected void |
scheduleNext(BasicExecutionEngine.SelfSchedulingRunner ssr) |
java.util.concurrent.ScheduledFuture<?> |
scheduleWithFixedDelay(java.lang.Runnable command,
long initialDelay,
long delay,
java.util.concurrent.TimeUnit unit)
Schedules a runnable to execute with a fixed delay, and after an initial delay, much like
ExecutionManager.registerWithInitialDelay(String, String, Runnable, int, TimeUnit, int) . |
void |
shutdown()
Stops all execution gracefully.
|
protected void |
synchedUpdateTaskMap(java.lang.String owner,
java.lang.String name,
java.util.concurrent.ScheduledFuture<?> future)
Updates the task map.
|
java.lang.String |
toString() |
void |
unRegister(java.lang.String owner,
java.lang.String name)
De-registers the execution unit.
|
void |
unRegisterAll(java.lang.String owner)
Unregisters all tasks for a given owner.
|
void |
unSchedule(java.lang.String taskId) |
public BasicExecutionEngine()
public BasicExecutionEngine(int threadCount, java.lang.String name)
public BasicExecutionEngine(int threadCount, java.lang.String name, boolean daemon)
public BasicExecutionEngine(int threadCount, java.lang.String name, java.util.concurrent.ThreadFactory threadFactory)
public java.lang.String getName()
public void shutdown()
ExecutionManager
shutdown
in interface ExecutionManager
public java.lang.String schedule(java.lang.String taskName, java.lang.Runnable task, java.lang.String cronPattern) throws it.sauronsoftware.cron4j.InvalidPatternException
it.sauronsoftware.cron4j.InvalidPatternException
public void unSchedule(java.lang.String taskId)
public void register(java.lang.String owner, java.lang.String name, java.lang.Runnable command, int rate)
ExecutionManager
register
in interface ExecutionManager
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.public void register(java.lang.String owner, java.lang.String name, java.lang.Runnable command, int rate, java.util.concurrent.TimeUnit unit)
ExecutionManager
register
in interface ExecutionManager
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.public void registerAtFixedRate(java.lang.String owner, java.lang.String name, java.lang.Runnable command, int rate, java.util.concurrent.TimeUnit unit)
ExecutionManager
registerAtFixedRate
in interface ExecutionManager
public void registerAtFixedRateWithInitialDelay(java.lang.String owner, java.lang.String name, java.lang.Runnable command, int rate, java.util.concurrent.TimeUnit unit, int initialDelay)
ExecutionManager
registerAtFixedRateWithInitialDelay
in interface ExecutionManager
protected void synchedUpdateTaskMap(java.lang.String owner, java.lang.String name, java.util.concurrent.ScheduledFuture<?> future)
owner
- name
- future
- public void registerWithInitialDelay(java.lang.String owner, java.lang.String name, java.lang.Runnable command, int rate, int initialDelay)
ExecutionManager
registerWithInitialDelay
in interface ExecutionManager
public void registerWithInitialDelay(java.lang.String owner, java.lang.String name, java.lang.Runnable command, int rate, java.util.concurrent.TimeUnit unit, int initialDelay)
ExecutionManager
registerWithInitialDelay
in interface ExecutionManager
public void modify(java.lang.String owner, java.lang.String name, java.lang.Runnable command, int newRate, java.util.concurrent.TimeUnit newUnit)
owner
- name
- newRate
- newUnit
- public void modifyFixedRate(java.lang.String owner, java.lang.String name, java.lang.Runnable command, int newRate, java.util.concurrent.TimeUnit newUnit)
public void unRegister(java.lang.String owner, java.lang.String name)
unRegister
in interface ExecutionManager
owner
- name
- public void unRegisterAll(java.lang.String owner)
unRegisterAll
in interface ExecutionManager
public void executeOnce(java.lang.Runnable command)
executeOnce
in interface ExecutionManager
public void executeOnce(java.lang.Runnable command, long delay)
ExecutionManager
executeOnce
in interface ExecutionManager
public java.util.concurrent.ScheduledFuture<?> executeOnce(java.lang.Runnable command, long delay, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.RejectedExecutionException
executeOnce
in interface ExecutionManager
java.util.concurrent.RejectedExecutionException
public void register(java.lang.String owner, java.lang.String name, SelfSchedulingRunnable command)
ExecutionManager
register
in interface ExecutionManager
protected void scheduleNext(BasicExecutionEngine.SelfSchedulingRunner ssr)
public java.util.concurrent.ScheduledFuture<?> scheduleWithFixedDelay(java.lang.Runnable command, long initialDelay, long delay, java.util.concurrent.TimeUnit unit)
ExecutionManager
ExecutionManager.registerWithInitialDelay(String, String, Runnable, int, TimeUnit, int)
. The difference is that this
method returns a ScheduledFuture that can be used to cancel the task.scheduleWithFixedDelay
in interface ExecutionManager
public java.util.List<java.lang.String> getTaskOwners()
public java.util.List<TaskStats> getTasks(java.lang.String owner)
public java.lang.String toString()
toString
in class java.lang.Object