Search in sources :

Example 1 with BlueprintTextProcessor

use of com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor in project cloudbreak by hortonworks.

the class ComponentLocatorService method getFqdnsByComponents.

private Map<String, List<String>> getFqdnsByComponents(Cluster cluster, Collection<String> componentNames) {
    Map<String, List<String>> fqdnsByService = new HashMap<>();
    String blueprintText = cluster.getBlueprint().getBlueprintText();
    BlueprintTextProcessor processor = cmTemplateProcessorFactory.get(blueprintText);
    for (HostGroup hg : hostGroupService.getByCluster(cluster.getId())) {
        Set<String> hgComponents = new HashSet<>(processor.getComponentsInHostGroup(hg.getName()));
        hgComponents.retainAll(componentNames);
        fillList(fqdnsByService, hg, hgComponents);
    }
    return fqdnsByService;
}
Also used : HashMap(java.util.HashMap) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) ArrayList(java.util.ArrayList) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) HashSet(java.util.HashSet)

Example 2 with BlueprintTextProcessor

use of com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor in project cloudbreak by hortonworks.

the class CloudResourceAdvisor method getPlatformRecommendationByCredential.

private PlatformRecommendation getPlatformRecommendationByCredential(Long workspaceId, String blueprintName, String region, String platformVariant, String availabilityZone, CdpResourceType cdpResourceType, Credential credential) {
    String cloudPlatform = credential.cloudPlatform();
    Map<String, VmType> vmTypesByHostGroup = new HashMap<>();
    Map<String, Boolean> hostGroupContainsMasterComp = new HashMap<>();
    LOGGER.debug("Advising resources for blueprintName: {}, provider: {} and region: {}.", blueprintName, cloudPlatform, region);
    List<String> entitlements = entitlementService.getEntitlements(credential.getAccount());
    BlueprintTextProcessor blueprintTextProcessor = getBlueprintTextProcessor(workspaceId, blueprintName);
    Map<String, Set<String>> componentsByHostGroup = blueprintTextProcessor.getComponentsByHostGroup();
    componentsByHostGroup.forEach((hGName, components) -> hostGroupContainsMasterComp.put(hGName, isThereMasterComponents(blueprintTextProcessor.getClusterManagerType(), hGName, components)));
    PlatformDisks platformDisks = cloudParameterService.getDiskTypes();
    Platform platform = platform(cloudPlatform);
    DiskTypes diskTypes = new DiskTypes(platformDisks.getDiskTypes().get(platform), platformDisks.getDefaultDisks().get(platform), platformDisks.getDiskMappings().get(platform), platformDisks.getDiskDisplayNames().get(platform));
    CloudVmTypes vmTypes = cloudParameterService.getVmTypesV2(extendedCloudCredentialConverter.convert(credential), region, platformVariant, cdpResourceType, Maps.newHashMap());
    VmType defaultVmType = getDefaultVmType(availabilityZone, vmTypes);
    if (defaultVmType != null) {
        componentsByHostGroup.keySet().forEach(comp -> vmTypesByHostGroup.put(comp, defaultVmType));
    }
    VmRecommendations recommendations = cloudParameterService.getRecommendation(cloudPlatform);
    Set<VmType> availableVmTypes = null;
    if (StringUtils.isNotBlank(availabilityZone)) {
        availableVmTypes = vmTypes.getCloudVmResponses().get(availabilityZone);
    } else if (vmTypes.getCloudVmResponses() != null && !vmTypes.getCloudVmResponses().isEmpty()) {
        availableVmTypes = vmTypes.getCloudVmResponses().values().iterator().next();
    }
    if (availableVmTypes == null) {
        availableVmTypes = Collections.emptySet();
    }
    if (recommendations != null) {
        Map<String, VmType> masterVmTypes = getVmTypesForComponentType(true, recommendations.getMaster(), hostGroupContainsMasterComp, availableVmTypes, cloudPlatform, diskTypes, recommendations.getMaster());
        vmTypesByHostGroup.putAll(masterVmTypes);
        Map<String, VmType> workerVmTypes = getVmTypesForComponentType(false, recommendations.getWorker(), hostGroupContainsMasterComp, availableVmTypes, cloudPlatform, diskTypes, recommendations.getWorker(), recommendations.getBroker(), recommendations.getQuorum());
        vmTypesByHostGroup.putAll(workerVmTypes);
    } else {
        componentsByHostGroup.keySet().forEach(hg -> vmTypesByHostGroup.put(hg, null));
    }
    Map<String, InstanceCount> instanceCounts = recommendInstanceCounts(blueprintTextProcessor);
    GatewayRecommendation gateway = recommendGateway(blueprintTextProcessor);
    AutoscaleRecommendation autoscale = recommendAutoscale(blueprintTextProcessor);
    ResizeRecommendation resize = recommendResize(blueprintTextProcessor, entitlements);
    return new PlatformRecommendation(vmTypesByHostGroup, availableVmTypes, diskTypes, instanceCounts, gateway, autoscale, resize);
}
Also used : AutoscaleRecommendation(com.sequenceiq.cloudbreak.cloud.model.AutoscaleRecommendation) ResizeRecommendation(com.sequenceiq.cloudbreak.cloud.model.ResizeRecommendation) Set(java.util.Set) Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) HashMap(java.util.HashMap) PlatformDisks(com.sequenceiq.cloudbreak.cloud.model.PlatformDisks) InstanceCount(com.sequenceiq.cloudbreak.cloud.model.InstanceCount) CloudVmTypes(com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes) VmRecommendations(com.sequenceiq.cloudbreak.cloud.model.VmRecommendations) GatewayRecommendation(com.sequenceiq.cloudbreak.cloud.model.GatewayRecommendation) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) DiskTypes(com.sequenceiq.cloudbreak.cloud.model.DiskTypes) VmType(com.sequenceiq.cloudbreak.cloud.model.VmType) PlatformRecommendation(com.sequenceiq.cloudbreak.cloud.model.PlatformRecommendation)

