use of com.sequenceiq.cloudbreak.blueprint.validation.StackServiceComponentDescriptor in project cloudbreak by hortonworks.
the class AppConfig method createServiceComponentDescriptors.
private StackServiceComponentDescriptors createServiceComponentDescriptors(String stackServiceComponentsJson, Map<String, Integer> minCardinalityReps, Map<String, Integer> maxCardinalityReps) throws Exception {
Map<String, StackServiceComponentDescriptor> stackServiceComponentDescriptorMap = Maps.newHashMap();
JsonNode rootNode = JsonUtil.readTree(stackServiceComponentsJson);
JsonNode itemsNode = rootNode.get("items");
for (JsonNode itemNode : itemsNode) {
JsonNode componentsNode = itemNode.get("components");
for (JsonNode componentNode : componentsNode) {
JsonNode stackServiceComponentsNode = componentNode.get("StackServiceComponents");
String componentName = stackServiceComponentsNode.get("component_name").asText();
String componentCategory = stackServiceComponentsNode.get("component_category").asText();
int minCardinality = parseCardinality(minCardinalityReps, stackServiceComponentsNode.get("cardinality").asText(), 0);
int maxCardinality = parseCardinality(maxCardinalityReps, stackServiceComponentsNode.get("cardinality").asText(), Integer.MAX_VALUE);
stackServiceComponentDescriptorMap.put(componentName, new StackServiceComponentDescriptor(componentName, componentCategory, minCardinality, maxCardinality));
}
}
return new StackServiceComponentDescriptors(stackServiceComponentDescriptorMap);
}
use of com.sequenceiq.cloudbreak.blueprint.validation.StackServiceComponentDescriptor in project cloudbreak by hortonworks.
the class ClusterToClusterResponseConverter method prepareServiceEndpointsMap.
private Map<String, String> prepareServiceEndpointsMap(Cluster cluster, String ambariIp) {
Set<HostGroup> hostGroups = cluster.getHostGroups();
Blueprint blueprint = cluster.getBlueprint();
Map<String, String> result = new HashMap<>();
List<Port> ports = NetworkUtils.getPorts(Optional.empty());
try {
JsonNode hostGroupsNode = blueprintValidator.getHostGroupNode(blueprint);
Map<String, HostGroup> hostGroupMap = blueprintValidator.createHostGroupMap(hostGroups);
for (JsonNode hostGroupNode : hostGroupsNode) {
String hostGroupName = blueprintValidator.getHostGroupName(hostGroupNode);
JsonNode componentsNode = blueprintValidator.getComponentsNode(hostGroupNode);
HostGroup actualHostgroup = hostGroupMap.get(hostGroupName);
String serviceAddress;
if (actualHostgroup.getConstraint().getInstanceGroup() != null) {
InstanceMetaData next = actualHostgroup.getConstraint().getInstanceGroup().getInstanceMetaData().iterator().next();
serviceAddress = next.getPublicIpWrapper();
} else {
serviceAddress = actualHostgroup.getHostMetadata().iterator().next().getHostName();
}
for (JsonNode componentNode : componentsNode) {
String componentName = componentNode.get("name").asText();
StackServiceComponentDescriptor componentDescriptor = stackServiceComponentDescs.get(componentName);
collectServicePorts(result, ports, ambariIp, serviceAddress, componentDescriptor, cluster);
}
}
} catch (Exception ignored) {
return result;
}
return result;
}
use of com.sequenceiq.cloudbreak.blueprint.validation.StackServiceComponentDescriptor in project cloudbreak by hortonworks.
the class ClusterToClusterResponseConverterTest method testConvertWithoutMasterComponent.
@Test
public void testConvertWithoutMasterComponent() throws IOException {
// GIVEN
mockAll();
given(stackServiceComponentDescs.get(anyString())).willReturn(new StackServiceComponentDescriptor("dummy", "dummy", 1, 1));
// WHEN
ClusterResponse result = underTest.convert(getSource());
// THEN
assertEquals(1L, (long) result.getId());
}
Aggregations