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;
}
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));
}
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());
}
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());
}
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);
}
}
}
}
Aggregations