Example 3 with BlueprintTextProcessor

use of com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor in project cloudbreak by hortonworks.

the class CloudResourceAdvisor method getAutoscaleRecommendation.

public AutoscaleRecommendation getAutoscaleRecommendation(Long workspaceId, String blueprintName) {
    LOGGER.debug("Autoscale advice for blueprintName: {}.", blueprintName);
    BlueprintTextProcessor blueprintTextProcessor = getBlueprintTextProcessor(workspaceId, blueprintName);
    return recommendAutoscale(blueprintTextProcessor);
}
Also used : BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)

Example 4 with BlueprintTextProcessor

use of com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor in project cloudbreak by hortonworks.

the class RangerRazBaseConfigProviderTest method getServiceTypesConfigWheAGCPAnd729ShouldNOTAddProperty.

@Test
public void getServiceTypesConfigWheAGCPAnd729ShouldNOTAddProperty() {
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    when(blueprintTextProcessor.getVersion()).thenReturn(Optional.of("7.2.9"));
    TemplatePreparationObject preparationObject = TemplatePreparationObject.Builder.builder().withStackType(StackType.WORKLOAD).withBlueprintView(new BlueprintView("", "7.2.9", "CDH", blueprintTextProcessor)).withCloudPlatform(CloudPlatform.GCP).withGeneralClusterConfigs(new GeneralClusterConfigs()).withDataLakeView(new DatalakeView(false)).build();
    List<ApiClusterTemplateConfig> roleConfigs = underTest.getRoleConfigs("", preparationObject);
    assertEquals(0, roleConfigs.size());
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) DatalakeView(com.sequenceiq.cloudbreak.template.views.DatalakeView) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Test(org.junit.jupiter.api.Test)

Example 5 with BlueprintTextProcessor

use of com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor in project cloudbreak by hortonworks.

the class RangerRazBaseConfigProviderTest method getServiceTypesConfigWheAWSAnd7210ShouldAddProperty.

@Test
public void getServiceTypesConfigWheAWSAnd7210ShouldAddProperty() {
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    when(blueprintTextProcessor.getVersion()).thenReturn(Optional.of("7.2.10"));
    TemplatePreparationObject preparationObject = TemplatePreparationObject.Builder.builder().withStackType(StackType.WORKLOAD).withBlueprintView(new BlueprintView("", "7.2.10", "CDH", blueprintTextProcessor)).withCloudPlatform(CloudPlatform.AWS).withGeneralClusterConfigs(new GeneralClusterConfigs()).withDataLakeView(new DatalakeView(false)).build();
    List<ApiClusterTemplateConfig> roleConfigs = underTest.getRoleConfigs("", preparationObject);
    assertEquals(1, roleConfigs.size());
    assertEquals("<property><name>ranger.raz.bootstrap.servicetypes</name><value>s3</value></property>", roleConfigs.get(0).getValue());
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) DatalakeView(com.sequenceiq.cloudbreak.template.views.DatalakeView) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Test(org.junit.jupiter.api.Test)

Aggregations

BlueprintTextProcessor (com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)22 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)13 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)12 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)11 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)7 Test (org.junit.jupiter.api.Test)7 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)6 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)6 DatalakeView (com.sequenceiq.cloudbreak.template.views.DatalakeView)6 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)5 IdBroker (com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker)5 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)5 HashMap (java.util.HashMap)5 Test (org.junit.Test)5 HashSet (java.util.HashSet)4 GatewayTopology (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology)3 AutoscaleRecommendation (com.sequenceiq.cloudbreak.cloud.model.AutoscaleRecommendation)2 ResizeRecommendation (com.sequenceiq.cloudbreak.cloud.model.ResizeRecommendation)2 ExposedServices (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices)2 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)2