Search in sources :

Example 1 with JobDef

use of nl.nn.adapterframework.scheduler.JobDef in project iaf by ibissource.

the class ShowScheduler method getJobGroupNamesWithJobs.

private Map<String, Object> getJobGroupNamesWithJobs(Scheduler scheduler) throws ApiException {
    Map<String, Object> jobGroups = new HashMap<String, Object>();
    try {
        String[] jobGroupNames = scheduler.getJobGroupNames();
        for (int i = 0; i < jobGroupNames.length; i++) {
            Map<String, Object> jobsInGroup = new HashMap<String, Object>();
            String jobGroupName = jobGroupNames[i];
            String[] jobNames = scheduler.getJobNames(jobGroupName);
            for (int j = 0; j < jobNames.length; j++) {
                String jobName = jobNames[j];
                Map<String, Object> jobData = new HashMap<String, Object>();
                JobDef jobDef = null;
                for (Configuration configuration : ibisManager.getConfigurations()) {
                    jobDef = configuration.getScheduledJob(jobName);
                    if (jobDef != null) {
                        break;
                    }
                }
                JobDetail job = scheduler.getJobDetail(jobName, jobGroupName);
                jobData.put("fullName", job.getFullName());
                jobData.put("name", job.getName());
                String description = "-";
                if (StringUtils.isNotEmpty(job.getDescription()))
                    description = job.getDescription();
                jobData.put("description", description);
                jobData.put("stateful", job.isStateful());
                jobData.put("durable", job.isDurable());
                jobData.put("volatile", job.isVolatile());
                jobData.put("jobClass", job.getJobClass().getName());
                jobData.put("triggers", getJobTriggers(scheduler, jobName, jobGroupName));
                jobData.put("messages", getJobMessages(jobDef));
                JobDataMap jobMap = job.getJobDataMap();
                jobData.put("containsTransientData", jobMap.containsTransientData());
                jobData.put("allowsTransientData", jobMap.getAllowsTransientData());
                jobData.put("properties", getJobData(jobMap));
                jobsInGroup.put(jobName, jobData);
            }
            jobGroups.put(jobGroupName, jobsInGroup);
        }
    } catch (Exception e) {
        log.error(e);
    }
    return jobGroups;
}
Also used : JobDetail(org.quartz.JobDetail) JobDataMap(org.quartz.JobDataMap) Configuration(nl.nn.adapterframework.configuration.Configuration) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) JobDef(nl.nn.adapterframework.scheduler.JobDef) SchedulerException(org.quartz.SchedulerException)

Example 2 with JobDef

use of nl.nn.adapterframework.scheduler.JobDef in project iaf by ibissource.

the class DefaultIbisManager method startScheduledJobs.

public void startScheduledJobs(Configuration configuration) {
    List<JobDef> scheduledJobs = configuration.getScheduledJobs();
    for (Iterator<JobDef> iter = scheduledJobs.iterator(); iter.hasNext(); ) {
        JobDef jobdef = iter.next();
        try {
            schedulerHelper.scheduleJob(this, jobdef);
            log.info("job scheduled with properties :" + jobdef.toString());
        } catch (Exception e) {
            log.error("Could not schedule job [" + jobdef.getName() + "] cron [" + jobdef.getCronExpression() + "]", e);
        }
    }
    try {
        schedulerHelper.startScheduler();
        log.info("Scheduler started");
    } catch (SchedulerException e) {
        log.error("Could not start scheduler", e);
    }
}
Also used : SchedulerException(org.quartz.SchedulerException) JobDef(nl.nn.adapterframework.scheduler.JobDef) SchedulerException(org.quartz.SchedulerException)

Aggregations

JobDef (nl.nn.adapterframework.scheduler.JobDef)2 SchedulerException (org.quartz.SchedulerException)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Configuration (nl.nn.adapterframework.configuration.Configuration)1 JobDataMap (org.quartz.JobDataMap)1 JobDetail (org.quartz.JobDetail)1