use of com.sequenceiq.cloudbreak.orchestrator.salt.domain.JobId in project cloudbreak by hortonworks.
the class SaltJobIdTracker method call.
@Override
public Boolean call() throws Exception {
if (JobState.NOT_STARTED.equals(saltJobRunner.getJobState())) {
LOGGER.info("Job has not started in the cluster. Starting for first time.");
JobId jobIdObject = jobId(saltJobRunner.submit(saltConnector));
String jobId = jobIdObject.getJobId();
saltJobRunner.setJid(jobIdObject);
checkIsFinished(jobId);
} else if (JobState.IN_PROGRESS.equals(saltJobRunner.getJobState())) {
String jobId = saltJobRunner.getJid().getJobId();
LOGGER.info("Job: {} is running currently checking the current state.", jobId);
checkIsFinished(jobId);
} else if (!retryOnFail && JobState.FAILED == saltJobRunner.getJobState()) {
String jobId = saltJobRunner.getJid().getJobId();
LOGGER.info("Job: {} failed. Terminate execution on these targets: {}", jobId, saltJobRunner.getTarget());
throw new CloudbreakOrchestratorTerminateException(buildErrorMessage());
} else if (JobState.FAILED == saltJobRunner.getJobState() || JobState.AMBIGUOUS == saltJobRunner.getJobState()) {
String jobId = saltJobRunner.getJid().getJobId();
LOGGER.info("Job: {} failed in the previous time. Trigger again with these targets: {}", jobId, saltJobRunner.getTarget());
saltJobRunner.setJid(jobId(saltJobRunner.submit(saltConnector)));
saltJobRunner.setJobState(JobState.IN_PROGRESS);
return call();
}
if (JobState.IN_PROGRESS.equals(saltJobRunner.getJobState())) {
String jobIsRunningMessage = String.format("Job: %s is running currently", saltJobRunner.getJid());
throw new CloudbreakOrchestratorFailedException(jobIsRunningMessage);
}
if (JobState.FAILED == saltJobRunner.getJobState() || JobState.AMBIGUOUS == saltJobRunner.getJobState()) {
throw new CloudbreakOrchestratorFailedException(buildErrorMessage());
}
LOGGER.info("Job (jid: {}) was finished. Triggering next salt event.", saltJobRunner.getJid().getJobId());
return true;
}
Aggregations