use of com.sequenceiq.cloudbreak.blueprint.validation.StackServiceComponentDescriptors 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);
}
Aggregations