Search in sources :

Example 6 with HostGroup

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

the class InstanceGroupV4RequestToHostGroupConverter method convert.

public HostGroup convert(InstanceGroupV4Request source) {
    HostGroup hostGroup = new HostGroup();
    hostGroup.setName(source.getName().toLowerCase());
    hostGroup.setRecoveryMode(source.getRecoveryMode());
    Set<String> recipeNames = source.getRecipeNames();
    if (!CollectionUtils.isEmpty(recipeNames)) {
        CloudbreakUser cloudbreakUser = restRequestThreadLocalService.getCloudbreakUser();
        User user = userService.getOrCreate(cloudbreakUser);
        Workspace workspace = workspaceService.get(restRequestThreadLocalService.getRequestedWorkspaceId(), user);
        hostGroup.setRecipes(recipeService.getRecipesByNamesForWorkspace(workspace, recipeNames));
    }
    return hostGroup;
}
Also used : User(com.sequenceiq.cloudbreak.workspace.model.User) CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Example 7 with HostGroup

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

the class ClusterHostServiceRunner method collectUpscaleCandidates.

private Map<String, String> collectUpscaleCandidates(Long clusterId, Map<String, Integer> hostGroupWithAdjustment) {
    Map<String, String> hostNames = new HashMap<>();
    for (Map.Entry<String, Integer> entry : hostGroupWithAdjustment.entrySet()) {
        String hostGroupName = entry.getKey();
        Integer adjustment = entry.getValue();
        HostGroup hostGroup = hostGroupService.findHostGroupInClusterByName(clusterId, hostGroupName).orElseThrow(NotFoundException.notFound("hostgroup", hostGroupName));
        if (hostGroup.getInstanceGroup() != null) {
            Long instanceGroupId = hostGroup.getInstanceGroup().getId();
            instanceMetaDataService.findUnusedHostsInInstanceGroup(instanceGroupId).stream().filter(instanceMetaData -> instanceMetaData.getDiscoveryFQDN() != null).sorted(Comparator.comparing(InstanceMetaData::getStartDate)).limit(adjustment.longValue()).forEach(im -> hostNames.put(im.getDiscoveryFQDN(), im.getPrivateIp()));
        }
    }
    return hostNames;
}
Also used : CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) DatalakeService(com.sequenceiq.cloudbreak.service.sharedservice.DatalakeService) ComponentConfigProviderService(com.sequenceiq.cloudbreak.service.ComponentConfigProviderService) StringUtils(org.apache.commons.lang3.StringUtils) ThreadBasedUserCrnProvider(com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider) Map(java.util.Map) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) StringUtils.isEmpty(org.apache.commons.lang3.StringUtils.isEmpty) HostAttributeDecorator(com.sequenceiq.cloudbreak.core.bootstrap.service.host.decorator.HostAttributeDecorator) RecipeEngine(com.sequenceiq.cloudbreak.service.cluster.flow.recipe.RecipeEngine) CLOUDERAMANAGER_VERSION_7_2_1(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.CLOUDERAMANAGER_VERSION_7_2_1) CLOUDERAMANAGER_VERSION_7_2_0(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.CLOUDERAMANAGER_VERSION_7_2_0) Set(java.util.Set) Crn(com.sequenceiq.cloudbreak.auth.crn.Crn) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) Serializable(java.io.Serializable) TargetedUpscaleSupportService(com.sequenceiq.cloudbreak.service.stack.TargetedUpscaleSupportService) StringUtils.isNotBlank(org.apache.commons.lang3.StringUtils.isNotBlank) RdsConfigWithoutClusterService(com.sequenceiq.cloudbreak.service.rdsconfig.RdsConfigWithoutClusterService) StackUtil(com.sequenceiq.cloudbreak.util.StackUtil) MDCUtils(com.sequenceiq.cloudbreak.logger.MDCUtils) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) CollectionUtils(org.springframework.util.CollectionUtils) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) ExposedServices(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) Joiner(com.google.common.base.Joiner) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) CMLicenseParser(com.sequenceiq.cloudbreak.auth.CMLicenseParser) OrchestratorGrainRunnerParams(com.sequenceiq.cloudbreak.orchestrator.host.OrchestratorGrainRunnerParams) HostGroupService(com.sequenceiq.cloudbreak.service.hostgroup.HostGroupService) StringUtils.isNotEmpty(org.apache.commons.lang3.StringUtils.isNotEmpty) ArrayList(java.util.ArrayList) Value(org.springframework.beans.factory.annotation.Value) CsdParcelDecorator(com.sequenceiq.cloudbreak.core.bootstrap.service.host.decorator.CsdParcelDecorator) KerberosDetailService(com.sequenceiq.cloudbreak.template.kerberos.KerberosDetailService) Lists(com.google.common.collect.Lists) KerberosType(com.sequenceiq.cloudbreak.type.KerberosType) LdapView(com.sequenceiq.cloudbreak.dto.LdapView) CMRepositoryVersionUtil.isVersionNewerOrEqualThanLimited(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.isVersionNewerOrEqualThanLimited) ClusterComponentConfigProvider(com.sequenceiq.cloudbreak.cluster.service.ClusterComponentConfigProvider) NullUtil.throwIfNull(com.sequenceiq.cloudbreak.util.NullUtil.throwIfNull) DatabaseType(com.sequenceiq.cloudbreak.api.endpoint.v4.database.base.DatabaseType) DnsResolverType(com.sequenceiq.cloudbreak.domain.stack.DnsResolverType) ExitCriteriaModel(com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteriaModel) IOException(java.io.IOException) PostgresConfigService(com.sequenceiq.cloudbreak.core.bootstrap.service.container.postgres.PostgresConfigService) ServiceLocationMap(com.sequenceiq.cloudbreak.cluster.model.ServiceLocationMap) ClusterDeletionBasedExitCriteriaModel(com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel) GrpcUmsClient(com.sequenceiq.cloudbreak.auth.altus.GrpcUmsClient) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) GrainProperties(com.sequenceiq.cloudbreak.orchestrator.model.GrainProperties) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) ComponentLocatorService(com.sequenceiq.cloudbreak.service.blueprint.ComponentLocatorService) InetAddresses(com.google.common.net.InetAddresses) NodesUnreachableException(com.sequenceiq.cloudbreak.util.NodesUnreachableException) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) GrainOperation(com.sequenceiq.cloudbreak.orchestrator.host.GrainOperation) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) CloudbreakOrchestratorCancelledException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException) LoggerFactory(org.slf4j.LoggerFactory) LoadBalancerSANProvider(com.sequenceiq.cloudbreak.san.LoadBalancerSANProvider) InstanceGroupService(com.sequenceiq.cloudbreak.service.stack.InstanceGroupService) ClusterPreCreationApi(com.sequenceiq.cloudbreak.cluster.api.ClusterPreCreationApi) KerberosConfigService(com.sequenceiq.cloudbreak.kerberos.KerberosConfigService) ExposedServiceCollector(com.sequenceiq.cloudbreak.api.service.ExposedServiceCollector) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) CLOUDERAMANAGER_VERSION_7_0_2(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.CLOUDERAMANAGER_VERSION_7_0_2) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) DataBusCredential(com.sequenceiq.common.api.telemetry.model.DataBusCredential) StackTags(com.sequenceiq.cloudbreak.cloud.model.StackTags) ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService) Collectors(java.util.stream.Collectors) TemporaryStorage(com.sequenceiq.cloudbreak.common.type.TemporaryStorage) RegionAwareInternalCrnGeneratorFactory(com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGeneratorFactory) Json(com.sequenceiq.cloudbreak.common.json.Json) IdBrokerService(com.sequenceiq.cloudbreak.service.idbroker.IdBrokerService) GatewayConfigService(com.sequenceiq.cloudbreak.service.GatewayConfigService) ProxyConfigProvider(com.sequenceiq.cloudbreak.service.proxy.ProxyConfigProvider) List(java.util.List) VirtualGroupService(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupService) RdsView(com.sequenceiq.cloudbreak.template.views.RdsView) Optional(java.util.Optional) SSOType(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.SSOType) Pattern(java.util.regex.Pattern) KerberosConfig(com.sequenceiq.cloudbreak.dto.KerberosConfig) Account(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Account) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) LoadBalancerConfigService(com.sequenceiq.cloudbreak.service.LoadBalancerConfigService) CMRepositoryVersionUtil(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil) IdBroker(com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker) LdapConfigService(com.sequenceiq.cloudbreak.ldap.LdapConfigService) HashMap(java.util.HashMap) FreeIpaConfigProvider(com.sequenceiq.cloudbreak.service.freeipa.FreeIpaConfigProvider) HashSet(java.util.HashSet) Inject(javax.inject.Inject) InstanceMetaDataService(com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService) Collections.singletonMap(java.util.Collections.singletonMap) RdsConfigWithoutCluster(com.sequenceiq.cloudbreak.domain.view.RdsConfigWithoutCluster) Nonnull(javax.annotation.Nonnull) TelemetryDecorator(com.sequenceiq.cloudbreak.core.bootstrap.service.host.decorator.TelemetryDecorator) ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel(com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel) Logger(org.slf4j.Logger) VirtualGroupRequest(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest) NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult) EnvironmentConfigProvider(com.sequenceiq.cloudbreak.service.environment.EnvironmentConfigProvider) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) MountDisks(com.sequenceiq.cloudbreak.service.stack.flow.MountDisks) Component(org.springframework.stereotype.Component) UmsVirtualGroupRight(com.sequenceiq.cloudbreak.auth.altus.UmsVirtualGroupRight) ClusterApiConnectors(com.sequenceiq.cloudbreak.service.cluster.ClusterApiConnectors) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Comparator(java.util.Comparator) Collections(java.util.Collections) HashMap(java.util.HashMap) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) Map(java.util.Map) ServiceLocationMap(com.sequenceiq.cloudbreak.cluster.model.ServiceLocationMap) HashMap(java.util.HashMap) Collections.singletonMap(java.util.Collections.singletonMap)

