Search in sources :

Example 1 with ServiceComponent

use of com.sequenceiq.cloudbreak.template.model.ServiceComponent in project cloudbreak by hortonworks.

the class RangerRazDatahubConfigProvider method getAdditionalServices.

@Override
public Map<String, ApiClusterTemplateService> getAdditionalServices(CmTemplateProcessor cmTemplateProcessor, TemplatePreparationObject source) {
    if (isConfigurationNeeded(cmTemplateProcessor, source)) {
        ApiClusterTemplateService coreSettings = createTemplate();
        Set<HostgroupView> hostgroupViews = source.getHostgroupViews();
        Map<String, Set<ServiceComponent>> serviceComponentsByHostGroup = cmTemplateProcessor.getServiceComponentsByHostGroup();
        Set<String> zkServerGroups = collectZKServers(serviceComponentsByHostGroup);
        boolean weHaveMoreThan2ZKServer = getZKHostNumbers(hostgroupViews, zkServerGroups);
        return hostgroupViews.stream().filter(hg -> isProperHostGroupForRaz(hg, zkServerGroups, weHaveMoreThan2ZKServer)).collect(Collectors.toMap(HostgroupView::getName, v -> coreSettings));
    }
    return Map.of();
}
Also used : CMRepositoryVersionUtil(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil) Set(java.util.Set) Collectors(java.util.stream.Collectors) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) ServiceComponent(com.sequenceiq.cloudbreak.template.model.ServiceComponent) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) Component(org.springframework.stereotype.Component) Map(java.util.Map) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) Set(java.util.Set) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView)

Example 2 with ServiceComponent

use of com.sequenceiq.cloudbreak.template.model.ServiceComponent in project cloudbreak by hortonworks.

the class CmTemplateProcessor method collectServiceComponentsByHostGroup.

private Map<String, Set<ServiceComponent>> collectServiceComponentsByHostGroup(Map<String, ServiceComponent> rolesByRoleRef) {
    Map<String, Set<ServiceComponent>> result = new HashMap<>();
    List<ApiClusterTemplateHostTemplate> hostTemplates = Optional.ofNullable(cmTemplate.getHostTemplates()).orElse(List.of());
    for (ApiClusterTemplateHostTemplate apiClusterTemplateHostTemplate : hostTemplates) {
        Set<ServiceComponent> components = apiClusterTemplateHostTemplate.getRoleConfigGroupsRefNames().stream().map(rolesByRoleRef::get).filter(Objects::nonNull).collect(toSet());
        result.put(apiClusterTemplateHostTemplate.getRefName(), components);
    }
    return result;
}
Also used : Collectors.toSet(java.util.stream.Collectors.toSet) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ServiceComponent(com.sequenceiq.cloudbreak.template.model.ServiceComponent) ApiClusterTemplateHostTemplate(com.cloudera.api.swagger.model.ApiClusterTemplateHostTemplate)

Example 3 with ServiceComponent

use of com.sequenceiq.cloudbreak.template.model.ServiceComponent in project cloudbreak by hortonworks.

the class CmHostGroupRoleConfigProviderProcessor method groupByHostGroupName.

private void groupByHostGroupName(TemplatePreparationObject source, Map<String, Map<String, List<ApiClusterTemplateConfig>>> configsByRoleConfigGroup, Map<String, ServiceComponent> serviceComponents, String hostGroupName, List<String> roleConfigGroups, HostgroupView hostgroupView) {
    for (String roleConfigGroup : roleConfigGroups) {
        for (CmHostGroupRoleConfigProvider provider : providers) {
            ServiceComponent serviceComponent = serviceComponents.get(roleConfigGroup);
            if (isServiceComponentEquals(provider, serviceComponent)) {
                Map<String, List<ApiClusterTemplateConfig>> configs = configsByRoleConfigGroup.computeIfAbsent(roleConfigGroup, __ -> new HashMap<>());
                configs.computeIfAbsent(hostGroupName, __ -> new ArrayList<>()).addAll(provider.getRoleConfigs(serviceComponent.getComponent(), hostgroupView, source));
            }
        }
    }
}
Also used : Logger(org.slf4j.Logger) Optional.ofNullable(java.util.Optional.ofNullable) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) ApiClusterTemplateHostTemplate(com.cloudera.api.swagger.model.ApiClusterTemplateHostTemplate) Function(java.util.function.Function) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ArrayList(java.util.ArrayList) Objects(java.util.Objects) Inject(javax.inject.Inject) ServiceComponent(com.sequenceiq.cloudbreak.template.model.ServiceComponent) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) List(java.util.List) Component(org.springframework.stereotype.Component) Collectors.toMap(java.util.stream.Collectors.toMap) Pair(org.apache.commons.lang3.tuple.Pair) Map(java.util.Map) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) ApiClusterTemplateInstantiator(com.cloudera.api.swagger.model.ApiClusterTemplateInstantiator) Optional(java.util.Optional) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) VisibleForTesting(com.google.common.annotations.VisibleForTesting) ApiClusterTemplateRoleConfigGroupInfo(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroupInfo) ServiceComponent(com.sequenceiq.cloudbreak.template.model.ServiceComponent) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with ServiceComponent

