Search in sources :

Example 1 with StackServiceComponentDescriptors

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);
}
Also used : StackServiceComponentDescriptors(com.sequenceiq.cloudbreak.blueprint.validation.StackServiceComponentDescriptors) StackServiceComponentDescriptor(com.sequenceiq.cloudbreak.blueprint.validation.StackServiceComponentDescriptor) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 StackServiceComponentDescriptor (com.sequenceiq.cloudbreak.blueprint.validation.StackServiceComponentDescriptor)1 StackServiceComponentDescriptors (com.sequenceiq.cloudbreak.blueprint.validation.StackServiceComponentDescriptors)1