Search in sources :

Example 1 with SchedulerMetaData

use of org.quartz.SchedulerMetaData in project kylo by Teradata.

the class QuartzScheduler method getMetaData.

public Map<String, Object> getMetaData() throws JobSchedulerException {
    Map<String, Object> map = new HashMap<String, Object>();
    try {
        SchedulerMetaData metaData = getScheduler().getMetaData();
        if (metaData != null) {
            ObjectMapper objectMapper = new ObjectMapper();
            map = objectMapper.convertValue(metaData, Map.class);
        }
    } catch (IllegalArgumentException | SchedulerException e) {
        throw new JobSchedulerException(e);
    }
    return map;
}
Also used : SchedulerException(org.quartz.SchedulerException) HashMap(java.util.HashMap) SchedulerMetaData(org.quartz.SchedulerMetaData) Map(java.util.Map) JobDataMap(org.quartz.JobDataMap) HashMap(java.util.HashMap) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with SchedulerMetaData

use of org.quartz.SchedulerMetaData in project iaf by ibissource.

the class SchedulerAdapter method getSchedulerMetaDataToXml.

public XmlBuilder getSchedulerMetaDataToXml(Scheduler theScheduler) {
    XmlBuilder xbRoot = new XmlBuilder("schedulerMetaData");
    try {
        SchedulerMetaData smd = theScheduler.getMetaData();
        xbRoot.addAttribute("schedulerName", smd.getSchedulerName());
        xbRoot.addAttribute("schedulerInstanceId", smd.getSchedulerInstanceId().toString());
        xbRoot.addAttribute("version", smd.getVersion());
        xbRoot.addAttribute("isPaused", (smd.isInStandbyMode() ? "True" : "False"));
        xbRoot.addAttribute("isSchedulerRemote", (smd.isSchedulerRemote() ? "True" : "False"));
        xbRoot.addAttribute("isShutdown", (smd.isShutdown() ? "True" : "False"));
        xbRoot.addAttribute("isStarted", (smd.isStarted() ? "True" : "False"));
        xbRoot.addAttribute("jobStoreSupportsPersistence", (smd.jobStoreSupportsPersistence() ? "True" : "False"));
        xbRoot.addAttribute("numJobsExecuted", Integer.toString(smd.getNumberOfJobsExecuted()));
        try {
            Date runningSince = smd.getRunningSince();
            xbRoot.addAttribute("runningSince", (null == runningSince ? "unknown" : DateUtils.format(runningSince, DateUtils.FORMAT_GENERICDATETIME)));
        } catch (Exception e) {
            log.debug(e);
        }
        ;
        xbRoot.addAttribute("jobStoreClass", smd.getJobStoreClass().getName());
        xbRoot.addAttribute("schedulerClass", smd.getSchedulerClass().getName());
        xbRoot.addAttribute("threadPoolClass", smd.getThreadPoolClass().getName());
        xbRoot.addAttribute("threadPoolSize", Integer.toString(smd.getThreadPoolSize()));
    } catch (SchedulerException se) {
        log.error(se);
    }
    return xbRoot;
}
Also used : SchedulerException(org.quartz.SchedulerException) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) SchedulerMetaData(org.quartz.SchedulerMetaData) Date(java.util.Date) SchedulerException(org.quartz.SchedulerException)

Example 3 with SchedulerMetaData

use of org.quartz.SchedulerMetaData in project iaf by ibissource.

the class ShowScheduler method getSchedulerMetaData.

private Map<String, Object> getSchedulerMetaData(Scheduler scheduler) throws ApiException {
    Map<String, Object> schedulesMap = new HashMap<String, Object>();
    try {
        SchedulerMetaData schedulerMetaData = scheduler.getMetaData();
        schedulesMap.put("name", schedulerMetaData.getSchedulerName());
        schedulesMap.put("instanceId", schedulerMetaData.getSchedulerInstanceId().toString());
        schedulesMap.put("version", schedulerMetaData.getVersion());
        schedulesMap.put("isSchedulerRemote", schedulerMetaData.isSchedulerRemote());
        String state = "unknown";
        if (schedulerMetaData.isStarted())
            state = "started";
        if (schedulerMetaData.isInStandbyMode())
            state = "paused";
        if (schedulerMetaData.isShutdown())
            state = "stopped";
        schedulesMap.put("state", state);
        schedulesMap.put("shutdown", schedulerMetaData.isShutdown());
        schedulesMap.put("started", schedulerMetaData.isStarted());
        schedulesMap.put("paused", schedulerMetaData.isInStandbyMode());
        schedulesMap.put("jobStoreSupportsPersistence", schedulerMetaData.jobStoreSupportsPersistence());
        schedulesMap.put("jobsExecuted", schedulerMetaData.getNumberOfJobsExecuted());
        long runningSinceInLong = 0;
        try {
            Date runningSince = schedulerMetaData.getRunningSince();
            runningSinceInLong = runningSince.getTime();
        } catch (Exception e) {
            log.debug(e);
        }
        schedulesMap.put("runningSince", runningSinceInLong);
        schedulesMap.put("jobStoreClass", schedulerMetaData.getJobStoreClass().getName());
        schedulesMap.put("schedulerClass", schedulerMetaData.getSchedulerClass().getName());
        schedulesMap.put("threadPoolClass", schedulerMetaData.getThreadPoolClass().getName());
        schedulesMap.put("threadPoolSize", schedulerMetaData.getThreadPoolSize());
    } catch (SchedulerException se) {
        log.error(se);
    }
    return schedulesMap;
}
Also used : SchedulerException(org.quartz.SchedulerException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) SchedulerMetaData(org.quartz.SchedulerMetaData) Date(java.util.Date) SchedulerException(org.quartz.SchedulerException)

Aggregations

SchedulerException (org.quartz.SchedulerException)3 SchedulerMetaData (org.quartz.SchedulerMetaData)3 Date (java.util.Date)2 HashMap (java.util.HashMap)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 XmlBuilder (nl.nn.adapterframework.util.XmlBuilder)1 JobDataMap (org.quartz.JobDataMap)1