Example 8 with HostGroup

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

the class ClusterBuilderService method loadInstanceMetadataForHostGroups.

private Map<HostGroup, List<InstanceMetaData>> loadInstanceMetadataForHostGroups(Iterable<HostGroup> hostGroups) {
    Map<HostGroup, List<InstanceMetaData>> instanceMetaDataByHostGroup = new HashMap<>();
    for (HostGroup hostGroup : hostGroups) {
        Long instanceGroupId = hostGroup.getInstanceGroup().getId();
        List<InstanceMetaData> metas = instanceMetaDataService.findAliveInstancesInInstanceGroup(instanceGroupId);
        instanceMetaDataByHostGroup.put(hostGroup, metas);
    }
    return instanceMetaDataByHostGroup;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) HashMap(java.util.HashMap) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) List(java.util.List)

Example 9 with HostGroup

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

the class ClusterBuilderService method prepareExtendedTemplate.

public void prepareExtendedTemplate(Long stackId) {
    Stack stack = stackService.getByIdWithListsInTransaction(stackId);
    Cluster cluster = stack.getCluster();
    Set<HostGroup> hostGroups = hostGroupService.getByClusterWithRecipes(cluster.getId());
    setInitialBlueprintText(cluster);
    String template = getClusterSetupService(stack).prepareTemplate(loadInstanceMetadataForHostGroups(hostGroups), stackToTemplatePreparationObjectConverter.convert(stack), getSdxContextOptional(stack.getDatalakeCrn()).orElse(null), stack.getDatalakeCrn(), kerberosConfigService.get(stack.getEnvironmentCrn(), stack.getName()).orElse(null));
    validateExtendedBlueprintTextDoesNotContainUnresolvedHandlebarParams(template);
    cluster.setExtendedBlueprintText(template);
    clusterService.save(cluster);
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 10 with HostGroup

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

the class CollectDownscaleCandidatesHandler method collectCandidates.

private Set<Long> collectCandidates(CollectDownscaleCandidatesRequest request, Stack stack) throws CloudbreakException {
    Set<Long> privateIds = new HashSet<>();
    LOGGER.debug("Collecting candidates for downscale based on [{}] and stack CRN [{}].", request, stack.getResourceCrn());
    for (Map.Entry<String, Integer> entry : request.getHostGroupWithAdjustment().entrySet()) {
        String hostGroupName = entry.getKey();
        HostGroup hostGroup = hostGroupService.getByClusterIdAndName(stack.getCluster().getId(), hostGroupName).orElseThrow(NotFoundException.notFound("hostgroup", hostGroupName));
        LOGGER.debug("Host group has been found for cluster! It's name: {}", hostGroup.getName());
        List<InstanceMetaData> metaDataForInstanceGroup = instanceMetaDataService.findAliveInstancesInInstanceGroup(hostGroup.getInstanceGroup().getId());
        Set<InstanceMetaData> collectedCandidates = clusterApiConnectors.getConnector(stack).clusterDecomissionService().collectDownscaleCandidates(hostGroup, entry.getValue(), new HashSet<>(metaDataForInstanceGroup));
        String collectedHostsAsString = collectedCandidates.stream().map(instanceMetaData -> instanceMetaData.getDiscoveryFQDN() != null ? "FQDN: " + instanceMetaData.getDiscoveryFQDN() : "Private id: " + instanceMetaData.getPrivateId()).collect(Collectors.joining(", "));
        LOGGER.debug("The following hosts has been collected as candidates for downscale: [{}]", collectedHostsAsString);
        flowMessageService.fireEventAndLog(stack.getId(), AVAILABLE.name(), STACK_SELECT_FOR_DOWNSCALE, collectedHostsAsString);
        privateIds.addAll(collectedCandidates.stream().map(InstanceMetaData::getPrivateId).collect(Collectors.toSet()));
    }
    return privateIds;
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) STACK_SELECT_FOR_DOWNSCALE(com.sequenceiq.cloudbreak.event.ResourceEvent.STACK_SELECT_FOR_DOWNSCALE) Resource(com.sequenceiq.cloudbreak.domain.Resource) AVAILABLE(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.AVAILABLE) LoggerFactory(org.slf4j.LoggerFactory) EventSelectorUtil(com.sequenceiq.flow.event.EventSelectorUtil) HostGroupService(com.sequenceiq.cloudbreak.service.hostgroup.HostGroupService) CollectionUtils.isEmpty(org.apache.commons.collections4.CollectionUtils.isEmpty) CollectionUtils(org.apache.commons.collections4.CollectionUtils) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ResourceService(com.sequenceiq.cloudbreak.service.resource.ResourceService) Event(reactor.bus.Event) CloudbreakFlowMessageService(com.sequenceiq.cloudbreak.core.flow2.stack.CloudbreakFlowMessageService) Map(java.util.Map) InstanceMetaDataService(com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService) EventHandler(com.sequenceiq.flow.reactor.api.handler.EventHandler) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) Logger(org.slf4j.Logger) Collection(java.util.Collection) Set(java.util.Set) EventBus(reactor.bus.EventBus) Collectors(java.util.stream.Collectors) List(java.util.List) Component(org.springframework.stereotype.Component) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) CollectDownscaleCandidatesRequest(com.sequenceiq.cloudbreak.reactor.api.event.resource.CollectDownscaleCandidatesRequest) ClusterApiConnectors(com.sequenceiq.cloudbreak.service.cluster.ClusterApiConnectors) CollectDownscaleCandidatesResult(com.sequenceiq.cloudbreak.reactor.api.event.resource.CollectDownscaleCandidatesResult) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)132 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)66 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)60 HashSet (java.util.HashSet)55 Test (org.junit.jupiter.api.Test)52 List (java.util.List)50 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)43 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)37 Map (java.util.Map)37 Set (java.util.Set)37 Collectors (java.util.stream.Collectors)35 HostGroupService (com.sequenceiq.cloudbreak.service.hostgroup.HostGroupService)25 Optional (java.util.Optional)25 ArrayList (java.util.ArrayList)24 StackService (com.sequenceiq.cloudbreak.service.stack.StackService)22 InstanceStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus)21 ClusterApiConnectors (com.sequenceiq.cloudbreak.service.cluster.ClusterApiConnectors)21 HashMap (java.util.HashMap)19 Logger (org.slf4j.Logger)19 LoggerFactory (org.slf4j.LoggerFactory)19