Search in sources :

Example 11 with Versioned

use of com.sequenceiq.cloudbreak.common.type.Versioned in project cloudbreak by hortonworks.

the class CloudResourceAdvisor method recommendResize.

private ResizeRecommendation recommendResize(BlueprintTextProcessor blueprintTextProcessor, List<String> entitlements) {
    Versioned blueprintVersion = () -> blueprintTextProcessor.getVersion().get();
    ResizeRecommendation resizeRecommendation = blueprintTextProcessor.recommendResize(entitlements, blueprintVersion);
    if (resizeRecommendation.getScaleUpHostGroups().isEmpty()) {
        Set<String> scaleUpHostGroups = filterHostGroupByPredicate(blueprintTextProcessor, this::fallbackScaleUpFilter);
        if (!scaleUpHostGroups.isEmpty()) {
            resizeRecommendation.setScaleUpHostGroups(scaleUpHostGroups);
        }
    }
    if (resizeRecommendation.getScaleDownHostGroups().isEmpty()) {
        Set<String> scaleDownHostGroups = filterHostGroupByPredicate(blueprintTextProcessor, this::fallbackScaleDownFilter);
        if (!scaleDownHostGroups.isEmpty()) {
            resizeRecommendation.setScaleDownHostGroups(scaleDownHostGroups);
        }
    }
    return resizeRecommendation;
}
Also used : ResizeRecommendation(com.sequenceiq.cloudbreak.cloud.model.ResizeRecommendation) Versioned(com.sequenceiq.cloudbreak.common.type.Versioned)

Example 12 with Versioned

use of com.sequenceiq.cloudbreak.common.type.Versioned in project cloudbreak by hortonworks.

the class CmTemplateProcessorTest method recommendResize.

@Test
public void recommendResize() {
    Versioned blueprintVersion = () -> "7.2.11";
    underTest = new CmTemplateProcessor(getBlueprintText("input/kafka.bp"));
    assertEquals(new ResizeRecommendation(Set.of("quorum"), Set.of("quorum")), underTest.recommendResize(List.of(), blueprintVersion));
    underTest = new CmTemplateProcessor(getBlueprintText("input/de-ha.bp"));
    Set<String> hostGroups = Set.of("gateway", "compute", "worker");
    assertEquals(new ResizeRecommendation(hostGroups, hostGroups), underTest.recommendResize(List.of(), blueprintVersion));
    underTest = new CmTemplateProcessor(getBlueprintText("input/cb5660.bp"));
    hostGroups = Set.of("gateway", "quorum", "worker", "compute");
    assertEquals(new ResizeRecommendation(hostGroups, hostGroups), underTest.recommendResize(List.of(), blueprintVersion));
    underTest = new CmTemplateProcessor(getBlueprintText("input/nifi.bp"));
    assertEquals(new ResizeRecommendation(Set.of(), Set.of()), underTest.recommendResize(List.of(), blueprintVersion));
}
Also used : ResizeRecommendation(com.sequenceiq.cloudbreak.cloud.model.ResizeRecommendation) Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) Test(org.junit.jupiter.api.Test)

Example 13 with Versioned

use of com.sequenceiq.cloudbreak.common.type.Versioned in project cloudbreak by hortonworks.

the class CmTemplateProcessorTest method testGetComputeHostGroups.

@Test
public void testGetComputeHostGroups() {
    Versioned blueprintVersion = () -> "7.2.11";
    underTest = new CmTemplateProcessor(getBlueprintText("input/custom-hostgroups-for-nms.bp"));
    assertEquals(2, underTest.getComputeHostGroups(blueprintVersion).size());
}
Also used : Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) Test(org.junit.jupiter.api.Test)

Example 14 with Versioned

use of com.sequenceiq.cloudbreak.common.type.Versioned in project cloudbreak by hortonworks.

the class CmTemplateProcessorTest method testYARNServiceAttributes.

