Package org.nuxeo.ecm.core.scheduler
Class SchedulerServiceImpl
java.lang.Object
org.nuxeo.runtime.model.DefaultComponent
org.nuxeo.ecm.core.scheduler.SchedulerServiceImpl
- All Implemented Interfaces:
SchedulerService
,Adaptable
,Component
,Extensible
,TimestampedService
Schedule service implementation. Since the cleanup of the quartz job is done when service is activated, ( see
https://jira.nuxeo.com/browse/NXP-7303 ) in cluster mode, the schedules contributions MUST be the same on all nodes.
Due the fact that all jobs are removed when service starts on a node it may be a short period with no schedules in
quartz table even other node is running.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Duration
Default value is set to 5 seconds to delay the start by defaultstatic final String
static final Duration
static final String
protected RuntimeContext
protected final ScheduleExtensionRegistry
protected org.quartz.Scheduler
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
activate
(ComponentContext context) Activates the component.void
deactivate
(ComponentContext context) Deactivates the component.Gets the list of the registered schedules.boolean
Checks if the framework has fully started.void
pause()
Pause the scheduler service.void
registerExtension
(Extension extension) Registers the given extension.void
registerSchedule
(Schedule schedule) Registers a schedule.void
registerSchedule
(Schedule schedule, Map<String, Serializable> parameters) Registers a schedule.void
resume()
Resume the scheduler service.protected void
protected void
schedule
(Schedule schedule, Map<String, Serializable> parameters) protected void
protected void
void
start
(ComponentContext context) Start the component.protected void
void
stop
(ComponentContext context) Stop the component.void
unregisterExtension
(Extension extension) Unregisters the given extension.boolean
UnRegisters a schedule.boolean
unregisterSchedule
(Schedule schedule) UnRegisters a schedule.protected boolean
unschedule
(String id) protected boolean
unschedule
(String id, org.quartz.JobKey jobKey) Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
addRuntimeMessage, addRuntimeMessage, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerContribution, setLastModified, setModifiedNow, setName, unregister, unregisterContribution
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.nuxeo.runtime.model.Component
getApplicationStartedOrder
-
Field Details
-
CLUSTER_START_DURATION_PROP
- Since:
- 11.1
- See Also:
-
CLUSTER_START_DURATION_DEFAULT
- Since:
- 11.1
-
CLUSTER_START_DELAY_PROP
- Since:
- 2021.19
- See Also:
-
CLUSTER_START_DELAY_DEFAULT
Default value is set to 5 seconds to delay the start by default- Since:
- 2021.19
-
context
-
scheduler
protected org.quartz.Scheduler scheduler -
registry
-
-
Constructor Details
-
SchedulerServiceImpl
public SchedulerServiceImpl()
-
-
Method Details
-
activate
Description copied from interface:Component
Activates the component.This method is called by the runtime when a component is activated.
- Specified by:
activate
in interfaceComponent
- Overrides:
activate
in classDefaultComponent
- Parameters:
context
- the runtime context
-
setupScheduler
- Throws:
IOException
org.quartz.SchedulerException
-
shutdownScheduler
protected void shutdownScheduler() -
deactivate
Description copied from interface:Component
Deactivates the component.This method is called by the runtime when a component is deactivated.
- Specified by:
deactivate
in interfaceComponent
- Overrides:
deactivate
in classDefaultComponent
- Parameters:
context
- the runtime context
-
start
Description copied from interface:Component
Start the component. This method is called after all the components were resolved and activated- Specified by:
start
in interfaceComponent
- Overrides:
start
in classDefaultComponent
-
startScheduler
protected void startScheduler() -
stop
Description copied from interface:Component
Stop the component.- Specified by:
stop
in interfaceComponent
- Overrides:
stop
in classDefaultComponent
-
hasApplicationStarted
public boolean hasApplicationStarted()Description copied from interface:SchedulerService
Checks if the framework has fully started.Used to delay job execution until the framework has fully started.
- Specified by:
hasApplicationStarted
in interfaceSchedulerService
- Returns:
true
if the framework has started
-
registerExtension
Description copied from interface:Extensible
Registers the given extension.- Specified by:
registerExtension
in interfaceExtensible
- Overrides:
registerExtension
in classDefaultComponent
- Parameters:
extension
- the extension to register
-
unregisterExtension
Description copied from interface:Extensible
Unregisters the given extension.- Specified by:
unregisterExtension
in interfaceExtensible
- Overrides:
unregisterExtension
in classDefaultComponent
- Parameters:
extension
- the extension to unregister
-
getContext
-
registerSchedule
Description copied from interface:SchedulerService
Registers a schedule.- Specified by:
registerSchedule
in interfaceSchedulerService
- Parameters:
schedule
- the schedule
-
registerSchedule
Description copied from interface:SchedulerService
Registers a schedule. Add all parameters to eventContext.- Specified by:
registerSchedule
in interfaceSchedulerService
-
schedule
-
unregisterSchedule
Description copied from interface:SchedulerService
UnRegisters a schedule.- Specified by:
unregisterSchedule
in interfaceSchedulerService
- Parameters:
id
- the schedule id- Returns:
- true if schedule has been successfully removed.
-
schedule
protected void schedule(String id, org.quartz.JobDetail job, org.quartz.Trigger trigger) throws org.quartz.SchedulerException - Throws:
org.quartz.SchedulerException
-
unschedule
-
unschedule
-
unregisterSchedule
Description copied from interface:SchedulerService
UnRegisters a schedule.- Specified by:
unregisterSchedule
in interfaceSchedulerService
- Parameters:
schedule
- to be unregistered- Returns:
- true if schedule has been successfully removed.
-
getSchedules
Description copied from interface:SchedulerService
Gets the list of the registered schedules.- Specified by:
getSchedules
in interfaceSchedulerService
- Returns:
- the schedules list
-
pause
public void pause()Description copied from interface:SchedulerService
Pause the scheduler service. The pause is cluster-wide and survives a node restart. SeeSchedulerService.resume()
to resume the schedules service.- Specified by:
pause
in interfaceSchedulerService
-
resume
public void resume()Description copied from interface:SchedulerService
Resume the scheduler service.- Specified by:
resume
in interfaceSchedulerService
-