use of com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap in project cloudbreak by hortonworks.
the class SaltOrchestrator method bootstrapNewNodes.
@Override
public void bootstrapNewNodes(List<GatewayConfig> allGatewayConfigs, Set<Node> targets, Set<Node> allNodes, byte[] stateConfigZip, ExitCriteriaModel exitModel) throws CloudbreakOrchestratorException {
GatewayConfig primaryGateway = getPrimaryGatewayConfig(allGatewayConfigs);
Set<String> gatewayTargets = allGatewayConfigs.stream().filter(gc -> targets.stream().anyMatch(n -> gc.getPrivateAddress().equals(n.getPrivateIp()))).map(GatewayConfig::getPrivateAddress).collect(Collectors.toSet());
try (SaltConnector sc = new SaltConnector(primaryGateway, restDebug)) {
if (!gatewayTargets.isEmpty()) {
uploadSaltConfig(sc, gatewayTargets, stateConfigZip, exitModel);
}
uploadSignKey(sc, primaryGateway, gatewayTargets, targets.stream().map(Node::getPrivateIp).collect(Collectors.toSet()), exitModel);
// if there is a new salt master then re-bootstrap all nodes
Set<Node> nodes = gatewayTargets.isEmpty() ? targets : allNodes;
OrchestratorBootstrap saltBootstrap = new SaltBootstrap(sc, allGatewayConfigs, nodes);
Callable<Boolean> saltBootstrapRunner = runner(saltBootstrap, exitCriteria, exitModel);
Future<Boolean> saltBootstrapRunnerFuture = parallelOrchestratorComponentRunner.submit(saltBootstrapRunner);
saltBootstrapRunnerFuture.get();
} catch (Exception e) {
LOGGER.error("Error occurred during salt upscale", e);
throw new CloudbreakOrchestratorFailedException(e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap in project cloudbreak by hortonworks.
the class SaltOrchestrator method bootstrap.
@Override
public void bootstrap(List<GatewayConfig> allGatewayConfigs, Set<Node> targets, ExitCriteriaModel exitModel) throws CloudbreakOrchestratorException {
LOGGER.info("Start SaltBootstrap on nodes: {}", targets);
GatewayConfig primaryGateway = getPrimaryGatewayConfig(allGatewayConfigs);
Set<String> gatewayTargets = getGatewayPrivateIps(allGatewayConfigs);
try (SaltConnector sc = new SaltConnector(primaryGateway, restDebug)) {
uploadSaltConfig(sc, gatewayTargets, exitModel);
uploadSignKey(sc, primaryGateway, gatewayTargets, targets.stream().map(Node::getPrivateIp).collect(Collectors.toSet()), exitModel);
OrchestratorBootstrap saltBootstrap = new SaltBootstrap(sc, allGatewayConfigs, targets);
Callable<Boolean> saltBootstrapRunner = runner(saltBootstrap, exitCriteria, exitModel);
Future<Boolean> saltBootstrapRunnerFuture = parallelOrchestratorComponentRunner.submit(saltBootstrapRunner);
saltBootstrapRunnerFuture.get();
} catch (Exception e) {
LOGGER.error("Error occurred during the salt bootstrap", e);
throw new CloudbreakOrchestratorFailedException(e);
}
LOGGER.info("SaltBootstrap finished");
}
use of com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap in project cloudbreak by hortonworks.
the class YarnContainerOrchestrator method runContainer.
@Override
public List<ContainerInfo> runContainer(ContainerConfig config, OrchestrationCredential cred, ContainerConstraint constraint, ExitCriteriaModel exitCriteriaModel) throws CloudbreakOrchestratorException {
// Create an application per component
List<ContainerInfo> containerInfos = new ArrayList<>();
for (int componentNumber = 1; componentNumber <= constraint.getInstances(); componentNumber++) {
try {
submitHandler.submitApplication(config, cred, constraint, componentNumber);
String applicationName = applicationUtils.getApplicationName(constraint, componentNumber);
OrchestratorBootstrap bootstrap = new YarnAppBootstrap(applicationName, cred.getApiEndpoint());
Callable<Boolean> runner = runner(bootstrap, getExitCriteria(), exitCriteriaModel);
Future<Boolean> appFuture = getParallelOrchestratorComponentRunner().submit(runner);
appFuture.get();
containerInfos.add(detailHandler.getContainerInfo(config, cred, constraint, componentNumber));
} catch (CloudbreakOrchestratorException | InterruptedException | ExecutionException e) {
throw new CloudbreakOrchestratorFailedException(e);
}
}
return containerInfos;
}
use of com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap 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.OrchestratorBootstrap in project cloudbreak by hortonworks.
the class SaltOrchestrator method runNewService.
private void runNewService(SaltConnector sc, BaseSaltJobRunner baseSaltJobRunner, ExitCriteriaModel exitCriteriaModel, int maxRetry, boolean retryOnFail) throws ExecutionException, InterruptedException {
OrchestratorBootstrap saltJobIdTracker = new SaltJobIdTracker(sc, baseSaltJobRunner, retryOnFail);
Callable<Boolean> saltJobRunBootstrapRunner = runner(saltJobIdTracker, exitCriteria, exitCriteriaModel, maxRetry);
Future<Boolean> saltJobRunBootstrapFuture = parallelOrchestratorComponentRunner.submit(saltJobRunBootstrapRunner);
saltJobRunBootstrapFuture.get();
}
Aggregations