@Test
public void testYARNServiceAttributes() {
    Versioned blueprintVersion = () -> "7.2.11";
    underTest = new CmTemplateProcessor(getBlueprintText("input/custom-hostgroups-for-nms.bp"));
    assertEquals(7, underTest.getHostTemplateNames().size());
    Map<String, Map<String, ServiceAttributes>> attrs = underTest.getHostGroupBasedServiceAttributes(blueprintVersion);
    assertEquals(4, attrs.size());
    Map<String, ServiceAttributes> serviceAttributesMap;
    serviceAttributesMap = attrs.get("worker");
    assertEquals(1, serviceAttributesMap.get(YarnRoles.YARN).getAttributes().size());
    assertEquals(YarnConstants.ATTRIBUTE_NAME_NODE_INSTANCE_TYPE, serviceAttributesMap.get(YarnRoles.YARN).getAttributes().keySet().iterator().next());
    assertEquals(YarnConstants.ATTRIBUTE_NODE_INSTANCE_TYPE_WORKER, serviceAttributesMap.get(YarnRoles.YARN).getAttributes().values().iterator().next());
    serviceAttributesMap = attrs.get("compute");
    assertEquals(1, serviceAttributesMap.get(YarnRoles.YARN).getAttributes().size());
    assertEquals(YarnConstants.ATTRIBUTE_NAME_NODE_INSTANCE_TYPE, serviceAttributesMap.get(YarnRoles.YARN).getAttributes().keySet().iterator().next());
    assertEquals(YarnConstants.ATTRIBUTE_NODE_INSTANCE_TYPE_COMPUTE, serviceAttributesMap.get(YarnRoles.YARN).getAttributes().values().iterator().next());
    // Verify that custom hostGroup names also get marked as "compute" or "worker"
    serviceAttributesMap = attrs.get("customnm1");
    assertEquals(1, serviceAttributesMap.get(YarnRoles.YARN).getAttributes().size());
    assertEquals(YarnConstants.ATTRIBUTE_NAME_NODE_INSTANCE_TYPE, serviceAttributesMap.get(YarnRoles.YARN).getAttributes().keySet().iterator().next());
    assertEquals(YarnConstants.ATTRIBUTE_NODE_INSTANCE_TYPE_WORKER, serviceAttributesMap.get(YarnRoles.YARN).getAttributes().values().iterator().next());
    serviceAttributesMap = attrs.get("customnm2");
    assertEquals(1, serviceAttributesMap.get(YarnRoles.YARN).getAttributes().size());
    assertEquals(YarnConstants.ATTRIBUTE_NAME_NODE_INSTANCE_TYPE, serviceAttributesMap.get(YarnRoles.YARN).getAttributes().keySet().iterator().next());
    assertEquals(YarnConstants.ATTRIBUTE_NODE_INSTANCE_TYPE_COMPUTE, serviceAttributesMap.get(YarnRoles.YARN).getAttributes().values().iterator().next());
}
Also used : Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) ServiceAttributes(com.sequenceiq.cloudbreak.template.model.ServiceAttributes) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) Test(org.junit.jupiter.api.Test)

Example 15 with Versioned

use of com.sequenceiq.cloudbreak.common.type.Versioned in project cloudbreak by hortonworks.

the class CmTemplateValidator method validateBlackListedScalingRoles.

private void validateBlackListedScalingRoles(String accountId, CmTemplateProcessor templateProcessor, String hostGroupName, Integer adjustment) {
    Versioned blueprintVersion = () -> templateProcessor.getVersion().get();
    Set<String> services = templateProcessor.getComponentsByHostGroup().get(hostGroupName);
    if (adjustment < 0) {
        for (BlackListedDownScaleRole role : BlackListedDownScaleRole.values()) {
            if (services.contains(role.name())) {
                validateRole(accountId, role, blueprintVersion, templateProcessor);
            }
        }
    }
    if (adjustment > 0) {
        for (BlackListedUpScaleRole role : BlackListedUpScaleRole.values()) {
            if (services.contains(role.name())) {
                validateRole(accountId, role, blueprintVersion, templateProcessor);
            }
        }
    }
}
Also used : Versioned(com.sequenceiq.cloudbreak.common.type.Versioned)

Aggregations

Versioned (com.sequenceiq.cloudbreak.common.type.Versioned)15 Test (org.junit.jupiter.api.Test)4 VersionComparator (com.sequenceiq.cloudbreak.util.VersionComparator)3 AutoscaleRecommendation (com.sequenceiq.cloudbreak.cloud.model.AutoscaleRecommendation)2 ResizeRecommendation (com.sequenceiq.cloudbreak.cloud.model.ResizeRecommendation)2 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ClustersResourceApi (com.cloudera.api.swagger.ClustersResourceApi)1 ApiClient (com.cloudera.api.swagger.client.ApiClient)1 CloudStorageSupportedV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.CloudStorageSupportedV4Response)1 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)1 Image (com.sequenceiq.cloudbreak.cloud.model.Image)1 CloudbreakImageCatalogV3 (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3)1 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)1 ClouderaManagerClientInitException (com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 Node (com.sequenceiq.cloudbreak.common.orchestration.Node)1 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)1 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)1