use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorTerminateException 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;
}
use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorTerminateException in project cloudbreak by hortonworks.
the class OrchestratorBootstrapRunner method doCall.
private ImmutablePair<Boolean, Exception> doCall() throws CloudbreakOrchestratorCancelledException, InterruptedException {
Boolean success = null;
int retryCount = 1;
Exception actualException = null;
String type = orchestratorBootstrap.getClass().getSimpleName().replace("Bootstrap", "");
long initialStartTime = System.currentTimeMillis();
while (success == null && retryCount <= maxRetryCount) {
if (isExitNeeded()) {
LOGGER.error(exitCriteria.exitMessage());
throw new CloudbreakOrchestratorCancelledException(exitCriteria.exitMessage());
}
long startTime = System.currentTimeMillis();
try {
LOGGER.info("Calling orchestrator bootstrap: {}, additional info: {}", type, orchestratorBootstrap);
orchestratorBootstrap.call();
long elapsedTime = System.currentTimeMillis() - startTime;
long totalElapsedTime = System.currentTimeMillis() - initialStartTime;
success = true;
LOGGER.info("Orchestrator component {} successfully started! Elapsed time: {} ms, Total elapsed time: {} ms, " + "additional info: {}", type, elapsedTime, totalElapsedTime, orchestratorBootstrap);
} catch (CloudbreakOrchestratorTerminateException te) {
actualException = te;
long elapsedTime = System.currentTimeMillis() - startTime;
long totalElapsedTime = System.currentTimeMillis() - initialStartTime;
success = false;
LOGGER.info("Failed to execute orchestrator component {}! Elapsed time: {} ms, Total elapsed time: {} ms, " + "additional info: {}", type, elapsedTime, totalElapsedTime, orchestratorBootstrap);
} catch (Exception ex) {
actualException = ex;
long elapsedTime = System.currentTimeMillis() - startTime;
long totalElapsedTime = System.currentTimeMillis() - initialStartTime;
LOGGER.warn("Orchestrator component {} failed to start, retrying [{}/{}] Elapsed time: {} ms, " + "Total elapsed time: {} ms, Reason: {}, additional info: {}", type, retryCount, maxRetryCount, elapsedTime, totalElapsedTime, actualException.getMessage(), orchestratorBootstrap);
retryCount++;
if (retryCount <= maxRetryCount) {
Thread.sleep(sleepTime);
} else {
success = Boolean.FALSE;
}
}
}
return new ImmutablePair<>(success, actualException);
}
Aggregations