use of com.sequenceiq.cloudbreak.template.model.ServiceComponent in project cloudbreak by hortonworks.

the class CmHostGroupRoleConfigProviderProcessor method generateConfigs.

@VisibleForTesting
Map<String, Map<String, List<ApiClusterTemplateConfig>>> generateConfigs(CmTemplateProcessor templateProcessor, TemplatePreparationObject source) {
    Map<String, Map<String, List<ApiClusterTemplateConfig>>> configsByRoleConfigGroup = new HashMap<>();
    Map<String, HostgroupView> hostGroups = source.getHostgroupViews().stream().collect(toMap(HostgroupView::getName, Function.identity()));
    List<ApiClusterTemplateHostTemplate> hostTemplates = getHostTemplates(templateProcessor);
    Map<String, ServiceComponent> serviceComponents = templateProcessor.mapRoleRefsToServiceComponents();
    for (ApiClusterTemplateHostTemplate hostTemplate : hostTemplates) {
        String hostGroupName = hostTemplate.getRefName();
        List<String> roleConfigGroups = ofNullable(hostTemplate.getRoleConfigGroupsRefNames()).orElseGet(List::of);
        HostgroupView hostgroupView = hostGroups.get(hostGroupName);
        groupByHostGroupName(source, configsByRoleConfigGroup, serviceComponents, hostGroupName, roleConfigGroups, hostgroupView);
    }
    return configsByRoleConfigGroup;
}
Also used : HashMap(java.util.HashMap) ServiceComponent(com.sequenceiq.cloudbreak.template.model.ServiceComponent) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) ArrayList(java.util.ArrayList) List(java.util.List) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) HashMap(java.util.HashMap) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) ApiClusterTemplateHostTemplate(com.cloudera.api.swagger.model.ApiClusterTemplateHostTemplate) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 5 with ServiceComponent

use of com.sequenceiq.cloudbreak.template.model.ServiceComponent in project cloudbreak by hortonworks.

the class ServiceEndpointCollector method getExposedServices.

/**
 * Get all exposed services for blueprint, there are filtered by visibility
 *
 * @param blueprintText given blueprintText
 * @return all visible exposed services for the given blueprint
 */
private Collection<ExposedService> getExposedServices(String blueprintText, List<String> entitlements) {
    CmTemplateProcessor processor = cmTemplateProcessorFactory.get(blueprintText);
    List<String> components = processor.getAllComponents().stream().map(ServiceComponent::getComponent).collect(Collectors.toList());
    return exposedServiceCollector.knoxServicesForComponents(processor.getVersion(), components).stream().filter(ExposedService::isVisible).filter(e -> serviceEndpointCollectorEntitlementComparator.entitlementSupported(entitlements, e.getEntitlement())).collect(Collectors.toList());
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) ClusterExposedServiceV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.ClusterExposedServiceV4Response) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) CmTemplateProcessorFactory(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessorFactory) StringUtils.isNotEmpty(org.apache.commons.lang3.StringUtils.isNotEmpty) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Value(org.springframework.beans.factory.annotation.Value) Strings(com.google.common.base.Strings) Service(org.springframework.stereotype.Service) Map(java.util.Map) ExposedServiceV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ExposedServiceV4Response) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) ExposedServiceCollector(com.sequenceiq.cloudbreak.api.service.ExposedServiceCollector) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) ClusterExposedServiceView(com.sequenceiq.cloudbreak.template.views.ClusterExposedServiceView) Logger(org.slf4j.Logger) YARN(com.sequenceiq.cloudbreak.common.type.OrchestratorConstants.YARN) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) GatewayTopologyV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.GatewayTopologyV4Response) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) ServiceComponent(com.sequenceiq.cloudbreak.template.model.ServiceComponent) List(java.util.List) GatewayType(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.GatewayType) Stream(java.util.stream.Stream) SecurityConfig(com.sequenceiq.cloudbreak.domain.SecurityConfig) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) Optional(java.util.Optional) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) ExposedServices(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices) BlueprintService(com.sequenceiq.cloudbreak.service.blueprint.BlueprintService) SSOType(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.SSOType) ComponentLocatorService(com.sequenceiq.cloudbreak.service.blueprint.ComponentLocatorService) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)

Aggregations

ServiceComponent (com.sequenceiq.cloudbreak.template.model.ServiceComponent)6 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 ApiClusterTemplateHostTemplate (com.cloudera.api.swagger.model.ApiClusterTemplateHostTemplate)3 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)3 HostgroupView (com.sequenceiq.cloudbreak.template.views.HostgroupView)3 List (java.util.List)3 Set (java.util.Set)3 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)2 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 StackType (com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType)2 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)2 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)2 HashSet (java.util.HashSet)2 Objects (java.util.Objects)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 Collectors.toMap (java.util.stream.Collectors.toMap)2