use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method runAmbariServices.
@Transactional
public void runAmbariServices(Stack stack, Cluster cluster) throws CloudbreakException {
try {
Set<Node> nodes = collectNodes(stack);
HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
GatewayConfig primaryGatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
SaltConfig saltConfig = createSaltConfig(stack, cluster, primaryGatewayConfig, gatewayConfigs);
hostOrchestrator.runService(gatewayConfigs, nodes, saltConfig, clusterDeletionBasedModel(stack.getId(), cluster.getId()));
} catch (CloudbreakOrchestratorCancelledException e) {
throw new CancellationException(e.getMessage());
} catch (CloudbreakOrchestratorException | IOException e) {
throw new CloudbreakException(e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException in project cloudbreak by hortonworks.
the class ClusterContainerRunner method addClusterContainers.
public Map<String, List<Container>> addClusterContainers(Long stackId, String hostGroupName, Integer scalingAdjustment) throws CloudbreakException {
try {
Stack stack = stackRepository.findOneWithLists(stackId);
String cloudPlatform = StringUtils.isNotEmpty(stack.cloudPlatform()) ? stack.cloudPlatform() : NONE;
return addClusterContainers(stack, cloudPlatform, hostGroupName, scalingAdjustment);
} catch (CloudbreakOrchestratorCancelledException e) {
throw new CancellationException(e.getMessage());
} catch (CloudbreakOrchestratorException e) {
throw new CloudbreakException(e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException in project cloudbreak by hortonworks.
the class ClusterBootstrapper method bootstrapNewNodes.
public void bootstrapNewNodes(Long stackId, Set<String> upscaleCandidateAddresses, Collection<String> recoveryHostNames) throws CloudbreakException {
Stack stack = stackRepository.findOneWithLists(stackId);
Set<Node> nodes = new HashSet<>();
Set<Node> allNodes = new HashSet<>();
boolean recoveredNodes = Integer.valueOf(recoveryHostNames.size()).equals(upscaleCandidateAddresses.size());
Set<InstanceMetaData> metaDataSet = stack.getRunningInstanceMetaData().stream().filter(im -> im.getPrivateIp() != null && im.getPublicIpWrapper() != null).collect(Collectors.toSet());
String clusterDomain = metaDataSet.stream().filter(im -> isNoneBlank(im.getDiscoveryFQDN())).findAny().get().getDomain();
for (InstanceMetaData im : metaDataSet) {
Node node = createNode(stack.getCustomHostname(), im, clusterDomain, stack.isHostgroupNameAsHostname());
if (upscaleCandidateAddresses.contains(im.getPrivateIp())) {
// but only when we would have generated a hostname, otherwise use the cloud provider's default mechanism
if (recoveredNodes && isNoneBlank(node.getHostname())) {
Iterator<String> iterator = recoveryHostNames.iterator();
node.setHostname(iterator.next().split("\\.")[0]);
iterator.remove();
LOGGER.info("Set the hostname to {} for address: {}", node.getHostname(), im.getPrivateIp());
}
nodes.add(node);
}
allNodes.add(node);
}
try {
String stackOrchestratorType = stack.getOrchestrator().getType();
OrchestratorType orchestratorType = orchestratorTypeResolver.resolveType(stack.getOrchestrator().getType());
if (orchestratorType.hostOrchestrator()) {
List<GatewayConfig> allGatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
bootstrapNewNodesOnHost(stack, allGatewayConfigs, nodes, allNodes);
} else if (orchestratorType.containerOrchestrator()) {
LOGGER.info("Skipping bootstrap of the new machines because the stack's orchestrator type is '{}'.", stackOrchestratorType);
} else {
LOGGER.error("Orchestrator not found: {}", stackOrchestratorType);
throw new CloudbreakException("HostOrchestrator not found: " + stackOrchestratorType);
}
} catch (CloudbreakOrchestratorCancelledException e) {
throw new CancellationException(e.getMessage());
} catch (CloudbreakOrchestratorException e) {
throw new CloudbreakException(e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method addAmbariServices.
@Transactional
public Map<String, String> addAmbariServices(Long stackId, String hostGroupName, Integer scalingAdjustment) throws CloudbreakException {
Map<String, String> candidates;
try {
Stack stack = stackRepository.findOneWithLists(stackId);
Cluster cluster = stack.getCluster();
candidates = collectUpscaleCandidates(cluster.getId(), hostGroupName, scalingAdjustment);
Set<Node> allNodes = collectNodes(stack);
HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
SaltConfig saltConfig = createSaltConfig(stack, cluster, gatewayConfigService.getPrimaryGatewayConfig(stack), gatewayConfigs);
hostOrchestrator.runService(gatewayConfigs, allNodes, saltConfig, clusterDeletionBasedModel(stack.getId(), cluster.getId()));
} catch (CloudbreakOrchestratorCancelledException e) {
throw new CancellationException(e.getMessage());
} catch (CloudbreakOrchestratorException | IOException e) {
throw new CloudbreakException(e);
}
return candidates;
}
use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException 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