org.quartz.Scheduler.interrupt()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(237)

本文整理了Java中org.quartz.Scheduler.interrupt()方法的一些代码示例,展示了Scheduler.interrupt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Scheduler.interrupt()方法的具体详情如下:
包路径:org.quartz.Scheduler
类名称:Scheduler
方法名:interrupt

Scheduler.interrupt介绍

[英]Request the interruption, within this Scheduler instance, of the identified executing Job instance, which must be an implementor of the InterruptableJob interface.

This method is not cluster aware. That is, it will only interrupt instances of the identified InterruptableJob currently executing in this Scheduler instance, not across the entire cluster.
[中]在该调度程序实例中,请求已识别的执行Job实例的中断,该实例必须是InterruptableJob接口的实现者。
此方法不支持群集。也就是说,它只会中断当前在该调度程序实例中执行的已识别可中断作业的实例,而不是整个集群。

代码示例

代码示例来源:origin: quartz-scheduler/quartz

@Override
  public void run() {
    try {
      // Interrupt the job here - using Scheduler API that gets propagated to Job's interrupt
      getLog().info("Interrupting Job as it ran more than the configured max time. Job Details [" + jobKey.getName() + ":" + jobKey.getGroup()+"]");
      scheduler.interrupt(jobKey);
    } catch (SchedulerException x) {
      getLog().info("Error interrupting Job: " + x.getMessage(), x);
    }
  }
}

代码示例来源:origin: quartz-scheduler/quartz

@Override
  public void run() {
    try {
      // Interrupt the job here - using Scheduler API that gets propagated to Job's interrupt
      getLog().info("Interrupting Job as it ran more than the configured max time. Job Details [" + jobKey.getName() + ":" + jobKey.getGroup()+"]");
      scheduler.interrupt(jobKey);
    } catch (SchedulerException x) {
      getLog().info("Error interrupting Job: " + x.getMessage(), x);
    }
  }
}

代码示例来源:origin: apache/incubator-gobblin

@Override
protected void shutDown()
  throws Exception {
 LOG.info("Stopping the job scheduler");
 closer.close();
 cancelRequested = true;
 List<JobExecutionContext> currentExecutions = this.scheduler.getScheduler().getCurrentlyExecutingJobs();
 for (JobExecutionContext jobExecutionContext : currentExecutions) {
  try {
   this.scheduler.getScheduler().interrupt(jobExecutionContext.getFireInstanceId());
  } catch (UnableToInterruptJobException e) {
   LOG.error("Failed to cancel job " + jobExecutionContext.getJobDetail().getKey(), e);
  }
 }
 ExecutorsUtils.shutdownExecutorService(this.jobExecutor, Optional.of(LOG));
}

代码示例来源:origin: org.rhq/rhq-enterprise-server

public boolean interrupt(String jobName, String groupName) throws UnableToInterruptJobException {
  return scheduler.interrupt(jobName, groupName);
}

代码示例来源:origin: com.threewks.thundr/thundr-contrib-quartz

@Override
public boolean interrupt(String fireInstanceId) throws UnableToInterruptJobException {
  return delegate.interrupt(fireInstanceId);
}

代码示例来源:origin: com.threewks.thundr/thundr-quartz

@Override
public boolean interrupt(String fireInstanceId) throws UnableToInterruptJobException {
  return delegate.interrupt(fireInstanceId);
}

代码示例来源:origin: com.threewks.thundr/thundr-contrib-quartz

@Override
public boolean interrupt(JobKey jobKey) throws UnableToInterruptJobException {
  return delegate.interrupt(jobKey);
}

代码示例来源:origin: com.threewks.thundr/thundr-quartz

@Override
public boolean interrupt(JobKey jobKey) throws UnableToInterruptJobException {
  return delegate.interrupt(jobKey);
}

代码示例来源:origin: stackoverflow.com

@Autowired
private Scheduler schedulerFactoryBean; //injected by spring
...
...

List<JobExecutionContext> currentlyExecuting = schedulerFactoryBean.getCurrentlyExecutingJobs();

//verifying if job is running       
for (JobExecutionContext jobExecutionContext : currentlyExecuting) {
  if(jobExecutionContext.getJobDetail().getKey().getName().equals("JobKeyNameToInterrupt")){
    result = schedulerFactoryBean.interrupt(jobExecutionContext.getJobDetail().getKey());
  }
}

