use of nl.nn.adapterframework.scheduler.job.IJob in project iaf by ibissource.
the class ShowScheduler method getJobMessages.
private List<Map<String, Object>> getJobMessages(JobDetail jobDetail) throws ApiException {
List<Map<String, Object>> messages = new ArrayList<Map<String, Object>>();
IJob jobdef = (IJob) jobDetail.getJobDataMap().get(ConfiguredJob.JOBDEF_KEY);
for (int t = 0; t < jobdef.getMessageKeeper().size(); t++) {
Map<String, Object> message = new HashMap<String, Object>(3);
MessageKeeperMessage job = jobdef.getMessageKeeper().getMessage(t);
message.put("text", job.getMessageText());
message.put("date", job.getMessageDate());
message.put("level", job.getMessageLevel());
messages.add(message);
}
return messages;
}
use of nl.nn.adapterframework.scheduler.job.IJob in project iaf by ibissource.
the class ShowScheduler method getJobData.
private Map<String, Object> getJobData(JobKey jobKey, boolean expanded) throws SchedulerException {
Map<String, Object> jobData = new HashMap<String, Object>();
Scheduler scheduler = getScheduler();
String jobName = jobKey.getName();
JobDetail job = scheduler.getJobDetail(jobKey);
jobData.put("fullName", job.getKey().getGroup() + "." + job.getKey().getName());
jobData.put("name", job.getKey().getName());
jobData.put("group", job.getKey().getGroup());
String description = "-";
if (StringUtils.isNotEmpty(job.getDescription()))
description = job.getDescription();
jobData.put("description", description);
jobData.put("stateful", job.isPersistJobDataAfterExecution() && job.isConcurrentExectionDisallowed());
jobData.put("durable", job.isDurable());
jobData.put("jobClass", job.getJobClass().getSimpleName());
if (job instanceof IbisJobDetail) {
jobData.put("type", ((IbisJobDetail) job).getJobType());
}
TriggerState state = scheduler.getTriggerState(TriggerKey.triggerKey(jobName, jobKey.getGroup()));
jobData.put("state", state.name());
jobData.put("triggers", getJobTriggers(scheduler.getTriggersOfJob(jobKey)));
jobData.put("messages", getJobMessages(job));
JobDataMap jobMap = job.getJobDataMap();
jobData.put("properties", getJobData(jobMap));
if (expanded) {
IJob jobDef = (IJob) jobMap.get(ConfiguredJob.JOBDEF_KEY);
if (jobDef instanceof DatabaseJob) {
DatabaseJob dbJob = (DatabaseJob) jobDef;
jobData.put("adapter", dbJob.getAdapterName());
jobData.put("listener", dbJob.getJavaListener());
jobData.put("message", dbJob.getMessage());
}
Locker locker = jobDef.getLocker();
if (locker != null) {
jobData.put("locker", true);
jobData.put("lockkey", locker.getObjectId());
} else {
jobData.put("locker", false);
}
}
return jobData;
}
use of nl.nn.adapterframework.scheduler.job.IJob in project iaf by ibissource.
the class ScheduleManager method configure.
@Override
public void configure() {
if (!inState(BootState.STOPPED)) {
log.warn("unable to configure [" + this + "] while in state [" + getState() + "]");
return;
}
updateState(BootState.STARTING);
for (IJob jobdef : getSchedulesList()) {
try {
jobdef.configure();
log.info("job scheduled with properties :" + jobdef.toString());
} catch (Exception e) {
log.error("Could not schedule job [" + jobdef.getName() + "] cron [" + jobdef.getCronExpression() + "]", e);
}
}
}
use of nl.nn.adapterframework.scheduler.job.IJob in project iaf by ibissource.
the class ScheduleManager method start.
/**
* Configure and start, managed through the Spring Lifecyle
*/
@Override
public void start() {
if (!inState(BootState.STARTING)) {
log.warn("unable to start [" + this + "] while in state [" + getState() + "]");
return;
}
for (IJob jobdef : getSchedulesList()) {
if (jobdef.isConfigured()) {
try {
schedulerHelper.scheduleJob(jobdef);
log.info("job scheduled with properties :" + jobdef.toString());
} catch (SchedulerException e) {
log.error("Could not schedule job [" + jobdef.getName() + "] cron [" + jobdef.getCronExpression() + "]", e);
}
} else {
log.info("Could not schedule job [" + jobdef.getName() + "] as it is not configured");
}
}
try {
schedulerHelper.startScheduler();
log.info("Scheduler started");
} catch (SchedulerException e) {
log.error("Could not start scheduler", e);
}
updateState(BootState.STARTED);
}
use of nl.nn.adapterframework.scheduler.job.IJob in project iaf by ibissource.
the class ConfiguredJob method execute.
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
String ctName = Thread.currentThread().getName();
try {
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
IbisManager ibisManager = (IbisManager) dataMap.get(MANAGER_KEY);
IJob jobDef = (IJob) dataMap.get(JOBDEF_KEY);
Thread.currentThread().setName(jobDef.getName() + "[" + ctName + "]");
log.info(getLogPrefix(jobDef) + "executing");
jobDef.executeJob(ibisManager);
log.debug(getLogPrefix(jobDef) + "completed");
} catch (Exception e) {
log.error("JobExecutionException while running " + getLogPrefix(context), e);
throw new JobExecutionException(e, false);
} finally {
Thread.currentThread().setName(ctName);
}
}
Aggregations