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.StringAUTO_INTERRUPTIBLEstatic java.lang.StringMAX_RUN_TIME
-
Constructor Summary
Constructors Constructor Description JobInterruptMonitorPlugin()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetDefaultMaxRunTime()protected org.slf4j.LoggergetLog()Get thefor this class's category.Loggerjava.lang.StringgetName()Get the name of theTriggerListener.voidinitialize(java.lang.String name, Scheduler scheduler, ClassLoadHelper helper)Called during creation of theSchedulerin order to give theSchedulerPlugina chance to initialize.java.util.concurrent.ScheduledFuturescheduleJobInterruptMonitor(JobKey jobkey, long delay)voidsetDefaultMaxRunTime(long defaultMaxRunTime)voidshutdown()Called in order to inform theSchedulerPluginthat it should free up all of it's resources because the scheduler is shutting down.voidstart()Called when the associatedScheduleris started, in order to let the plug-in know it can now make calls into the scheduler if it needs to.voidtriggerComplete(Trigger trigger, JobExecutionContext context, Trigger.CompletedExecutionInstruction triggerInstructionCode)voidtriggerFired(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:SchedulerPluginCalled when the associated
Scheduleris started, in order to let the plug-in know it can now make calls into the scheduler if it needs to.- Specified by:
startin interfaceSchedulerPlugin
-
shutdown
public void shutdown()
Description copied from interface:SchedulerPluginCalled in order to inform the
SchedulerPluginthat it should free up all of it's resources because the scheduler is shutting down.- Specified by:
shutdownin interfaceSchedulerPlugin
-
getLog
protected org.slf4j.Logger getLog()
Description copied from class:TriggerListenerSupportGet thefor this class's category. This should be used by subclasses for logging.Logger- Overrides:
getLogin 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:TriggerListenerGet the name of the
TriggerListener.- Specified by:
getNamein interfaceTriggerListener
-
triggerFired
public void triggerFired(Trigger trigger, JobExecutionContext context)
Description copied from interface:TriggerListenerCalled by the
when aSchedulerhas fired, and it's associatedTriggeris about to be executed.JobDetailIt is called before the
vetoJobExecution(..)method of this interface.- Specified by:
triggerFiredin interfaceTriggerListener- Overrides:
triggerFiredin classTriggerListenerSupport- Parameters:
trigger- TheTriggerthat has fired.context- TheJobExecutionContextthat will be passed to theJob'sexecute(xx)method.
-
triggerComplete
public void triggerComplete(Trigger trigger, JobExecutionContext context, Trigger.CompletedExecutionInstruction triggerInstructionCode)
Description copied from interface:TriggerListenerCalled by the
when aSchedulerhas fired, it's associatedTriggerhas been executed, and it'sJobDetailtriggered(xx)method has been called.- Specified by:
triggerCompletein interfaceTriggerListener- Overrides:
triggerCompletein classTriggerListenerSupport- Parameters:
trigger- TheTriggerthat was fired.context- TheJobExecutionContextthat 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 SchedulerExceptionDescription copied from interface:SchedulerPluginCalled during creation of the
Schedulerin order to give theSchedulerPlugina chance to initialize.At this point, the Scheduler's
JobStoreis not yet initialized.If you need direct access your plugin, for example during
Jobexecution, you can have this method explicitly put a reference to this plugin in theScheduler'sSchedulerContext.- Specified by:
initializein interfaceSchedulerPlugin- Parameters:
name- The name by which the plugin is identified.scheduler- The scheduler to which the plugin is registered.helper- The classLoadHelper theSchedulerFactoryis actually using- Throws:
SchedulerConfigException- if there is an error initializing.SchedulerException
-
-