本文整理了Java中org.quartz.Scheduler.getCurrentlyExecutingJobs()
方法的一些代码示例,展示了Scheduler.getCurrentlyExecutingJobs()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Scheduler.getCurrentlyExecutingJobs()
方法的具体详情如下:
包路径:org.quartz.Scheduler
类名称:Scheduler
方法名:getCurrentlyExecutingJobs
[英]Return a list of JobExecutionContext
objects that represent all currently executing Jobs in this Scheduler instance.
This method is not cluster aware. That is, it will only return Jobs currently executing in this Scheduler instance, not across the entire cluster.
Note that the list returned is an 'instantaneous' snap-shot, and that as soon as it's returned, the true list of executing jobs may be different. Also please read the doc associated with JobExecutionContext
- especially if you're using RMI.
[中]返回JobExecutionContext
对象的列表,这些对象表示此计划程序实例中当前正在执行的所有作业。
此方法不支持群集。也就是说,它将只返回当前在此调度程序实例中执行的作业,而不是整个集群中的作业。
请注意,返回的列表是一个“即时”快照,一旦返回,执行作业的真实列表可能会有所不同。另外,请阅读与JobExecutionContext
相关的文档,尤其是如果您使用RMI。
代码示例来源: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: javamelody/javamelody
final Map<String, JobExecutionContext> currentlyExecutingJobsByFullName = new LinkedHashMap<String, JobExecutionContext>();
for (final JobExecutionContext currentlyExecutingJob : (List<JobExecutionContext>) scheduler
.getCurrentlyExecutingJobs()) {
final JobDetail jobDetail = quartzAdapter
.getContextJobDetail(currentlyExecutingJob);
代码示例来源:origin: org.exoplatform.kernel/exo.kernel.component.common
public List<JobExecutionContext> getAllExcutingJobs() throws Exception
{
return scheduler_.getCurrentlyExecutingJobs();
}
代码示例来源:origin: bill1012/AdminEAP
/**
* 获取运行中的任务
*/
public List<ScheduleJob> getRunningJobs() throws SchedulerException {
Scheduler scheduler = schedulerFactoryBean.getScheduler();
List<JobExecutionContext> executingJobs = scheduler.getCurrentlyExecutingJobs();
List<ScheduleJob> jobList = new ArrayList<ScheduleJob>(executingJobs.size());
for (JobExecutionContext executingJob : executingJobs) {
ScheduleJob job = new ScheduleJob();
JobDetail jobDetail = executingJob.getJobDetail();
JobKey jobKey = jobDetail.getKey();
Trigger trigger = executingJob.getTrigger();
job.setJobId(jobKey.getGroup() + "_" + jobKey.getName());
job.setJobName(jobKey.getName());
job.setJobGroup(jobKey.getGroup());
job.setDesc(trigger.getDescription());
Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
job.setJobStatus(triggerState.name());
if (trigger instanceof CronTrigger) {
CronTrigger cronTrigger = (CronTrigger) trigger;
String cronExpression = cronTrigger.getCronExpression();
job.setCronExpression(cronExpression);
}
jobList.add(job);
}
return jobList;
}
代码示例来源:origin: org.kuali.kfs/kfs-core
public List<JobExecutionContext> getRunningJobs() {
try {
List<JobExecutionContext> jobContexts = scheduler.getCurrentlyExecutingJobs();
return jobContexts;
}
catch (SchedulerException ex) {
throw new RuntimeException("Unable to get list of running jobs.", ex);
}
}
代码示例来源:origin: org.kuali.kpme/kpme-tk-lm-impl
public List<JobExecutionContext> getRunningJobs() {
try {
List<JobExecutionContext> jobContexts = scheduler.getCurrentlyExecutingJobs();
return jobContexts;
}
catch (SchedulerException ex) {
throw new RuntimeException("Unable to get list of running jobs.", ex);
}
}
代码示例来源:origin: apache/lens
public List<JobExecutionContext> getCurrentlyExecutingJobs() {
try {
return scheduler.getCurrentlyExecutingJobs();
} catch (SchedulerException e) {
log.error("Failed to get currently executing jobs");
}
return new ArrayList<>();
}
代码示例来源:origin: myschedule/myschedule-quartz-extra
public List<JobExecutionContext> getCurrentlyExecutingJobs() {
try {
return scheduler.getCurrentlyExecutingJobs();
} catch (SchedulerException e) {
throw new QuartzRuntimeException(e);
}
}
代码示例来源: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.codelibs/elasticsearch-quartz
public List<JobExecutionContext> getCurrentlyExecutingJobs() {
try {
return scheduler.getCurrentlyExecutingJobs();
} catch (final SchedulerException e) {
throw new QuartzSchedulerException(e);
}
}
代码示例来源:origin: OpenWiseSolutions/openhub-framework
@Override
public List<JobExecutionContext> getCurrentlyExecutingJobs() throws SchedulerException {
return getScheduler().getCurrentlyExecutingJobs();
}
代码示例来源:origin: pl.touk.hades/hades-quartz
private JobExecutionContext hadesJobIsExecuting() throws SchedulerException {
for (JobExecutionContext c: (List<JobExecutionContext>) scheduler.getCurrentlyExecutingJobs()) {
if (hadesQuartzJob.equals(c.getJobDetail().getName())
&& hadesQuartzGroup.equals(c.getJobDetail().getGroup())) {
return c;
}
}
return null;
}
代码示例来源:origin: ch.exense.step/core
public List<ExecutionRunnable> getCurrentExecutions() {
List<JobExecutionContext> excutingJobs;
try {
excutingJobs = scheduler.getCurrentlyExecutingJobs();
} catch (SchedulerException e) {
throw new RuntimeException("Unexepected error occurred while getting executing jobs", e);
}
List<ExecutionRunnable> result = new ArrayList<ExecutionRunnable>(excutingJobs.size());
for(JobExecutionContext jobContext:excutingJobs) {
result.add(((ExecutionJob) jobContext.getJobInstance()).getRunnable());
}
return result;
}
代码示例来源:origin: org.sakaiproject.sitestats/sitestats-impl
private boolean isJobCurrentlyRunning(JobExecutionContext context) throws SchedulerException {
String beanId = context.getJobDetail().getJobDataMap().getString(SpringJobBeanWrapper.SPRING_BEAN_NAME);
List<JobExecutionContext> jobsRunning = context.getScheduler().getCurrentlyExecutingJobs();
int jobsCount = 0;
for(JobExecutionContext j : jobsRunning)
if(beanId.equals(j.getJobDetail().getJobDataMap().getString(SpringJobBeanWrapper.SPRING_BEAN_NAME))) {
jobsCount++;
}
if(jobsCount > 1)
return true;
return false;
}
代码示例来源:origin: org.apache.syncope.core/syncope-core-provisioning-java
private boolean isRunningHere(final JobKey jobKey) throws SchedulerException {
return scheduler.getScheduler().getCurrentlyExecutingJobs().stream().
anyMatch(jec -> jobKey.equals(jec.getJobDetail().getKey()));
}
代码示例来源: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: jiwenxing/springboot-quartz
public List<ScheduleJob> getRunningJobList() throws SchedulerException{
List<JobExecutionContext> executingJobList = scheduler.getCurrentlyExecutingJobs();
List<ScheduleJob> jobList = new ArrayList<>(executingJobList.size());
for(JobExecutionContext executingJob : executingJobList){
ScheduleJob scheduleJob = new ScheduleJob();
JobDetail jobDetail = executingJob.getJobDetail();
JobKey jobKey = jobDetail.getKey();
Trigger trigger = executingJob.getTrigger();
this.wrapScheduleJob(scheduleJob,scheduler,jobKey,trigger);
jobList.add(scheduleJob);
}
return jobList;
}
代码示例来源:origin: Evolveum/midpoint
boolean isTaskThreadActiveLocally(String oid) {
try {
for (JobExecutionContext jec : getQuartzScheduler().getCurrentlyExecutingJobs()) {
if (oid.equals(jec.getJobDetail().getKey().getName())) {
return true;
}
}
} catch (SchedulerException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Cannot get the list of currently executing jobs", e);
return false;
}
return false;
}
代码示例来源:origin: com.threewks.thundr/thundr-quartz
@Override
public List<JobExecutionContext> getCurrentlyExecutingJobs() throws QuartzException {
try {
return delegate.getCurrentlyExecutingJobs();
} catch (SchedulerException e) {
Logger.error(e.getMessage());
throw new QuartzException(e);
}
}
代码示例来源:origin: com.threewks.thundr/thundr-contrib-quartz
@Override
public List<JobExecutionContext> getCurrentlyExecutingJobs() throws QuartzException {
try {
return delegate.getCurrentlyExecutingJobs();
} catch (SchedulerException e) {
Logger.error(e.getMessage());
throw new QuartzException(e);
}
}
内容来源于网络,如有侵权,请联系作者删除!