use of com.sequenceiq.cloudbreak.service.CloudbreakException 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.service.CloudbreakException in project cloudbreak by hortonworks.
the class ClusterBootstrapper method bootstrapMachines.
public void bootstrapMachines(Long stackId) throws CloudbreakException {
Stack stack = stackRepository.findOneWithLists(stackId);
String stackOrchestratorType = stack.getOrchestrator().getType();
OrchestratorType orchestratorType = orchestratorTypeResolver.resolveType(stackOrchestratorType);
if (orchestratorType.hostOrchestrator()) {
bootstrapOnHost(stack);
} else if (orchestratorType.containerOrchestrator()) {
LOGGER.info("Skipping bootstrap of the machines because the stack's orchestrator type is '{}'.", stackOrchestratorType);
} else {
LOGGER.error("Orchestrator not found: {}", stackOrchestratorType);
throw new CloudbreakException("HostOrchestrator not found: " + stackOrchestratorType);
}
}
use of com.sequenceiq.cloudbreak.service.CloudbreakException in project cloudbreak by hortonworks.
the class StackService method validateOrchestrator.
public void validateOrchestrator(Orchestrator orchestrator) {
try {
ContainerOrchestrator containerOrchestrator = containerOrchestratorResolver.get(orchestrator.getType());
containerOrchestrator.validateApiEndpoint(new OrchestrationCredential(orchestrator.getApiEndpoint(), orchestrator.getAttributes().getMap()));
} catch (CloudbreakException e) {
throw new BadRequestException(String.format("Invalid orchestrator type: %s", e.getMessage()));
} catch (CloudbreakOrchestratorException e) {
throw new BadRequestException(String.format("Error occurred when trying to reach orchestrator API: %s", e.getMessage()));
}
}
use of com.sequenceiq.cloudbreak.service.CloudbreakException in project cloudbreak by hortonworks.
the class AmbariClusterModificationService method upscaleCluster.
@Override
public void upscaleCluster(Stack stack, HostGroup hostGroup, Collection<HostMetadata> hostMetadata) throws CloudbreakException {
AmbariClient ambariClient = clientFactory.getAmbariClient(stack, stack.getCluster());
List<String> upscaleHostNames = hostMetadata.stream().map(HostMetadata::getHostName).collect(Collectors.toList()).stream().filter(hostName -> !ambariClient.getClusterHosts().contains(hostName)).collect(Collectors.toList());
if (!upscaleHostNames.isEmpty()) {
recipeEngine.executePostAmbariStartRecipes(stack, Sets.newHashSet(hostGroup));
Pair<PollingResult, Exception> pollingResult = ambariOperationService.waitForOperations(stack, ambariClient, installServices(upscaleHostNames, stack, ambariClient, hostGroup.getName()), UPSCALE_AMBARI_PROGRESS_STATE);
String message = pollingResult.getRight() == null ? cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_UPSCALE_FAILED.code()) : pollingResult.getRight().getMessage();
ambariClusterConnectorPollingResultChecker.checkPollingResult(pollingResult.getLeft(), message);
}
}
use of com.sequenceiq.cloudbreak.service.CloudbreakException in project cloudbreak by hortonworks.
the class AmbariClusterSetupService method waitForServices.
@Override
public void waitForServices(Stack stack, int requestId) throws CloudbreakException {
AmbariClient ambariClient = clientFactory.getAmbariClient(stack, stack.getCluster());
LOGGER.info("Waiting for Hadoop services to start on stack");
PollingResult servicesStartResult = ambariOperationService.waitForOperations(stack, ambariClient, singletonMap("start services", requestId), START_AMBARI_PROGRESS_STATE).getLeft();
if (isExited(servicesStartResult)) {
throw new CancellationException("Cluster was terminated while waiting for Hadoop services to start");
} else if (isTimeout(servicesStartResult)) {
throw new CloudbreakException("Timeout while starting Ambari services.");
}
eventService.fireCloudbreakEvent(stack.getId(), UPDATE_IN_PROGRESS.name(), cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_SERVICES_STARTED.code()));
}
Aggregations