Java Code Examples for org.quartz.Scheduler#getJobGroupNames()
The following examples show how to use
org.quartz.Scheduler#getJobGroupNames() .
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: QuartzAdapter.java From javamelody with Apache License 2.0 | 6 votes |
List<JobDetail> getAllJobsOfScheduler(Scheduler scheduler) throws SchedulerException { final List<JobDetail> result = new ArrayList<JobDetail>(); for (final String jobGroupName : scheduler.getJobGroupNames()) { for (final String jobName : scheduler.getJobNames(jobGroupName)) { final JobDetail jobDetail; try { jobDetail = scheduler.getJobDetail(jobName, jobGroupName); // le job peut être terminé et supprimé depuis la ligne ci-dessus if (jobDetail != null) { result.add(jobDetail); } } catch (final Exception e) { // si les jobs sont persistés en base de données, il peut y avoir une exception // dans getJobDetail, par exemple si la classe du job n'existe plus dans l'application LOG.debug(e.toString(), e); } } } return result; }
Example 2
Source File: Quartz2Adapter.java From javamelody with Apache License 2.0 | 6 votes |
@Override List<JobDetail> getAllJobsOfScheduler(Scheduler scheduler) throws SchedulerException { final List<JobDetail> result = new ArrayList<JobDetail>(); for (final String jobGroupName : scheduler.getJobGroupNames()) { final GroupMatcher<JobKey> groupMatcher = GroupMatcher.groupEquals(jobGroupName); for (final JobKey jobKey : scheduler.getJobKeys(groupMatcher)) { final JobDetail jobDetail; try { jobDetail = scheduler.getJobDetail(jobKey); // le job peut être terminé et supprimé depuis la ligne ci-dessus if (jobDetail != null) { result.add(jobDetail); } } catch (final Exception e) { // si les jobs sont persistés en base de données, il peut y avoir une exception // dans getJobDetail, par exemple si la classe du job n'existe plus dans l'application LOG.debug(e.toString(), e); } } } return result; }
Example 3
Source File: ShowScheduler.java From iaf with Apache License 2.0 | 6 votes |
private Map<String,Object> getJobGroupNamesWithJobs(Scheduler scheduler) throws ApiException { Map<String, Object> jobGroups = new HashMap<String, Object>(); try { List<String> jobGroupNames = scheduler.getJobGroupNames(); for(String jobGroupName : jobGroupNames) { Map<String, Object> jobsInGroup = new HashMap<String, Object>(); Set<JobKey> jobKeys = scheduler.getJobKeys(GroupMatcher.jobGroupEquals(jobGroupName)); for (JobKey jobKey : jobKeys) { jobsInGroup.put(jobKey.getName(), getJobData(jobKey, false)); } jobGroups.put(jobGroupName, jobsInGroup); } } catch (Exception e) { log.error("error retrieving job from jobgroup", e); } return jobGroups; }
Example 4
Source File: ScheduleServiceImpl.java From fixflow with Apache License 2.0 | 6 votes |
public List<JobDetail> getJobList(String queryId){ if(!getIsEnabled()){ throw new FixFlowScheduleException(ExceptionCode.QUARZTEXCEPTION_ISENABLE); } Scheduler scheduler = getScheduler(); List<JobDetail> jobList = new ArrayList<JobDetail>(); Set<JobKey> set = new HashSet<JobKey>(); try { //如果queryId不为空,则返回queryId对应的job,否则返回所有job if(StringUtil.isNotEmpty(queryId)){ set = scheduler.getJobKeys(GroupMatcher.jobGroupContains(queryId)); }else{ List<String> groupNames = scheduler.getJobGroupNames(); for(String groupName:groupNames){ set.addAll(scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))); } } for(JobKey key :set){ JobDetail job = scheduler.getJobDetail(key); jobList.add(job); } }catch (SchedulerException e) { throw new FixFlowException(e.getMessage(),e); } return jobList; }
Example 5
Source File: SiteScheduledJobsController.java From engine with GNU General Public License v3.0 | 6 votes |
@GetMapping(URL_LIST) @SuppressWarnings("unchecked") public List<Map<String, String>> listScheduledJobs() throws SchedulerException { List<Map<String, String>> jobs = new LinkedList<>(); SiteContext siteContext = SiteContext.getCurrent(); Scheduler scheduler = siteContext.getScheduler(); if(scheduler != null) { List<String> groups = scheduler.getJobGroupNames(); for (String group : groups) { Set<JobKey> keys = scheduler.getJobKeys(GroupMatcher.jobGroupEquals(group)); for (JobKey key : keys) { List<Trigger> triggers = (List<Trigger>)scheduler.getTriggersOfJob(key); Map<String, String> job = new HashMap<>(); job.put("name", key.getName()); job.put("nextFireTime", triggers.get(0).getNextFireTime().toInstant().toString()); jobs.add(job); } } } return jobs; }
Example 6
Source File: QuartzJobHandler.java From nextreports-server with Apache License 2.0 | 6 votes |
public static void listJobs(Scheduler scheduler) throws SchedulerException { if (!LOG.isDebugEnabled()) { return; } List<String> jobGroups = scheduler.getJobGroupNames(); if (jobGroups.isEmpty()) { LOG.debug("No jobs !!!"); } for (String jobGroup : jobGroups) { LOG.debug("Group '{}' contains the following jobs:", jobGroup); Set<JobKey> jobKeys = scheduler.getJobKeys(GroupMatcher.jobGroupEquals(jobGroup)); for (JobKey jobKey : jobKeys) { LOG.debug("- {}", jobKey.getName()); } } }
Example 7
Source File: QuartzUtils.java From quartz-web with Apache License 2.0 | 5 votes |
/** * 获取scheduler下所有的jobDetail * @param scheduler * @return * @throws SchedulerException */ public static List<JobDetail> getAllJobsOfScheduler(Scheduler scheduler) throws SchedulerException { List<JobDetail> result = new ArrayList<JobDetail>(); List<String> jobGroupNames = scheduler.getJobGroupNames(); for (String groupName : jobGroupNames) { Set<JobKey> jobKeys = scheduler.getJobKeys(GroupMatcher.<JobKey>groupEquals(groupName)); for (JobKey jobKey : jobKeys) { JobDetail jobDetail = scheduler.getJobDetail(jobKey); result.add(jobDetail); } } return result; }
Example 8
Source File: SchedulerServiceSupplier.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
/** * Gets the job list. * * @return the job list */ public String getJobList() { String xml = ""; try { Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler(); List toReturn = new ArrayList(); String[] groups = scheduler.getJobGroupNames(); if (groups == null || groups.length == 0) { SpagoBITracer.warning(SpagoBIConstants.NAME_MODULE, this.getClass().getName(), "getJobList", "No job groups defined!"); } else { for (int i = 0; i < groups.length; i++) { String group = groups[i]; String[] jobNames = scheduler.getJobNames(group); if (jobNames == null || jobNames.length == 0) { SpagoBITracer.warning(SpagoBIConstants.NAME_MODULE, this.getClass().getName(), "getJobList", "No job defined for group " + group + "!"); } else { for (int j = 0; j < jobNames.length; j++) { JobDetail aJob = scheduler.getJobDetail(jobNames[j], group); toReturn.add(aJob); } } } } xml = buildJobListXmlString(toReturn); } catch (Exception e) { SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(), "getJobList", "Error while recovering job list"); xml = "<ROWS></ROWS>"; } return xml; }
Example 9
Source File: PlugwiseBinding.java From openhab1-addons with Eclipse Public License 2.0 | 5 votes |
private boolean isExistingJob(Scheduler scheduler, String jobName) { try { for (String group : scheduler.getJobGroupNames()) { for (JobKey jobKey : scheduler.getJobKeys(jobGroupEquals(group))) { if (jobKey.getName().equals(jobName)) { return true; } } } } catch (SchedulerException e1) { logger.error("An exception occurred while querying the Quartz Scheduler ({})", e1.getMessage()); } return false; }
Example 10
Source File: QuartzUtil.java From nextreports-server with Apache License 2.0 | 5 votes |
public static List<JobDetail> getAllJobDetails(Scheduler scheduler) throws SchedulerException { List<JobDetail> jobDetails = new ArrayList<JobDetail>(); List<String> groupNames = scheduler.getJobGroupNames(); for (String jobGroup : groupNames) { Set<JobKey> jobKeys = scheduler.getJobKeys(GroupMatcher.jobGroupEquals(jobGroup)); for (JobKey jobKey : jobKeys) { jobDetails.add(scheduler.getJobDetail(jobKey)); } } return jobDetails; }
Example 11
Source File: JobServiceImpl.java From spring-boot-quartz-demo with MIT License | 4 votes |
/** * Get all jobs */ @Override public List<Map<String, Object>> getAllJobs() { List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); try { Scheduler scheduler = schedulerFactoryBean.getScheduler(); for (String groupName : scheduler.getJobGroupNames()) { for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) { String jobName = jobKey.getName(); String jobGroup = jobKey.getGroup(); //get job's trigger List<Trigger> triggers = (List<Trigger>) scheduler.getTriggersOfJob(jobKey); Date scheduleTime = triggers.get(0).getStartTime(); Date nextFireTime = triggers.get(0).getNextFireTime(); Date lastFiredTime = triggers.get(0).getPreviousFireTime(); Map<String, Object> map = new HashMap<String, Object>(); map.put("jobName", jobName); map.put("groupName", jobGroup); map.put("scheduleTime", scheduleTime); map.put("lastFiredTime", lastFiredTime); map.put("nextFireTime", nextFireTime); if(isJobRunning(jobName)){ map.put("jobStatus", "RUNNING"); }else{ String jobState = getJobState(jobName); map.put("jobStatus", jobState); } /* Date currentDate = new Date(); if (scheduleTime.compareTo(currentDate) > 0) { map.put("jobStatus", "scheduled"); } else if (scheduleTime.compareTo(currentDate) < 0) { map.put("jobStatus", "Running"); } else if (scheduleTime.compareTo(currentDate) == 0) { map.put("jobStatus", "Running"); }*/ list.add(map); System.out.println("Job details:"); System.out.println("Job Name:"+jobName + ", Group Name:"+ groupName + ", Schedule Time:"+scheduleTime); } } } catch (SchedulerException e) { System.out.println("SchedulerException while fetching all jobs. error message :"+e.getMessage()); e.printStackTrace(); } return list; }
Example 12
Source File: SchedulerAdapter.java From iaf with Apache License 2.0 | 4 votes |
/** * Get all jobgroups, jobs within this group, the jobdetail and the * associated triggers in XML format. */ public XmlBuilder getJobGroupNamesWithJobsToXml(Scheduler theScheduler, IbisManager ibisManager) { XmlBuilder xbRoot = new XmlBuilder("jobGroups"); try { // process groups List<String> jgnames = theScheduler.getJobGroupNames(); for (int i = 0; i < jgnames.size(); i++) { XmlBuilder el = new XmlBuilder("jobGroup"); String jobGroupName = jgnames.get(i); el.addAttribute("name", jobGroupName); // process jobs within group XmlBuilder jb = new XmlBuilder("jobs"); Set<JobKey> jobKeys = theScheduler.getJobKeys(GroupMatcher.jobGroupEquals(jobGroupName)); for (JobKey jobKey : jobKeys) { XmlBuilder jn = new XmlBuilder("job"); String jobName = jobKey.getName(); jn.addAttribute("name", jobName); // details for job JobDetail jobDetail = theScheduler.getJobDetail(jobKey); XmlBuilder jd = jobDetailToXmlBuilder(jobDetail); jn.addSubElement(jd); // get the triggers for this job List<? extends Trigger> triggers = theScheduler.getTriggersOfJob(jobKey); XmlBuilder tr = getJobTriggers(triggers); jn.addSubElement(tr); JobDataMap jobDataMap = jobDetail.getJobDataMap(); XmlBuilder datamap = jobDataMapToXmlBuilder(jobDataMap); jn.addSubElement(datamap); jb.addSubElement(jn); JobDef jobDef = null; if(ibisManager != null) { for (Configuration configuration : ibisManager.getConfigurations()) { jobDef = configuration.getScheduledJob(jobName); if (jobDef != null) { break; } } } XmlBuilder ms = getJobMessages(jobDef); jn.addSubElement(ms); XmlBuilder jrs= getJobRunStatistics(jobDef); jn.addSubElement(jrs); } el.addSubElement(jb); xbRoot.addSubElement(el); } } catch (SchedulerException se) { log.error(se); } return xbRoot; }