use of com.sequenceiq.cloudbreak.orchestrator.salt.client.target.Compound in project cloudbreak by hortonworks.
the class SaltStatesTest method setUp.
@Before
public void setUp() {
Set<String> targets = new HashSet<>();
targets.add("10-0-0-1.example.com");
targets.add("10-0-0-2.example.com");
targets.add("10-0-0-3.example.com");
target = new Compound(targets);
saltConnector = mock(SaltConnector.class);
}
use of com.sequenceiq.cloudbreak.orchestrator.salt.client.target.Compound in project cloudbreak by hortonworks.
the class ModifyGrainBase method submit.
@Override
public String submit(SaltConnector saltConnector) {
ApplyResponse response;
response = addGrain ? SaltStates.addGrain(saltConnector, new Compound(getTarget(), compoundType), key, value) : SaltStates.removeGrain(saltConnector, new Compound(getTarget(), compoundType), key, value);
Set<String> missingIps = collectMissingNodes(collectNodes(response));
setTarget(missingIps);
return missingIps.toString();
}
use of com.sequenceiq.cloudbreak.orchestrator.salt.client.target.Compound in project cloudbreak by hortonworks.
the class SaltOrchestrator method resetAmbari.
@Override
public void resetAmbari(GatewayConfig gatewayConfig, Set<String> target, Set<Node> allNodes, ExitCriteriaModel exitCriteriaModel) throws CloudbreakOrchestratorException {
try (SaltConnector saltConnector = new SaltConnector(gatewayConfig, restDebug)) {
BaseSaltJobRunner baseSaltJobRunner = new BaseSaltJobRunner(target, allNodes) {
@Override
public String submit(SaltConnector saltConnector) {
return SaltStates.ambariReset(saltConnector, new Compound(getTarget(), CompoundType.HOST));
}
};
OrchestratorBootstrap saltJobIdTracker = new SaltJobIdTracker(saltConnector, baseSaltJobRunner);
Callable<Boolean> saltJobRunBootstrapRunner = runner(saltJobIdTracker, exitCriteria, exitCriteriaModel);
Future<Boolean> saltJobRunBootstrapFuture = parallelOrchestratorComponentRunner.submit(saltJobRunBootstrapRunner);
saltJobRunBootstrapFuture.get();
} catch (Exception e) {
LOGGER.error("Error occurred during reset", e);
throw new CloudbreakOrchestratorFailedException(e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.salt.client.target.Compound in project cloudbreak by hortonworks.
the class SaltJobIdTracker method checkJobFinishedWithSuccess.
private void checkJobFinishedWithSuccess() {
String jobId = saltJobRunner.getJid().getJobId();
try {
Multimap<String, String> missingNodesWithReason = SaltStates.jidInfo(saltConnector, jobId, new Compound(saltJobRunner.getTarget()), saltJobRunner.stateType());
if (!missingNodesWithReason.isEmpty()) {
LOGGER.info("There are missing nodes after the job (jid: {}) completion: {}", jobId, String.join(",", missingNodesWithReason.keySet()));
saltJobRunner.setJobState(JobState.FAILED);
saltJobRunner.setNodesWithError(missingNodesWithReason);
saltJobRunner.setTarget(missingNodesWithReason.keySet());
} else {
LOGGER.info("The job (jid: {}) completed successfully on every node.", jobId);
saltJobRunner.setJobState(JobState.FINISHED);
}
} catch (RuntimeException e) {
LOGGER.warn("Fail while checking the result (jid: {}), this usually occurs due to concurrency", jobId, e);
saltJobRunner.setJobState(JobState.AMBIGUOUS);
}
}
Aggregations