Search in sources :

Example 26 with HostGroup

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

the class ClusterUpscaleFlowService method updateMetadata.

private int updateMetadata(StackView stackView, String hostGroupName) {
    LOGGER.info("Start update metadata");
    HostGroup hostGroup = hostGroupService.getByClusterIdAndName(stackView.getClusterView().getId(), hostGroupName);
    Set<HostMetadata> hostMetadata = hostGroupService.findEmptyHostMetadataInHostGroup(hostGroup.getId());
    updateFailedHostMetaData(hostMetadata);
    int failedHosts = 0;
    for (HostMetadata hostMeta : hostMetadata) {
        if (hostGroup.getConstraint().getInstanceGroup() != null) {
            stackService.updateMetaDataStatus(stackView.getId(), hostMeta.getHostName(), InstanceStatus.REGISTERED);
        }
        hostGroupService.updateHostMetaDataStatus(hostMeta.getId(), HostMetadataState.HEALTHY);
        if (hostMeta.getHostMetadataState() == HostMetadataState.UNHEALTHY) {
            failedHosts++;
        }
    }
    return failedHosts;
}
Also used : HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata)

Example 27 with HostGroup

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

the class StackRepairServiceTest method setupHostMetadata.

private void setupHostMetadata(Long clusterId, String privateIp, String hostGroupName) {
    HostMetadata hmd1 = mock(HostMetadata.class);
    HostGroup hg1 = mock(HostGroup.class);
    when(hg1.getName()).thenReturn(hostGroupName);
    when(hmd1.getHostGroup()).thenReturn(hg1);
    when(hostMetadataRepository.findHostInClusterByName(clusterId, privateIp)).thenReturn(hmd1);
}
Also used : HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata)

Example 28 with HostGroup

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

the class StackToStackV2RequestConverter method collectInformationsFromActualHostgroup.

private InstanceGroupV2Request collectInformationsFromActualHostgroup(Stack source, InstanceGroup instanceGroup, InstanceGroupV2Request instanceGroupV2Request) {
    HostGroup actualHostgroup = null;
    for (HostGroup hostGroup : source.getCluster().getHostGroups()) {
        if (hostGroup.getName().equals(instanceGroup.getGroupName())) {
            actualHostgroup = hostGroup;
        }
    }
    if (actualHostgroup != null) {
        instanceGroupV2Request.setRecoveryMode(actualHostgroup.getRecoveryMode());
        instanceGroupV2Request.setRecipeNames(new HashSet<>());
        for (Recipe recipe : actualHostgroup.getRecipes()) {
            instanceGroupV2Request.getRecipeNames().add(recipe.getName());
        }
    }
    return instanceGroupV2Request;
}
Also used : Recipe(com.sequenceiq.cloudbreak.domain.Recipe) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup)

Example 29 with HostGroup

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

the class StackValidationRequestToStackValidationConverter method convertHostGroupsFromJson.

private Set<HostGroup> convertHostGroupsFromJson(Collection<InstanceGroup> instanceGroups, Iterable<HostGroupRequest> hostGroupsJsons) {
    Set<HostGroup> hostGroups = new HashSet<>();
    for (HostGroupRequest json : hostGroupsJsons) {
        HostGroup hostGroup = new HostGroup();
        hostGroup.setName(json.getName());
        Constraint constraint = getConversionService().convert(json.getConstraint(), Constraint.class);
        String instanceGroupName = json.getConstraint().getInstanceGroupName();
        if (instanceGroupName != null) {
            InstanceGroup instanceGroup = instanceGroups.stream().filter(instanceGroup1 -> instanceGroup1.getGroupName().equals(instanceGroupName)).findFirst().get();
            if (instanceGroup == null) {
                throw new BadRequestException(String.format("Cannot find instance group named '%s' in instance group list", instanceGroupName));
            }
            constraint.setInstanceGroup(instanceGroup);
        }
        hostGroup.setConstraint(constraint);
        hostGroups.add(hostGroup);
    }
    return hostGroups;
}
Also used : Constraint(com.sequenceiq.cloudbreak.domain.Constraint) HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) HashSet(java.util.HashSet) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Example 30 with HostGroup

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

the class HostGroupDecorator method getDetailsFromExistingHostGroup.

private HostGroup getDetailsFromExistingHostGroup(Constraint constraint, HostGroup subject, String instanceGroupName, Collection<HostGroup> hostGroups) {
    Optional<HostGroup> hostGroupOptional = hostGroups.stream().filter(input -> input.getConstraint().getInstanceGroup().getGroupName().equals(instanceGroupName)).findFirst();
    if (hostGroupOptional.isPresent()) {
        HostGroup hostGroup = hostGroupOptional.get();
        Integer instanceGroupNodeCount = hostGroup.getConstraint().getInstanceGroup().getNodeCount();
        if (constraint.getHostCount() > instanceGroupNodeCount) {
            throw new BadRequestException(String.format("The 'hostCount' of host group '%s' constraint could not be more than '%s'!", subject.getName(), instanceGroupNodeCount));
        }
        hostGroup.getConstraint().setHostCount(constraint.getHostCount());
        hostGroup.setName(subject.getName());
        return hostGroup;
    } else {
        throw new BadRequestException(String.format("Invalid 'instanceGroupName'! Could not find instance group with name: '%s'", instanceGroupName));
    }
}
Also used : RecipeService(com.sequenceiq.cloudbreak.service.recipe.RecipeService) IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) LoggerFactory(org.slf4j.LoggerFactory) RecipeRequest(com.sequenceiq.cloudbreak.api.model.RecipeRequest) HostGroupService(com.sequenceiq.cloudbreak.service.hostgroup.HostGroupService) ClusterService(com.sequenceiq.cloudbreak.service.cluster.ClusterService) ConstraintTemplateRepository(com.sequenceiq.cloudbreak.repository.ConstraintTemplateRepository) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) Inject(javax.inject.Inject) ConstraintTemplate(com.sequenceiq.cloudbreak.domain.ConstraintTemplate) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) ConstraintJson(com.sequenceiq.cloudbreak.api.model.ConstraintJson) Stack(com.sequenceiq.cloudbreak.domain.Stack) ConversionService(org.springframework.core.convert.ConversionService) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) Constraint(com.sequenceiq.cloudbreak.domain.Constraint) Logger(org.slf4j.Logger) Collection(java.util.Collection) InstanceGroupRepository(com.sequenceiq.cloudbreak.repository.InstanceGroupRepository) Set(java.util.Set) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) Recipe(com.sequenceiq.cloudbreak.domain.Recipe) Component(org.springframework.stereotype.Component) HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) ConstraintRepository(com.sequenceiq.cloudbreak.repository.ConstraintRepository) StringUtils.isEmpty(org.springframework.util.StringUtils.isEmpty) Optional(java.util.Optional) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException)

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