Search in sources :

Example 1 with GrainOperation

use of com.sequenceiq.cloudbreak.orchestrator.host.GrainOperation in project cloudbreak by hortonworks.

the class SaltOrchestrator method runOrchestratorGrainRunner.

@Override
public void runOrchestratorGrainRunner(OrchestratorGrainRunnerParams grainRunnerParams) throws CloudbreakOrchestratorFailedException {
    try (SaltConnector sc = saltService.createSaltConnector(grainRunnerParams.getPrimaryGatewayConfig())) {
        Set<String> targetHostNames = grainRunnerParams.getTargetHostNames();
        GrainOperation grainOperation = grainRunnerParams.getGrainOperation();
        Set<Node> allNodes = grainRunnerParams.getAllNodes();
        String key = grainRunnerParams.getKey();
        String value = grainRunnerParams.getValue();
        ModifyGrainBase runner;
        switch(grainOperation) {
            case ADD:
                runner = new GrainAddRunner(targetHostNames, allNodes, key, value);
                break;
            case REMOVE:
                runner = new GrainRemoveRunner(targetHostNames, allNodes, key, value);
                break;
            default:
                throw new IllegalStateException("Unexpected value: " + grainOperation);
        }
        saltCommandRunner.runModifyGrainCommand(sc, runner, grainRunnerParams.getExitCriteriaModel(), exitCriteria);
    } catch (Exception e) {
        LOGGER.error("Exception during grain runner", e);
        throw new CloudbreakOrchestratorFailedException(e.getMessage(), e);
    }
}
Also used : ModifyGrainBase(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ModifyGrainBase) GrainRemoveRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainRemoveRunner) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) JsonNode(com.fasterxml.jackson.databind.JsonNode) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) GrainOperation(com.sequenceiq.cloudbreak.orchestrator.host.GrainOperation) GrainAddRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainAddRunner) SaltConnector(com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) CloudbreakOrchestratorTimeoutException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorTimeoutException) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)1 Node (com.sequenceiq.cloudbreak.common.orchestration.Node)1 CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)1 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)1 CloudbreakOrchestratorTimeoutException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorTimeoutException)1 GrainOperation (com.sequenceiq.cloudbreak.orchestrator.host.GrainOperation)1 SaltConnector (com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector)1 GrainAddRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainAddRunner)1 GrainRemoveRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainRemoveRunner)1 ModifyGrainBase (com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ModifyGrainBase)1 IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1