Package ortus.boxlang.runtime.services
Class SchedulerService
java.lang.Object
ortus.boxlang.runtime.services.BaseService
ortus.boxlang.runtime.services.SchedulerService
- All Implemented Interfaces:
IService
This service manages all schedulers in the system.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
The default shutdown timeout for the scheduler serviceFields inherited from class ortus.boxlang.runtime.services.BaseService
name, runtime, timerUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclearSchedulers
(Boolean force, Long timeout) Clear all schedulers from the service.getScheduler
(Key name) Get a scheduler by nameGet all the registered scheduler names as a BoxLang ArraygetSchedulerOrFail
(Key name) Get a scheduler or fail the call with an exception if it does not existGet all schedulersGet all scheduler task statsgetSchedulerStats
(Key name) Get a single scheduler task statsboolean
hasScheduler
(Key name) Do we have a scheduler by this name?loadScheduler
(Key name, IScheduler scheduler) This method is used to load a scheduler into the service.void
The configuration load event is fired when the runtime loads the configurationvoid
onShutdown
(Boolean force) The shutdown event is fired when the runtime shuts downvoid
The startup event is fired when the runtime starts upregisterAndStartScheduler
(IScheduler scheduler, Boolean force) Register a scheduler with the servicevoid
Register all global schedulers found in the boxlang.json configregisterScheduler
(IScheduler scheduler) Register a scheduler with the serviceregisterScheduler
(IScheduler scheduler, Boolean force) Register a scheduler with the serviceboolean
removeScheduler
(Key name) Remove a scheduler from the service.boolean
removeScheduler
(Key name, boolean force, long timeout) Remove a scheduler from the service.restartScheduler
(Key name) Restart the scheduler if it exists.restartScheduler
(Key name, boolean force, long timeout) Restart the scheduler if it existsvoid
shutdownScheduler
(IScheduler scheduler, boolean force, long timeout) Shutdown the schedulervoid
shutdownScheduler
(Key scheduler, boolean force, long timeout) Shutdown the schedulerint
size()
How many schedulers do we have registeredStartup all the registered schedulers This is called by the runtime when it starts upstartupScheduler
(IScheduler scheduler) Start a scheduler if not started alreadyMethods inherited from class ortus.boxlang.runtime.services.BaseService
announce, announce, announce, announce, getName, getRuntime, getTimerUtil
-
Field Details
-
DEFAULT_SHUTDOWN_TIMEOUT
public static final long DEFAULT_SHUTDOWN_TIMEOUTThe default shutdown timeout for the scheduler service- See Also:
-
-
Constructor Details
-
SchedulerService
Constructor- Parameters:
runtime
- The BoxRuntime
-
-
Method Details
-
onConfigurationLoad
public void onConfigurationLoad()The configuration load event is fired when the runtime loads the configuration- Specified by:
onConfigurationLoad
in interfaceIService
- Specified by:
onConfigurationLoad
in classBaseService
-
onStartup
public void onStartup()The startup event is fired when the runtime starts up- Specified by:
onStartup
in interfaceIService
- Specified by:
onStartup
in classBaseService
-
registerGlobalSchedulers
public void registerGlobalSchedulers()Register all global schedulers found in the boxlang.json config -
onShutdown
The shutdown event is fired when the runtime shuts down- Specified by:
onShutdown
in interfaceIService
- Specified by:
onShutdown
in classBaseService
- Parameters:
force
- If true, forces the shutdown of the scheduler
-
startupRegisteredSchedulers
Startup all the registered schedulers This is called by the runtime when it starts up -
startupScheduler
Start a scheduler if not started already- Parameters:
scheduler
- The scheduler to start- Returns:
- Scheduler
-
getSchedulers
Get all schedulers- Returns:
- The schedulers
-
getSchedulerNames
Get all the registered scheduler names as a BoxLang Array -
getScheduler
Get a scheduler by name- Parameters:
name
- The name of the scheduler- Returns:
- The scheduler or null if not found
-
getSchedulerOrFail
Get a scheduler or fail the call with an exception if it does not exist- Parameters:
name
- The name of the scheduler- Returns:
- The scheduler
- Throws:
BoxRuntimeException
- If the scheduler is not found
-
getSchedulerStats
Get a single scheduler task stats- Parameters:
name
- The name of the scheduler- Returns:
- The scheduler task stats
- Throws:
BoxRuntimeException
- If the scheduler is not found
-
getSchedulerStats
Get all scheduler task stats- Returns:
- A struct with all the scheduler task stats
-
size
public int size()How many schedulers do we have registered- Returns:
- The number of schedulers
-
hasScheduler
Do we have a scheduler by this name?- Parameters:
name
- The name of the scheduler
-
registerScheduler
Register a scheduler with the service- Parameters:
scheduler
- The IScheduler to register- Returns:
- The scheduler
- Throws:
BoxRuntimeException
- If a scheduler with the same name already exists
-
registerAndStartScheduler
Register a scheduler with the service- Parameters:
scheduler
- The IScheduler to registerforce
- If true, forces the registration of the scheduler- Returns:
- The scheduler
- Throws:
BoxRuntimeException
- If a scheduler with the same name already exists but force is false
-
registerScheduler
Register a scheduler with the service- Parameters:
scheduler
- The IScheduler to registerforce
- If true, forces the registration of the scheduler- Returns:
- The scheduler
- Throws:
BoxRuntimeException
- If a scheduler with the same name already exists but force is false
-
loadScheduler
This method is used to load a scheduler into the service. If the scheduler already exists, it will be replaced. This is usually used from the ModuleService to load a module scheduler- Parameters:
name
- The name of the schedulerscheduler
- The IScheduler to load- Returns:
-
removeScheduler
Remove a scheduler from the service. This will also shutdown the scheduler.- Parameters:
name
- The name of the schedulerforce
- If true, forces the shutdown of the schedulertimeout
- The timeout in milliseconds to wait for the scheduler to shutdown- Returns:
- True if the scheduler was removed, false if it was not found
-
removeScheduler
Remove a scheduler from the service. This will also shutdown the scheduler gracefully- Parameters:
name
- The name of the scheduler- Returns:
- True if the scheduler was removed, false if it was not found
-
clearSchedulers
Clear all schedulers from the service. This will also shutdown all the schedulers- Parameters:
force
- If true, forces the shutdown of the schedulertimeout
- The timeout in milliseconds to wait for the scheduler to shutdown
-
restartScheduler
Restart the scheduler if it exists- Parameters:
name
- The name of the schedulerforce
- If true, forces the shutdown of the schedulertimeout
- The timeout in milliseconds to wait for the scheduler to shutdown- Throws:
BoxRuntimeException
- If the scheduler is not found
-
restartScheduler
Restart the scheduler if it exists. Not forced- Parameters:
name
- The name of the scheduler- Throws:
BoxRuntimeException
- If the scheduler is not found
-
shutdownScheduler
Shutdown the scheduler- Parameters:
scheduler
- The scheduler to shutdownforce
- If true, forces the shutdown of the schedulertimeout
- The timeout in seconds to wait for the scheduler to shutdown
-
shutdownScheduler
Shutdown the scheduler- Parameters:
scheduler
- The scheduler name to shutdownforce
- If true, forces the shutdown of the schedulertimeout
- The timeout in seconds to wait for the scheduler to shutdown
-