Java Code Examples for org.quartz.Scheduler#getCurrentlyExecutingJobs()

The following examples show how to use org.quartz.Scheduler#getCurrentlyExecutingJobs() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchedulerTool.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * This method runs the current job only once, right now
 * @return int 0 if it's not running, 1 if it is, 2 if there is an error
 */
public int getSelectedJobRunning()
{
   Scheduler scheduler = schedulerManager.getScheduler();
   if (scheduler == null)
   {
     log.error("Scheduler is down!");
     return 2;
   }
   try
   {
      List<JobExecutionContext> executingJobs = scheduler.getCurrentlyExecutingJobs();
      JobKey selected = selectedJobDetailWrapper.getJobDetail().getKey();

      for (JobExecutionContext jobExecutionContext : executingJobs) {
         if(selected.equals(jobExecutionContext.getJobDetail().getKey()) )
            return 1;
      }
      return 0;
   }
   catch (Exception e)
   {
     log.error("Failed to trigger job now", e);
     return 2;
   }
}
 
Example 2
Source File: SchedulerTool.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public List<JobExecutionContextWrapperBean> getRunningJobs() {
 List<JobExecutionContext> currentJobs = new ArrayList<JobExecutionContext>();
 List<JobExecutionContextWrapperBean> currentWrappedJobs = new ArrayList<JobExecutionContextWrapperBean>();
 Scheduler scheduler = schedulerManager.getScheduler();
 if (scheduler == null)
 {
  log.error("Scheduler is down!");
 }
 else {
  try {
	  currentJobs = scheduler.getCurrentlyExecutingJobs();
  } catch (SchedulerException e) {
	  log.warn("Unable to get currently executing jobs");
  }
 }

 for (JobExecutionContext jec : currentJobs)
 {
  JobExecutionContextWrapperBean jobExecutionContextWrapper = new JobExecutionContextWrapperBean(this, jec);
  jobExecutionContextWrapper.setIsKillable(isJobKillable(jec.getJobDetail()));
  currentWrappedJobs.add(jobExecutionContextWrapper);
 }

 return currentWrappedJobs;
}
 
Example 3
Source File: SchedulerTool.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * This method runs the current job only once, right now
 * @return int 0 if it's not running, 1 if it is, 2 if there is an error
 */
public int getSelectedJobRunning()
{
   Scheduler scheduler = schedulerManager.getScheduler();
   if (scheduler == null)
   {
     log.error("Scheduler is down!");
     return 2;
   }
   try
   {
      List<JobExecutionContext> executingJobs = scheduler.getCurrentlyExecutingJobs();
      JobKey selected = selectedJobDetailWrapper.getJobDetail().getKey();

      for (JobExecutionContext jobExecutionContext : executingJobs) {
         if(selected.equals(jobExecutionContext.getJobDetail().getKey()) )
            return 1;
      }
      return 0;
   }
   catch (Exception e)
   {
     log.error("Failed to trigger job now", e);
     return 2;
   }
}
 
Example 4
Source File: SchedulerTool.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public List<JobExecutionContextWrapperBean> getRunningJobs() {
 List<JobExecutionContext> currentJobs = new ArrayList<JobExecutionContext>();
 List<JobExecutionContextWrapperBean> currentWrappedJobs = new ArrayList<JobExecutionContextWrapperBean>();
 Scheduler scheduler = schedulerManager.getScheduler();
 if (scheduler == null)
 {
  log.error("Scheduler is down!");
 }
 else {
  try {
	  currentJobs = scheduler.getCurrentlyExecutingJobs();
  } catch (SchedulerException e) {
	  log.warn("Unable to get currently executing jobs");
  }
 }

 for (JobExecutionContext jec : currentJobs)
 {
  JobExecutionContextWrapperBean jobExecutionContextWrapper = new JobExecutionContextWrapperBean(this, jec);
  jobExecutionContextWrapper.setIsKillable(isJobKillable(jec.getJobDetail()));
  currentWrappedJobs.add(jobExecutionContextWrapper);
 }

 return currentWrappedJobs;
}
 
Example 5
Source File: QuartzUtil.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public static List<String> getRunningJobNames(Scheduler scheduler) throws SchedulerException {
	List<JobExecutionContext> jobs = scheduler.getCurrentlyExecutingJobs();

	List<String> runningJobs = new ArrayList<String>();
	for (JobExecutionContext job : jobs) {
		runningJobs.add(job.getJobDetail().getKey().getName());
	}

	return runningJobs;
}
 
Example 6
Source File: QuartzUtil.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public static Map<String, JobExecutionContext> getRunningJobs(Scheduler scheduler) throws SchedulerException {
	Map<String, JobExecutionContext> runningJobs = new HashMap<String, JobExecutionContext>();
	List<JobExecutionContext> jobs = scheduler.getCurrentlyExecutingJobs();
	for (JobExecutionContext context : jobs) {
		runningJobs.put(context.getJobDetail().getKey().getName(), context);
	}
	
	return runningJobs;		
}