Search in sources :

Example 1 with RepoHandler

use of de.cinovo.cloudconductor.agent.jobs.handler.RepoHandler in project cloudconductor-agent-redhat by cinovo.

the class HeartBeatJob method run.

@Override
public void run() {
    HeartBeatJob.LOGGER.debug("Starting HeartBeatJob");
    AgentOption newOptions;
    try {
        newOptions = ServerCom.heartBeat();
    } catch (CloudConductorException e) {
        HeartBeatJob.LOGGER.error("Error getting options from server: ", e);
        return;
    }
    new OptionHandler(newOptions).run();
    try {
        if (AgentState.repoExecutionLock.tryLock()) {
            new RepoHandler().run();
        }
    } catch (ExecutionError e) {
        HeartBeatJob.LOGGER.error("Error updating repos: ", e);
    } finally {
        AgentState.repoExecutionLock.unlock();
    }
    HeartBeatJob.LOGGER.debug("Finished HeartBeatJob");
}
Also used : CloudConductorException(de.cinovo.cloudconductor.api.lib.exceptions.CloudConductorException) ExecutionError(de.cinovo.cloudconductor.agent.exceptions.ExecutionError) RepoHandler(de.cinovo.cloudconductor.agent.jobs.handler.RepoHandler) AgentOption(de.cinovo.cloudconductor.api.model.AgentOption) OptionHandler(de.cinovo.cloudconductor.agent.jobs.handler.OptionHandler)

Example 2 with RepoHandler

use of de.cinovo.cloudconductor.agent.jobs.handler.RepoHandler 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);
        }
    }
}
Also used : ExecutionError(de.cinovo.cloudconductor.agent.exceptions.ExecutionError) AgentJob(de.cinovo.cloudconductor.agent.jobs.AgentJob) RepoHandler(de.cinovo.cloudconductor.agent.jobs.handler.RepoHandler)

Aggregations

ExecutionError (de.cinovo.cloudconductor.agent.exceptions.ExecutionError)2 RepoHandler (de.cinovo.cloudconductor.agent.jobs.handler.RepoHandler)2 AgentJob (de.cinovo.cloudconductor.agent.jobs.AgentJob)1 OptionHandler (de.cinovo.cloudconductor.agent.jobs.handler.OptionHandler)1 CloudConductorException (de.cinovo.cloudconductor.api.lib.exceptions.CloudConductorException)1 AgentOption (de.cinovo.cloudconductor.api.model.AgentOption)1