Class JobInterruptMonitorPlugin
- java.lang.Object
-
- org.quartz.listeners.TriggerListenerSupport
-
- org.quartz.plugins.interrupt.JobInterruptMonitorPlugin
-
- All Implemented Interfaces:
SchedulerPlugin
,TriggerListener
public class JobInterruptMonitorPlugin extends TriggerListenerSupport implements SchedulerPlugin
This plugin catches the event of job running for a long time (more than the configured max time) and tells the scheduler to "try" interrupting it if enabled.- Author:
- Rama Chavali
- See Also:
Scheduler.interrupt(JobKey)
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
AUTO_INTERRUPTIBLE
static java.lang.String
MAX_RUN_TIME
-
Constructor Summary
Constructors Constructor Description JobInterruptMonitorPlugin()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getDefaultMaxRunTime()
protected org.slf4j.Logger
getLog()
Get the
for this class's category.Logger
java.lang.String
getName()
Get the name of theTriggerListener
.void
initialize(java.lang.String name, Scheduler scheduler, ClassLoadHelper helper)
Called during creation of theScheduler
in order to give theSchedulerPlugin
a chance to initialize.java.util.concurrent.ScheduledFuture
scheduleJobInterruptMonitor(JobKey jobkey, long delay)
void
setDefaultMaxRunTime(long defaultMaxRunTime)
void
shutdown()
Called in order to inform theSchedulerPlugin
that it should free up all of it's resources because the scheduler is shutting down.void
start()
Called when the associatedScheduler
is started, in order to let the plug-in know it can now make calls into the scheduler if it needs to.void
triggerComplete(Trigger trigger, JobExecutionContext context, Trigger.CompletedExecutionInstruction triggerInstructionCode)
void
triggerFired(Trigger trigger, JobExecutionContext context)
-
Methods inherited from class org.quartz.listeners.TriggerListenerSupport
triggerMisfired, vetoJobExecution
-
-
-
-
Field Detail
-
AUTO_INTERRUPTIBLE
public static final java.lang.String AUTO_INTERRUPTIBLE
- See Also:
- Constant Field Values
-
MAX_RUN_TIME
public static final java.lang.String MAX_RUN_TIME
- See Also:
- Constant Field Values
-
-
Method Detail
-
start
public void start()
Description copied from interface:SchedulerPlugin
Called when the associated
Scheduler
is started, in order to let the plug-in know it can now make calls into the scheduler if it needs to.- Specified by:
start
in interfaceSchedulerPlugin
-
shutdown
public void shutdown()
Description copied from interface:SchedulerPlugin
Called in order to inform the
SchedulerPlugin
that it should free up all of it's resources because the scheduler is shutting down.- Specified by:
shutdown
in interfaceSchedulerPlugin
-
getLog
protected org.slf4j.Logger getLog()
Description copied from class:TriggerListenerSupport
Get the
for this class's category. This should be used by subclasses for logging.Logger
- Overrides:
getLog
in classTriggerListenerSupport
-
scheduleJobInterruptMonitor
public java.util.concurrent.ScheduledFuture scheduleJobInterruptMonitor(JobKey jobkey, long delay)
-
getDefaultMaxRunTime
public long getDefaultMaxRunTime()
-
setDefaultMaxRunTime
public void setDefaultMaxRunTime(long defaultMaxRunTime)
-
getName
public java.lang.String getName()
Description copied from interface:TriggerListener
Get the name of the
TriggerListener
.- Specified by:
getName
in interfaceTriggerListener
-
triggerFired
public void triggerFired(Trigger trigger, JobExecutionContext context)
Description copied from interface:TriggerListener
Called by the
when aScheduler
has fired, and it's associatedTrigger
is about to be executed.JobDetail
It is called before the
vetoJobExecution(..)
method of this interface.- Specified by:
triggerFired
in interfaceTriggerListener
- Overrides:
triggerFired
in classTriggerListenerSupport
- Parameters:
trigger
- TheTrigger
that has fired.context
- TheJobExecutionContext
that will be passed to theJob
'sexecute(xx)
method.
-
triggerComplete
public void triggerComplete(Trigger trigger, JobExecutionContext context, Trigger.CompletedExecutionInstruction triggerInstructionCode)
Description copied from interface:TriggerListener
Called by the
when aScheduler
has fired, it's associatedTrigger
has been executed, and it'sJobDetail
triggered(xx)
method has been called.- Specified by:
triggerComplete
in interfaceTriggerListener
- Overrides:
triggerComplete
in classTriggerListenerSupport
- Parameters:
trigger
- TheTrigger
that was fired.context
- TheJobExecutionContext
that was passed to theJob
'sexecute(xx)
method.triggerInstructionCode
- the result of the call on theTrigger
'striggered(xx)
method.
-
initialize
public void initialize(java.lang.String name, Scheduler scheduler, ClassLoadHelper helper) throws SchedulerException
Description copied from interface:SchedulerPlugin
Called during creation of the
Scheduler
in order to give theSchedulerPlugin
a chance to initialize.At this point, the Scheduler's
JobStore
is not yet initialized.If you need direct access your plugin, for example during
Job
execution, you can have this method explicitly put a reference to this plugin in theScheduler
'sSchedulerContext
.- Specified by:
initialize
in interfaceSchedulerPlugin
- Parameters:
name
- The name by which the plugin is identified.scheduler
- The scheduler to which the plugin is registered.helper
- The classLoadHelper theSchedulerFactory
is actually using- Throws:
SchedulerConfigException
- if there is an error initializing.SchedulerException
-
-