use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class HostGroupDecorator method getHostGroupByInstanceGroupName.
private HostGroup getHostGroupByInstanceGroupName(Constraint constraint, HostGroup subject, Cluster cluster, String instanceGroupName) {
HostGroup result = subject;
Set<HostGroup> hostGroups = hostGroupService.getByCluster(cluster.getId());
if (hostGroups.isEmpty()) {
Stack stack = cluster.getStack();
if (stack == null) {
String msg = String.format("There is no stack associated to cluster (id:'%s', name: '%s')!", cluster.getId(), cluster.getName());
throw new BadRequestException(msg);
} else {
subject.setConstraint(constraint);
}
} else {
result = getDetailsFromExistingHostGroup(constraint, subject, instanceGroupName, hostGroups);
}
return result;
}
use of com.sequenceiq.cloudbreak.domain.HostGroup 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.domain.HostGroup in project cloudbreak by hortonworks.
the class AmbariClusterSetupService method buildCluster.
@Override
public void buildCluster(Stack stack) {
Cluster cluster = stack.getCluster();
try {
clusterService.updateCreationDateOnCluster(cluster);
AmbariClient ambariClient = clientFactory.getAmbariClient(stack, stack.getCluster());
Set<HostGroup> hostGroups = hostGroupService.getByCluster(cluster.getId());
BlueprintPreparationObject blueprintPreparationObject = conversionService.convert(stack, BlueprintPreparationObject.class);
Map<String, List<Map<String, String>>> hostGroupMappings = hostGroupAssociationBuilder.buildHostGroupAssociations(hostGroups);
Set<HostMetadata> hostsInCluster = hostMetadataRepository.findHostsInCluster(cluster.getId());
recipeEngine.executePostAmbariStartRecipes(stack, hostGroups);
ambariRepositoryVersionService.setBaseRepoURL(stack.getName(), cluster.getId(), stack.getOrchestrator(), ambariClient);
String blueprintText = centralBlueprintUpdater.getBlueprintText(blueprintPreparationObject);
addBlueprint(stack.getId(), ambariClient, blueprintText, cluster.getTopologyValidation());
cluster.setExtendedBlueprintText(blueprintText);
clusterService.updateCluster(cluster);
PollingResult waitForHostsResult = ambariPollingServiceProvider.hostsPollingService(stack, ambariClient, hostsInCluster);
ambariClusterConnectorPollingResultChecker.checkPollingResult(waitForHostsResult, cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_HOST_JOIN_FAILED.code()));
ambariClusterTemplateService.addClusterTemplate(cluster, hostGroupMappings, ambariClient);
Pair<PollingResult, Exception> pollingResult = ambariOperationService.waitForOperationsToStart(stack, ambariClient, singletonMap("INSTALL_START", 1), START_OPERATION_STATE);
String message = pollingResult.getRight() == null ? cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_INSTALL_FAILED.code()) : pollingResult.getRight().getMessage();
ambariClusterConnectorPollingResultChecker.checkPollingResult(pollingResult.getLeft(), message);
Pair<PollingResult, Exception> pollingResultExceptionPair = ambariOperationService.waitForOperations(stack, ambariClient, new HashMap<String, Integer>() {
{
put("CLUSTER_INSTALL", 1);
}
}, INSTALL_AMBARI_PROGRESS_STATE);
ambariClusterConnectorPollingResultChecker.checkPollingResult(pollingResultExceptionPair.getLeft(), cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_INSTALL_FAILED.code()));
recipeEngine.executePostInstall(stack);
ambariSmartSenseCapturer.capture(0, ambariClient);
cluster = ambariViewProvider.provideViewInformation(ambariClient, cluster);
ambariClusterCreationSuccessHandler.handleClusterCreationSuccess(stack, cluster);
} catch (CancellationException cancellationException) {
throw cancellationException;
} catch (HttpResponseException hre) {
throw new AmbariOperationFailedException("Ambari could not create the cluster: " + AmbariClientExceptionUtil.getErrorMessage(hre), hre);
} catch (Exception e) {
LOGGER.error("Error while building the Ambari cluster. Message {}, throwable: {}", e.getMessage(), e);
throw new AmbariOperationFailedException(e.getMessage(), e);
}
}
use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class RecipeEngine method addHDFSRecipe.
private void addHDFSRecipe(Cluster cluster, String blueprintText, Iterable<HostGroup> hostGroups) {
try {
for (HostGroup hostGroup : hostGroups) {
if (isComponentPresent(blueprintText, "NAMENODE", hostGroup)) {
String script = FileReaderUtils.readFileFromClasspath("scripts/hdfs-home.sh").replaceAll("\\$USER", cluster.getUserName());
RecipeScript recipeScript = new RecipeScript(script, RecipeType.POST_CLUSTER_INSTALL);
Recipe recipe = recipeBuilder.buildRecipes("hdfs-home", Collections.singletonList(recipeScript)).get(0);
hostGroup.addRecipe(recipe);
break;
}
}
} catch (IOException e) {
LOGGER.warn("Cannot create HDFS home dir recipe", e);
}
}
use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class RecipeEngine method addContainerExecutorScripts.
private void addContainerExecutorScripts(Stack stack, Iterable<HostGroup> hostGroups) {
try {
Cluster cluster = stack.getCluster();
if (cluster != null && ExecutorType.CONTAINER.equals(cluster.getExecutorType())) {
for (HostGroup hostGroup : hostGroups) {
String script = FileReaderUtils.readFileFromClasspath("scripts/configure-container-executor.sh");
RecipeScript recipeScript = new RecipeScript(script, RecipeType.POST_CLUSTER_INSTALL);
Recipe recipe = recipeBuilder.buildRecipes("getConfigurationEntries-container-executor", Collections.singletonList(recipeScript)).get(0);
hostGroup.addRecipe(recipe);
}
}
} catch (IOException e) {
LOGGER.warn("Cannot getConfigurationEntries container executor", e);
}
}
Aggregations