代码示例来源:origin: org.rhq/rhq-enterprise-server

public boolean interrupt(String jobName, String groupName) throws UnableToInterruptJobException {
  try {
    return this.scheduler.interrupt(jobName, groupName);
  } catch (SchedulerException e) {
    throw new UnableToInterruptJobException(e);
  }
}

代码示例来源:origin: myschedule/myschedule-quartz-extra

public boolean interrupt(JobKey jobKey) {
  try {
    return scheduler.interrupt(jobKey);
  } catch (SchedulerException e) {
    throw new QuartzRuntimeException(e);
  }
}

代码示例来源:origin: myschedule/myschedule-quartz-extra

public boolean interrupt(String fireInstanceId) {
  try {
    return scheduler.interrupt(fireInstanceId);
  } catch (SchedulerException e) {
    throw new QuartzRuntimeException(e);
  }
}

代码示例来源:origin: org.codelibs/elasticsearch-quartz

public boolean interrupt(final JobKey jobKey) {
  try {
    return scheduler.interrupt(jobKey);
  } catch (final UnableToInterruptJobException e) {
    throw new QuartzInterruptException("Failed to interrupt the job.",
        e);
  }
}

代码示例来源:origin: org.codelibs/elasticsearch-quartz

public boolean interrupt(final String fireInstanceId) {
  try {
    return scheduler.interrupt(fireInstanceId);
  } catch (final UnableToInterruptJobException e) {
    throw new QuartzInterruptException("Failed to interrupt the job.",
        e);
  }
}

代码示例来源:origin: OpenWiseSolutions/openhub-framework

@Override
public boolean interrupt(JobKey jobKey) throws UnableToInterruptJobException {
  return getScheduler().interrupt(jobKey);
}

代码示例来源:origin: org.apache.deltaspike.modules/deltaspike-scheduler-module-impl

@Override
public void interruptJob(Class<? extends T> jobClass)
{
  try
  {
    this.scheduler.interrupt(createJobKey(jobClass));
  }
  catch (SchedulerException e)
  {
    throw ExceptionUtils.throwAsRuntimeException(e);
  }
}

代码示例来源:origin: stackoverflow.com

SchedulerFactory schedulerFactory = new StdSchedulerFactory();
Scheduler scheduler = schedulerFactory.getScheduler();
List<JobExecutionContext> currentlyExecuting = scheduler.getCurrentlyExecutingJobs();
for( JobExecutionContext jobExecutionContext : currentlyExecuting)
{
  if( jobExecutionContext.getJobDetail().getKey().getName().equals( "Name"))
  {
     scheduler.interrupt( jobExecutionContext.getJobDetail().getKey());
  }
}

代码示例来源:origin: bingoohuang/quartz-glass

@RequestMapping("/interrupt")
public String interrupt(String group, String name) throws SchedulerException {
  JobDetail job = quartzScheduler.getJobDetail(new JobKey(name, group));
  if (job == null) return "redirect:/glass/";
  quartzScheduler.interrupt(job.getKey());
  return "redirect:/glass/";
}

代码示例来源:origin: mbok/logsniffer

protected void stopAndDeleteAllSnifferJobs(final long snifferId) throws SchedulerException {
  for (final JobKey job : scheduler.getJobKeys(GroupMatcher.jobGroupEquals("SNIFFER:" + snifferId))) {
    logger.info("Deleting scheduled job for sniffer={} and log source={}", snifferId, getLogSourceId(job));
    scheduler.deleteJob(job);
    logger.info("Interrupting job for sniffer={} and log source={}", snifferId, getLogSourceId(job));
    scheduler.interrupt(job);
  }
}

代码示例来源:origin: Evolveum/midpoint

void stopLocalTaskRun(String oid, OperationResult parentResult) {
  OperationResult result = parentResult.createSubresult(LocalNodeManager.class.getName() + ".stopLocalTaskRun");
  result.addParam("task", oid);
  LOGGER.info("Stopping local task " + oid + " run");
  try {
    getQuartzScheduler().interrupt(TaskQuartzImplUtil.createJobKeyForTaskOid(oid));
    result.recordSuccess();
  } catch (UnableToInterruptJobException e) {
    String message = "Unable to interrupt the task " + oid;
    LoggingUtils.logUnexpectedException(LOGGER, message, e);            // however, we continue (e.g. to suspend the task)
    result.recordFatalError(message, e);
  }
}

相关文章