private boolean notifyTriggerListenersComplete(JobExecutionContext jec, CompletedExecutionInstruction instCode) { try { qs.notifyTriggerListenersComplete(jec, instCode); } catch (SchedulerException se) { qs.notifySchedulerListenersError("Unable to notify TriggerListener(s) of Job that was executed: " + "(error will be ignored). trigger= " + jec.getTrigger().getName() + " job= " + jec.getJobDetail().getName(), se); return false; } if (jec.getTrigger().getNextFireTime() == null) { qs.notifySchedulerListenersFinalized(jec.getTrigger()); } return true; }
/** * Triggers a Job interrupt on all Jobs matching the given Job Name * * @param jobName The job name */ public static void stopJob(String jobName) { try { List<JobExecutionContext> currentlyExecutingJobs = getScheduler().getCurrentlyExecutingJobs(); for (JobExecutionContext jobExecutionContext : currentlyExecutingJobs) { String currentlyExecutingJobName = jobExecutionContext.getJobDetail().getName(); if (currentlyExecutingJobName.equals(jobName)) { logger.debug("Matching Job found. Now Stopping!"); if (jobExecutionContext.getJobInstance() instanceof Job) { ((Job) jobExecutionContext.getJobInstance()).interrupt(); } else { logger.warn("CANNOT STOP NON-INTERRUPTABLE JOB!!!"); } } else { logger.debug("Non-matching Job found. Not Stopping!"); } } } catch (SchedulerException e) { logger.error("ERROR STOPPING JOB!!!", e); } }
/** * Add all the mappings from the JobExecutionContext to the JobContext * * @param jobExecutionContext */ public void addQuartzContext(JobExecutionContext jobExecutionContext) { for (Object mapKey : jobExecutionContext.getMergedJobDataMap().keySet()) { // logger.debug("added key: " + (String) mapKey); // logger.debug("added value: " + (String) jobExecutionContext.getMergedJobDataMap().get(mapKey)); map.put((String) mapKey, jobExecutionContext.getMergedJobDataMap().get(mapKey)); } map.put(KEY_JOB_NAME, jobExecutionContext.getJobDetail().getName()); map.put(KEY_TRIGGER_NAME, (jobExecutionContext.getTrigger().getName())); if (jobExecutionContext.getTrigger() instanceof CronTrigger) { map.put(KEY_TRIGGER_CRON_EXPRESSION, ((CronTrigger) jobExecutionContext.getTrigger()).getCronExpression()); } }
@Override public void triggerComplete(Trigger trigger, JobExecutionContext context, Trigger.CompletedExecutionInstruction triggerInstructionCode) { metrics.timer(triggerMetricName(trigger.getName())).update( context.getJobRunTime(), TimeUnit.MILLISECONDS ); metrics.timer(jobMetricName(context.getJobDetail().getName())).update( context.getJobRunTime(), TimeUnit.MILLISECONDS ); }
List<JobExecutionContext> currentlyExecutingJobs = getScheduler().getCurrentlyExecutingJobs(); for (JobExecutionContext jobExecutionContext : currentlyExecutingJobs) { String currentlyExecutingJobName = jobExecutionContext.getJobDetail().getName(); if (currentlyExecutingJobName.equals(jobName)) { if (jobExecutionContext.getJobInstance() instanceof Job) { JobDataMap jobDataMap = jobExecutionContext.getMergedJobDataMap(); String value = jobDataMap.getString(key); if (value != null & value.equalsIgnoreCase(pValue)) { ((Job) jobExecutionContext.getJobInstance()).interrupt();
@Override public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) { synchronized (executingJobs) { executingJobs.remove(((OperableTrigger) context.getTrigger()).getFireInstanceId()); } }
public static boolean isJobRunning(String jobName) { try { List<JobExecutionContext> currentlyExecutingJobs = getScheduler().getCurrentlyExecutingJobs(); for (JobExecutionContext jobExecutionContext : currentlyExecutingJobs) { String currentlyExecutingJobName = jobExecutionContext.getJobDetail().getName(); if (currentlyExecutingJobName.equals(jobName)) { logger.debug("Matching running Job found!"); return true; } } } catch (SchedulerException e) { logger.error("ERROR CHECKING RUNNING JOB!!!", e); } logger.debug("Matching running NOT Job found!"); return false; }
List<JobExecutionContext> currentlyExecutingJobs = getScheduler().getCurrentlyExecutingJobs(); for (JobExecutionContext jobExecutionContext : currentlyExecutingJobs) { String currentlyExecutingJobName = jobExecutionContext.getJobDetail().getName(); if (currentlyExecutingJobName.equals(jobName)) { if (jobExecutionContext.getJobInstance() instanceof Job) { JobDataMap jobDataMap = jobExecutionContext.getMergedJobDataMap(); String value = jobDataMap.getString(key); if (value != null & value.equalsIgnoreCase(pValue)) { ((Job) jobExecutionContext.getJobInstance()).interrupt();
@Override public void jobToBeExecuted(JobExecutionContext context) { numJobsFired.incrementAndGet(); synchronized (executingJobs) { executingJobs.put(((OperableTrigger) context.getTrigger()).getFireInstanceId(), context); } }
public static boolean isJobRunning(String jobName) throws SundialSchedulerException { try { List<JobExecutionContext> currentlyExecutingJobs = getScheduler().getCurrentlyExecutingJobs(); for (JobExecutionContext jobExecutionContext : currentlyExecutingJobs) { String currentlyExecutingJobName = jobExecutionContext.getJobDetail().getName(); if (currentlyExecutingJobName.equals(jobName)) { logger.debug("Matching running Job found!"); return true; } } } catch (SchedulerException e) { throw new SundialSchedulerException("ERROR CHECKING RUNNING JOB!!!", e); } logger.debug("Matching running NOT Job found!"); return false; }
private boolean notifyTriggerListenersComplete(JobExecutionContext jec, CompletedExecutionInstruction instCode) { try { qs.notifyTriggerListenersComplete(jec, instCode); } catch (SchedulerException se) { qs.notifySchedulerListenersError("Unable to notify TriggerListener(s) of Job that was executed: " + "(error will be ignored). trigger= " + jec.getTrigger().getName() + " job= " + jec.getJobDetail().getName(), se); return false; } if (jec.getTrigger().getNextFireTime() == null) { qs.notifySchedulerListenersFinalized(jec.getTrigger()); } return true; }
/** * Triggers a Job interrupt on all Jobs matching the given Job Name. The Job termination mechanism works by setting a flag that the Job should be * terminated, but it is up to the logic in the Job to decide at what point termination should occur. Therefore, in any long-running job that you * anticipate the need to terminate, put the method call checkTerminated() at an appropriate location. * * @param jobName The job name */ public static void stopJob(String jobName) throws SundialSchedulerException { try { List<JobExecutionContext> currentlyExecutingJobs = getScheduler().getCurrentlyExecutingJobs(); for (JobExecutionContext jobExecutionContext : currentlyExecutingJobs) { String currentlyExecutingJobName = jobExecutionContext.getJobDetail().getName(); if (currentlyExecutingJobName.equals(jobName)) { logger.debug("Matching Job found. Now Stopping!"); if (jobExecutionContext.getJobInstance() instanceof Job) { ((Job) jobExecutionContext.getJobInstance()).interrupt(); } else { logger.warn("CANNOT STOP NON-INTERRUPTABLE JOB!!!"); } } else { logger.debug("Non-matching Job found. Not Stopping!"); } } } catch (SchedulerException e) { throw new SundialSchedulerException("ERROR STOPPING JOB!!!", e); } }
/** * Add all the mappings from the JobExecutionContext to the JobContext * * @param jobExecutionContext */ public void addQuartzContext(JobExecutionContext jobExecutionContext) { for (Object mapKey : jobExecutionContext.getMergedJobDataMap().keySet()) { // logger.debug("added key: " + (String) mapKey); // logger.debug("added value: " + (String) jobExecutionContext.getMergedJobDataMap().get(mapKey)); map.put((String) mapKey, jobExecutionContext.getMergedJobDataMap().get(mapKey)); } map.put(KEY_JOB_NAME, jobExecutionContext.getJobDetail().getName()); map.put(KEY_TRIGGER_NAME, (jobExecutionContext.getTrigger().getName())); if (jobExecutionContext.getTrigger() instanceof CronTrigger) { map.put(KEY_TRIGGER_CRON_EXPRESSION, ((CronTrigger) jobExecutionContext.getTrigger()).getCronExpression()); } }
List<JobExecutionContext> currentlyExecutingJobs = getScheduler().getCurrentlyExecutingJobs(); for (JobExecutionContext jobExecutionContext : currentlyExecutingJobs) { String currentlyExecutingJobName = jobExecutionContext.getJobDetail().getName(); if (currentlyExecutingJobName.equals(jobName)) { if (jobExecutionContext.getJobInstance() instanceof Job) { JobDataMap jobDataMap = jobExecutionContext.getMergedJobDataMap(); String value = jobDataMap.getString(key); if (value != null & value.equalsIgnoreCase(pValue)) { ((Job) jobExecutionContext.getJobInstance()).interrupt();
@Override public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) { synchronized (executingJobs) { executingJobs.remove(((OperableTrigger) context.getTrigger()).getFireInstanceId()); } }
public static boolean isJobRunning(String jobName) throws SundialSchedulerException { try { List<JobExecutionContext> currentlyExecutingJobs = getScheduler().getCurrentlyExecutingJobs(); for (JobExecutionContext jobExecutionContext : currentlyExecutingJobs) { String currentlyExecutingJobName = jobExecutionContext.getJobDetail().getName(); if (currentlyExecutingJobName.equals(jobName)) { logger.debug("Matching running Job found!"); return true; } } } catch (SchedulerException e) { throw new SundialSchedulerException("ERROR CHECKING RUNNING JOB!!!", e); } logger.debug("Matching running NOT Job found!"); return false; }
private boolean notifyJobListenersComplete(JobExecutionContext jec, JobExecutionException jobExEx) { try { qs.notifyJobListenersWasExecuted(jec, jobExEx); } catch (SchedulerException se) { qs.notifySchedulerListenersError("Unable to notify JobListener(s) of Job that was executed: " + "(error will be ignored). trigger= " + jec.getTrigger().getName() + " job= " + jec.getJobDetail().getName(), se); return false; } return true; }
/** * Triggers a Job interrupt on all Jobs matching the given Job Name. The Job termination mechanism * works by setting a flag that the Job should be terminated, but it is up to the logic in the Job * to decide at what point termination should occur. Therefore, in any long-running job that you * anticipate the need to terminate, put the method call checkTerminated() at an appropriate * location. * * @param jobName The job name */ public static void stopJob(String jobName) throws SundialSchedulerException { try { List<JobExecutionContext> currentlyExecutingJobs = getScheduler().getCurrentlyExecutingJobs(); for (JobExecutionContext jobExecutionContext : currentlyExecutingJobs) { String currentlyExecutingJobName = jobExecutionContext.getJobDetail().getName(); if (currentlyExecutingJobName.equals(jobName)) { logger.debug("Matching Job found. Now Stopping!"); if (jobExecutionContext.getJobInstance() instanceof Job) { ((Job) jobExecutionContext.getJobInstance()).interrupt(); } else { logger.warn("CANNOT STOP NON-INTERRUPTABLE JOB!!!"); } } else { logger.debug("Non-matching Job found. Not Stopping!"); } } } catch (SchedulerException e) { throw new SundialSchedulerException("ERROR STOPPING JOB!!!", e); } }
/** * Add all the mappings from the JobExecutionContext to the JobContext * * @param jobExecutionContext */ public void addQuartzContext(JobExecutionContext jobExecutionContext) { for (Object mapKey : jobExecutionContext.getMergedJobDataMap().keySet()) { // logger.debug("added key: " + (String) mapKey); // logger.debug("added value: " + (String) // jobExecutionContext.getMergedJobDataMap().get(mapKey)); map.put((String) mapKey, jobExecutionContext.getMergedJobDataMap().get(mapKey)); } map.put(KEY_JOB_NAME, jobExecutionContext.getJobDetail().getName()); map.put(KEY_TRIGGER_NAME, (jobExecutionContext.getTrigger().getName())); if (jobExecutionContext.getTrigger() instanceof CronTrigger) { map.put( KEY_TRIGGER_CRON_EXPRESSION, ((CronTrigger) jobExecutionContext.getTrigger()).getCronExpression()); } }
@Override public void jobToBeExecuted(JobExecutionContext context) { numJobsFired.incrementAndGet(); synchronized (executingJobs) { executingJobs.put(((OperableTrigger) context.getTrigger()).getFireInstanceId(), context); } }