Search in sources :

Example 41 with Cluster

use of com.sequenceiq.cloudbreak.domain.Cluster 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);
    }
}
Also used : RecipeScript(com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript) Recipe(com.sequenceiq.cloudbreak.domain.Recipe) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) IOException(java.io.IOException)

Example 42 with Cluster

use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.

the class RecipeEngine method addSmartSenseRecipe.

private void addSmartSenseRecipe(Stack stack, Iterable<HostGroup> hostGroups) {
    try {
        Cluster cluster = stack.getCluster();
        String blueprintText = cluster.getBlueprint().getBlueprintText();
        if (smartsenseConfigurationLocator.smartsenseConfigurable(smartSenseSubscriptionService.getDefault())) {
            for (HostGroup hostGroup : hostGroups) {
                if (isComponentPresent(blueprintText, "HST_AGENT", hostGroup)) {
                    String script = FileReaderUtils.readFileFromClasspath("scripts/smartsense-capture-schedule.sh");
                    RecipeScript recipeScript = new RecipeScript(script, RecipeType.POST_CLUSTER_INSTALL);
                    Recipe recipe = recipeBuilder.buildRecipes("smartsense-capture-schedule", Collections.singletonList(recipeScript)).get(0);
                    hostGroup.addRecipe(recipe);
                    break;
                }
            }
        }
    } catch (IOException e) {
        LOGGER.warn("Cannot create SmartSense caputre schedule setter recipe", e);
    }
}
Also used : RecipeScript(com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript) Recipe(com.sequenceiq.cloudbreak.domain.Recipe) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) IOException(java.io.IOException)

Example 43 with Cluster

use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.

the class RecipeEngine method addFsRecipes.

private void addFsRecipes(Stack stack, Iterable<HostGroup> hostGroups) throws CloudbreakException {
    String orchestrator = stack.getOrchestrator().getType();
    if (SALT.equals(orchestrator)) {
        Cluster cluster = stack.getCluster();
        String blueprintText = cluster.getBlueprint().getBlueprintText();
        FileSystem fs = cluster.getFileSystem();
        if (fs != null) {
            try {
                addFsRecipesToHostGroups(stack.getCredential(), hostGroups, blueprintText, fs);
            } catch (IOException e) {
                throw new CloudbreakException("can not add FS recipes to host groups", e);
            }
        }
        addHDFSRecipe(cluster, blueprintText, hostGroups);
    }
}
Also used : FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) IOException(java.io.IOException)

Example 44 with Cluster

use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.

the class ConstraintTemplateService method delete.

private void delete(ConstraintTemplate constraintTemplate) {
    authorizationService.hasWritePermission(constraintTemplate);
    LOGGER.debug("Deleting constraint template. {} - {}", new Object[] { constraintTemplate.getId(), constraintTemplate.getName() });
    List<Cluster> clusters = clusterRepository.findAllClustersForConstraintTemplate(constraintTemplate.getId());
    if (clusters.isEmpty()) {
        if (ResourceStatus.USER_MANAGED.equals(constraintTemplate.getStatus())) {
            constraintTemplateRepository.delete(constraintTemplate);
        } else {
            constraintTemplate.setName(NameUtil.postfixWithTimestamp(constraintTemplate.getName()));
            constraintTemplate.setStatus(ResourceStatus.DEFAULT_DELETED);
            constraintTemplateRepository.save(constraintTemplate);
        }
    } else if (isRunningClusterReferToTemplate(clusters)) {
        throw new BadRequestException(String.format("There are stacks associated with template '%s'. Please remove these before deleting the template.", constraintTemplate.getName()));
    } else {
        constraintTemplate.setName(NameUtil.postfixWithTimestamp(constraintTemplate.getName()));
        constraintTemplate.setDeleted(true);
        if (ResourceStatus.DEFAULT.equals(constraintTemplate.getStatus())) {
            constraintTemplate.setStatus(ResourceStatus.DEFAULT_DELETED);
        }
        constraintTemplateRepository.save(constraintTemplate);
    }
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.Cluster) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException)

Example 45 with Cluster

use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.

the class ClusterCreationService method clusterInstallationFinished.

public void clusterInstallationFinished(StackView stackView) {
    String ambariIp = stackUtil.extractAmbariIp(stackView);
    clusterService.updateClusterStatusByStackId(stackView.getId(), AVAILABLE);
    stackUpdater.updateStackStatus(stackView.getId(), DetailedStackStatus.AVAILABLE, "Cluster creation finished.");
    flowMessageService.fireEventAndLog(stackView.getId(), Msg.AMBARI_CLUSTER_BUILT, AVAILABLE.name(), ambariIp);
    Cluster cluster = clusterService.getById(stackView.getClusterView().getId());
    clusterService.cleanupKerberosCredential(cluster);
    if (cluster.getEmailNeeded()) {
        emailSenderService.sendProvisioningSuccessEmail(cluster.getOwner(), stackView.getClusterView().getEmailTo(), ambariIp, cluster.getName(), cluster.getGateway().getEnableGateway());
        flowMessageService.fireEventAndLog(stackView.getId(), Msg.AMBARI_CLUSTER_NOTIFICATION_EMAIL, AVAILABLE.name());
    }
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.Cluster)

Aggregations

Cluster (com.sequenceiq.cloudbreak.domain.Cluster)144 Stack (com.sequenceiq.cloudbreak.domain.Stack)68 Test (org.junit.Test)64 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)31 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)26 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)22 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)22 HashMap (java.util.HashMap)22 HashSet (java.util.HashSet)15 List (java.util.List)15 ArrayList (java.util.ArrayList)13 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)12 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)12 BlueprintPreparationObject (com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject)11 Matchers.anyString (org.mockito.Matchers.anyString)11 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)10 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)10 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)9 Json (com.sequenceiq.cloudbreak.domain.json.Json)9 PollingResult (com.sequenceiq.cloudbreak.service.PollingResult)9