Search in sources :

Example 1 with InstanceCount

use of com.sequenceiq.cloudbreak.cloud.model.InstanceCount 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 2 with InstanceCount

use of com.sequenceiq.cloudbreak.cloud.model.InstanceCount in project cloudbreak by hortonworks.

the class CmTemplateProcessor method getCardinalityByHostGroup.

@Override
public Map<String, InstanceCount> getCardinalityByHostGroup() {
    Map<String, InstanceCount> result = new TreeMap<>();
    for (ApiClusterTemplateHostTemplate group : Optional.ofNullable(cmTemplate.getHostTemplates()).orElse(List.of())) {
        InstanceCount recommendedCount = recommendInstanceCount(group.getRefName(), group.getCardinality()).orElse(InstanceCount.fallbackInstanceCountRecommendation(group.getRefName()));
        result.put(group.getRefName(), recommendedCount);
    }
    return result;
}
Also used : InstanceCount(com.sequenceiq.cloudbreak.cloud.model.InstanceCount) TreeMap(java.util.TreeMap) ApiClusterTemplateHostTemplate(com.cloudera.api.swagger.model.ApiClusterTemplateHostTemplate)

Example 3 with InstanceCount

use of com.sequenceiq.cloudbreak.cloud.model.InstanceCount in project cloudbreak by hortonworks.

the class BlueprintValidatorUtil method validateHostGroupCardinality.

public static void validateHostGroupCardinality(Set<HostGroup> hostGroups, Map<String, InstanceCount> blueprintHostGroupCardinality) {
    List<String> failures = new LinkedList<>();
    for (HostGroup hostGroup : hostGroups) {
        InstanceCount requiredCount = blueprintHostGroupCardinality.get(hostGroup.getName());
        int count = hostGroup.getInstanceGroup().getNodeCount();
        if (!requiredCount.isAcceptable(count)) {
            failures.add(String.format("(group: '%s', required: %s, actual: %d)", hostGroup.getName(), requiredCount, count));
        }
    }
    if (!failures.isEmpty()) {
        throw new BlueprintValidationException("Node count for the following host groups does not meet requirements: " + String.join(", ", failures));
    }
}
Also used : InstanceCount(com.sequenceiq.cloudbreak.cloud.model.InstanceCount) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) LinkedList(java.util.LinkedList)

Aggregations

InstanceCount (com.sequenceiq.cloudbreak.cloud.model.InstanceCount)3 ApiClusterTemplateHostTemplate (com.cloudera.api.swagger.model.ApiClusterTemplateHostTemplate)1 AutoscaleRecommendation (com.sequenceiq.cloudbreak.cloud.model.AutoscaleRecommendation)1 CloudVmTypes (com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes)1 DiskTypes (com.sequenceiq.cloudbreak.cloud.model.DiskTypes)1 GatewayRecommendation (com.sequenceiq.cloudbreak.cloud.model.GatewayRecommendation)1 Platform (com.sequenceiq.cloudbreak.cloud.model.Platform)1 PlatformDisks (com.sequenceiq.cloudbreak.cloud.model.PlatformDisks)1 PlatformRecommendation (com.sequenceiq.cloudbreak.cloud.model.PlatformRecommendation)1 ResizeRecommendation (com.sequenceiq.cloudbreak.cloud.model.ResizeRecommendation)1 VmRecommendations (com.sequenceiq.cloudbreak.cloud.model.VmRecommendations)1 VmType (com.sequenceiq.cloudbreak.cloud.model.VmType)1 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)1 BlueprintTextProcessor (com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Set (java.util.Set)1 TreeMap (java.util.TreeMap)1