use of de.cinovo.cloudconductor.agent.jobs.AgentJob in project cloudconductor-agent-redhat by cinovo.
the class NodeAgent method doAfterSpringStart.
@Override
public void doAfterSpringStart() {
super.doAfterSpringStart();
this.waitForServer();
// initialize yum repos
try {
if (AgentState.repoExecutionLock.tryLock()) {
new RepoHandler().run();
}
} catch (ExecutionError e) {
NodeAgent.LOGGER.error("Error initializing yum repos: ", e);
return;
} finally {
AgentState.repoExecutionLock.unlock();
}
// start timed jobs
for (Class<AgentJob> jobClazz : OptionHandler.jobRegistry) {
AgentJob job;
try {
job = jobClazz.newInstance();
if (job.isDefaultStart()) {
SchedulerService.instance.register(job.getJobIdentifier(), job, job.defaultStartTimer(), job.defaultStartTimerUnit());
NodeAgent.LOGGER.info("Registered " + job.getJobIdentifier() + " as defaultstart with " + job.defaultStartTimer() + ":" + job.defaultStartTimerUnit());
} else {
SchedulerService.instance.register(job.getJobIdentifier(), job);
NodeAgent.LOGGER.info("Registered " + job.getJobIdentifier());
}
} catch (InstantiationException | IllegalAccessException e) {
NodeAgent.LOGGER.error("Couldn't start job: " + jobClazz.getName(), e);
}
}
}
Aggregations