Search in sources :

Example 1 with Compound

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);
}
Also used : Compound(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.Compound) SaltConnector(com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 2 with Compound

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();
}
Also used : Compound(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.Compound) ApplyResponse(com.sequenceiq.cloudbreak.orchestrator.salt.domain.ApplyResponse)

Example 3 with Compound

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);
    }
}
Also used : CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) OrchestratorBootstrap(com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap) SaltJobIdTracker(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker) BaseSaltJobRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.BaseSaltJobRunner) Compound(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.Compound) SaltConnector(com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Example 4 with Compound

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);
    }
}
Also used : Compound(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.Compound)

Aggregations

Compound (com.sequenceiq.cloudbreak.orchestrator.salt.client.target.Compound)4 SaltConnector (com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector)2 OrchestratorBootstrap (com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap)1 CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)1 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)1 ApplyResponse (com.sequenceiq.cloudbreak.orchestrator.salt.domain.ApplyResponse)1 BaseSaltJobRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.BaseSaltJobRunner)1 SaltJobIdTracker (com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 ExecutionException (java.util.concurrent.ExecutionException)1 Before (org.junit.Before)1