Search in sources :

Example 46 with HostGroup

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

Example 47 with HostGroup

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);
    }
}
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 48 with HostGroup

use of com.sequenceiq.cloudbreak.domain.HostGroup 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 49 with HostGroup

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

the class RecipeEngine method uploadUpscaleRecipes.

public void uploadUpscaleRecipes(Stack stack, HostGroup hostGroup, Set<HostMetadata> metaDatas, Collection<HostGroup> hostGroups) throws CloudbreakException {
    Orchestrator orchestrator = stack.getOrchestrator();
    if (recipesSupportedOnOrchestrator(orchestrator)) {
        Set<HostGroup> hgs = Collections.singleton(hostGroup);
        addFsRecipes(stack, hgs);
        if (recipesFound(hgs)) {
            if (hostGroup.getConstraint().getInstanceGroup().getInstanceGroupType() == InstanceGroupType.GATEWAY) {
                orchestratorRecipeExecutor.uploadRecipes(stack, hostGroups);
            }
        }
    }
}
Also used : HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) Orchestrator(com.sequenceiq.cloudbreak.domain.Orchestrator)

Example 50 with HostGroup

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

the class HostGroupService method saveOrUpdateWithMetadata.

public Set<HostGroup> saveOrUpdateWithMetadata(Collection<HostGroup> hostGroups, Cluster cluster) {
    Set<HostGroup> result = new HashSet<>(hostGroups.size());
    for (HostGroup hg : hostGroups) {
        hg.setCluster(cluster);
        hg.setConstraint(constraintRepository.save(hg.getConstraint()));
        result.add(hostGroupRepository.save(hg));
    }
    return result;
}
Also used : HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) HashSet(java.util.HashSet)

Aggregations

HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)94 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)33 Test (org.junit.Test)33 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)31 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)29 HashSet (java.util.HashSet)22 JsonNode (com.fasterxml.jackson.databind.JsonNode)20 HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)20 List (java.util.List)20 HashMap (java.util.HashMap)19 Stack (com.sequenceiq.cloudbreak.domain.Stack)18 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)16 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)15 Map (java.util.Map)14 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)13 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)12 Constraint (com.sequenceiq.cloudbreak.domain.Constraint)11 ArrayList (java.util.ArrayList)11 Set (java.util.Set)11 Inject (javax.inject.Inject)11