Search in sources :

Example 36 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 37 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 38 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)

Example 39 with HostGroup

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

the class AmbariClusterUpscaleService method uploadRecipesOnNewHosts.

public void uploadRecipesOnNewHosts(Long stackId, String hostGroupName) throws CloudbreakException {
    Stack stack = stackService.getByIdWithLists(stackId);
    LOGGER.info("Start executing pre recipes");
    HostGroup hostGroup = hostGroupService.getByClusterIdAndName(stack.getCluster().getId(), hostGroupName);
    Set<HostGroup> hostGroups = hostGroupService.getByCluster(stack.getCluster().getId());
    Set<HostMetadata> hostMetadata = hostGroupService.findEmptyHostMetadataInHostGroup(hostGroup.getId());
    recipeEngine.uploadUpscaleRecipes(stack, hostGroup, hostMetadata, hostGroups);
}
Also used : HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) Stack(com.sequenceiq.cloudbreak.domain.Stack) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata)

Example 40 with HostGroup

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

the class ClusterRepairFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public Queue<Selectable> createFlowTriggerEventQueue(ClusterRepairTriggerEvent event) {
    StackView stackView = stackService.getByIdView(event.getStackId());
    Queue<Selectable> flowChainTriggers = new ConcurrentLinkedDeque<>();
    Map<String, List<String>> failedNodesMap = event.getFailedNodesMap();
    for (Entry<String, List<String>> failedNodes : failedNodesMap.entrySet()) {
        String hostGroupName = failedNodes.getKey();
        List<String> hostNames = failedNodes.getValue();
        HostGroup hostGroup = hostGroupService.getByClusterIdAndName(stackView.getClusterView().getId(), hostGroupName);
        InstanceGroup instanceGroup = hostGroup.getConstraint().getInstanceGroup();
        if (InstanceGroupType.GATEWAY.equals(instanceGroup.getInstanceGroupType())) {
            List<InstanceMetaData> primary = instanceMetadataRepository.findAllByInstanceGroup(instanceGroup).stream().filter(imd -> hostNames.contains(imd.getDiscoveryFQDN()) && imd.getInstanceMetadataType() == InstanceMetadataType.GATEWAY_PRIMARY).collect(Collectors.toList());
            if (!primary.isEmpty()) {
                flowChainTriggers.add(new ChangePrimaryGatewayTriggerEvent(ChangePrimaryGatewayEvent.CHANGE_PRIMARY_GATEWAY_TRIGGER_EVENT.event(), event.getStackId(), event.accepted()));
            }
        }
        flowChainTriggers.add(new ClusterAndStackDownscaleTriggerEvent(FlowChainTriggers.FULL_DOWNSCALE_TRIGGER_EVENT, event.getStackId(), hostGroupName, new HashSet<>(hostNames), ScalingType.DOWNSCALE_TOGETHER, event.accepted()));
        if (!event.isRemoveOnly()) {
            flowChainTriggers.add(new StackAndClusterUpscaleTriggerEvent(FlowChainTriggers.FULL_UPSCALE_TRIGGER_EVENT, event.getStackId(), hostGroupName, hostNames.size(), ScalingType.UPSCALE_TOGETHER, Sets.newHashSet(hostNames)));
            // we need to update all ephemeral clusters that are connected to a datalake
            if (InstanceGroupType.GATEWAY.equals(instanceGroup.getInstanceGroupType()) && !stackService.findClustersConnectedToDatalake(event.getStackId()).isEmpty()) {
                flowChainTriggers.add(new EphemeralClustersUpgradeTriggerEvent(FlowChainTriggers.EPHEMERAL_CLUSTERS_UPDATE_TRIGGER_EVENT, event.getStackId(), event.accepted()));
            }
        }
    }
    return flowChainTriggers;
}
Also used : StackView(com.sequenceiq.cloudbreak.domain.view.StackView) StackAndClusterUpscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackAndClusterUpscaleTriggerEvent) InstanceMetaDataRepository(com.sequenceiq.cloudbreak.repository.InstanceMetaDataRepository) LoggerFactory(org.slf4j.LoggerFactory) HostGroupService(com.sequenceiq.cloudbreak.service.hostgroup.HostGroupService) ClusterRepairTriggerEvent(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterRepairTriggerEvent) InstanceGroupType(com.sequenceiq.cloudbreak.api.model.InstanceGroupType) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Map(java.util.Map) ChangePrimaryGatewayTriggerEvent(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ChangePrimaryGatewayTriggerEvent) ChangePrimaryGatewayEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.repair.ChangePrimaryGatewayEvent) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) Logger(org.slf4j.Logger) InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) ClusterAndStackDownscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.ClusterAndStackDownscaleTriggerEvent) Collectors(java.util.stream.Collectors) ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque) Sets(com.google.common.collect.Sets) InstanceMetadataType(com.sequenceiq.cloudbreak.api.model.InstanceMetadataType) List(java.util.List) Component(org.springframework.stereotype.Component) ScalingType(com.sequenceiq.cloudbreak.common.type.ScalingType) Entry(java.util.Map.Entry) EphemeralClustersUpgradeTriggerEvent(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.EphemeralClustersUpgradeTriggerEvent) Queue(java.util.Queue) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) ClusterAndStackDownscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.ClusterAndStackDownscaleTriggerEvent) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) EphemeralClustersUpgradeTriggerEvent(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.EphemeralClustersUpgradeTriggerEvent) ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) ChangePrimaryGatewayTriggerEvent(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ChangePrimaryGatewayTriggerEvent) StackAndClusterUpscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackAndClusterUpscaleTriggerEvent) Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) List(java.util.List) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) 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