AMBARI-22297 Enrich deserialized v2 blueprint (benyoka)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/acab46dc Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/acab46dc Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/acab46dc Branch: refs/heads/branch-feature-AMBARI-14714-ui Commit: acab46dc626d7eef9fdf610c8379b34645bcd758 Parents: f50d9a2 Author: Balazs Bence Sari <[email protected]> Authored: Tue Oct 24 13:52:46 2017 +0200 Committer: Balazs Bence Sari <[email protected]> Committed: Tue Oct 24 13:52:46 2017 +0200 ---------------------------------------------------------------------- .../StackAdvisorBlueprintProcessor.java | 2 +- .../ambari/server/controller/StackV2.java | 1029 +++++++++--------- .../ambari/server/topology/BlueprintImplV2.java | 211 ++-- .../ambari/server/topology/BlueprintV2.java | 8 +- .../server/topology/BlueprintV2Factory.java | 2 + .../ambari/server/topology/ComponentV2.java | 9 +- .../ambari/server/topology/HostGroupV2.java | 9 +- .../ambari/server/topology/HostGroupV2Impl.java | 37 +- .../apache/ambari/server/topology/Service.java | 58 +- .../ambari/server/topology/ServiceGroup.java | 28 +- .../ambari/server/topology/ServiceId.java | 10 + .../apache/ambari/server/topology/Setting.java | 18 +- .../validators/BlueprintImplV2Test.java | 11 + .../test/resources/blueprintv2/blueprintv2.json | 24 +- 14 files changed, 800 insertions(+), 656 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java index 2e9ac9f..9bbdc37 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java @@ -117,7 +117,7 @@ public class StackAdvisorBlueprintProcessor { private Map<String, Set<String>> gatherHostGroupComponents(ClusterTopology clusterTopology) { Map<String, Set<String>> hgComponentsMap = Maps.newHashMap(); - for (Map.Entry<String, HostGroupV2> hgEnrty: clusterTopology.getBlueprint().getHostGroups().entrySet()) { + for (Map.Entry<String, ? extends HostGroupV2> hgEnrty: clusterTopology.getBlueprint().getHostGroups().entrySet()) { hgComponentsMap.put(hgEnrty.getKey(), Sets.newCopyOnWriteArraySet(hgEnrty.getValue().getComponentNames())); } return hgComponentsMap; http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java index 169bf6a..040e604 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java @@ -7,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -30,6 +30,7 @@ import org.apache.ambari.server.state.ComponentInfo; import org.apache.ambari.server.state.DependencyInfo; import org.apache.ambari.server.state.PropertyDependencyInfo; import org.apache.ambari.server.state.PropertyInfo; +import org.apache.ambari.server.state.StackId; import org.apache.ambari.server.state.ValueAttributesInfo; import org.apache.ambari.server.topology.Cardinality; import org.apache.ambari.server.topology.Configuration; @@ -39,568 +40,572 @@ import org.apache.ambari.server.topology.Configuration; */ public class StackV2 { - /** Stack name */ - private final String name; - - /** Stack version */ - private final String version; - - /** Repo version */ - private final String repoVersion; - - /** Map of service name to components */ - private final Map<String, Collection<String>> serviceComponents; - - /** Map of component to service */ - private final Map<String, String> componentService; - - /** Map of component to dependencies */ - private final Map<String, Collection<DependencyInfo>> dependencies; - - /** Map of dependency to conditional service */ - private final Map<DependencyInfo, String> dependencyConditionalServiceMap; - - /** - * Map of database component name to configuration property which indicates whether - * the database in to be managed or if it is an external non-managed instance. - * If the value of the config property starts with 'New', the database is determined - * to be managed, otherwise it is non-managed. - */ - private final Map<String, String> dbDependencyInfo; - - /** Map of component to required cardinality */ - private final Map<String, String> cardinalityRequirements = new HashMap<>(); - - //todo: instead of all these maps from component -> * , - //todo: we should use a Component object with all of these attributes - private Set<String> masterComponents = new HashSet<>(); - - /** Map of component to auto-deploy information */ - private final Map<String, AutoDeployInfo> componentAutoDeployInfo; - - /** Map of service to config type properties */ - private final Map<String, Map<String, Map<String, ConfigProperty>>> serviceConfigurations; - - /** Map of service to required type properties */ - private final Map<String, Map<String, Map<String, ConfigProperty>>> requiredServiceConfigurations; - - /** Map of service to config type properties */ - private final Map<String, Map<String, ConfigProperty>> stackConfigurations; - - /** Map of service to set of excluded config types */ - private final Map<String, Set<String>> excludedConfigurationTypes; - - public StackV2(String name, - String version, - String repoVersion, - Map<String, Collection<String>> serviceComponents, - Map<String, Collection<DependencyInfo>> dependencies, - Map<String, String> dbDependencyInfo, - Map<String, AutoDeployInfo> componentAutoDeployInfo, - Map<String, Map<String, Map<String, ConfigProperty>>> serviceConfigurations, - Map<String, Map<String, Map<String, ConfigProperty>>> requiredServiceConfigurations, - Map<String, Map<String, ConfigProperty>> stackConfigurations, - Map<String, Set<String>> excludedConfigurationTypes) { - this.name = name; - this.version = version; - this.repoVersion = repoVersion; - - this.serviceComponents = serviceComponents; - this.componentService = new HashMap<>(); - for (Map.Entry<String, Collection<String>> entry: serviceComponents.entrySet()) { - for (String comp: entry.getValue()) { - componentService.put(comp, entry.getKey()); - } - } - - this.dependencies = dependencies; - this.dependencyConditionalServiceMap = new HashMap<>(); - for (Map.Entry<String, Collection<DependencyInfo>> entry: dependencies.entrySet()) { - for (DependencyInfo di: entry.getValue()) { - dependencyConditionalServiceMap.put(di, entry.getKey()); - } - } - - this.dbDependencyInfo = dbDependencyInfo; - this.componentAutoDeployInfo = componentAutoDeployInfo; - this.serviceConfigurations = serviceConfigurations; - this.requiredServiceConfigurations = requiredServiceConfigurations; - this.stackConfigurations = stackConfigurations; - this.excludedConfigurationTypes = excludedConfigurationTypes; - } - - /** @return stack name */ - public String getName() { - return name; - } - - /** @return stack version */ - public String getVersion() { - return version; - } - - /** @return repo version */ - public String getRepoVersion() { return repoVersion; } - - Map<DependencyInfo, String> getDependencyConditionalServiceMap() { - return dependencyConditionalServiceMap; - } - - /** @return collection of all services for the stack */ - public Collection<String> getServices() { - return serviceComponents.keySet(); - } - - /** - * Get components contained in the stack for the specified service. - * - * @param service service name - * @return collection of component names for the specified service - */ - public Collection<String> getComponents(String service) { - return serviceComponents.get(service); - } - - /** @return map of service to associated components */ - public Map<String, Collection<String>> getComponents() { - return serviceComponents; + /** Stack name */ + private final String name; + + /** Stack version */ + private final String version; + + /** Repo version */ + private final String repoVersion; + + /** Map of service name to components */ + private final Map<String, Collection<String>> serviceComponents; + + /** Map of component to service */ + private final Map<String, String> componentService; + + /** Map of component to dependencies */ + private final Map<String, Collection<DependencyInfo>> dependencies; + + /** Map of dependency to conditional service */ + private final Map<DependencyInfo, String> dependencyConditionalServiceMap; + + /** + * Map of database component name to configuration property which indicates whether + * the database in to be managed or if it is an external non-managed instance. + * If the value of the config property starts with 'New', the database is determined + * to be managed, otherwise it is non-managed. + */ + private final Map<String, String> dbDependencyInfo; + + /** Map of component to required cardinality */ + private final Map<String, String> cardinalityRequirements = new HashMap<>(); + + //todo: instead of all these maps from component -> * , + //todo: we should use a Component object with all of these attributes + private Set<String> masterComponents = new HashSet<>(); + + /** Map of component to auto-deploy information */ + private final Map<String, AutoDeployInfo> componentAutoDeployInfo; + + /** Map of service to config type properties */ + private final Map<String, Map<String, Map<String, ConfigProperty>>> serviceConfigurations; + + /** Map of service to required type properties */ + private final Map<String, Map<String, Map<String, ConfigProperty>>> requiredServiceConfigurations; + + /** Map of service to config type properties */ + private final Map<String, Map<String, ConfigProperty>> stackConfigurations; + + /** Map of service to set of excluded config types */ + private final Map<String, Set<String>> excludedConfigurationTypes; + + public StackV2(String name, + String version, + String repoVersion, + Map<String, Collection<String>> serviceComponents, + Map<String, Collection<DependencyInfo>> dependencies, + Map<String, String> dbDependencyInfo, + Map<String, AutoDeployInfo> componentAutoDeployInfo, + Map<String, Map<String, Map<String, ConfigProperty>>> serviceConfigurations, + Map<String, Map<String, Map<String, ConfigProperty>>> requiredServiceConfigurations, + Map<String, Map<String, ConfigProperty>> stackConfigurations, + Map<String, Set<String>> excludedConfigurationTypes) { + this.name = name; + this.version = version; + this.repoVersion = repoVersion; + + this.serviceComponents = serviceComponents; + this.componentService = new HashMap<>(); + for (Map.Entry<String, Collection<String>> entry: serviceComponents.entrySet()) { + for (String comp: entry.getValue()) { + componentService.put(comp, entry.getKey()); + } } - /** - * Get info for the specified component. - * - * @param component component name - * - * @return component information for the requested component - * or null if the component doesn't exist in the stack - */ - @Deprecated - public ComponentInfo getComponentInfo(String component) { - ComponentInfo componentInfo = null; -// String service = getServiceForComponent(component); -// if (service != null) { -// try { -// componentInfo = controller.getAmbariMetaInfo().getComponent( -// getName(), getVersion(), service, component); -// } catch (AmbariException e) { -// // just return null if component doesn't exist -// } -// } - return componentInfo; + this.dependencies = dependencies; + this.dependencyConditionalServiceMap = new HashMap<>(); + for (Map.Entry<String, Collection<DependencyInfo>> entry: dependencies.entrySet()) { + for (DependencyInfo di: entry.getValue()) { + dependencyConditionalServiceMap.put(di, entry.getKey()); } - - /** - * Get all configuration types, including excluded types for the specified service. - * - * @param service service name - * - * @return collection of all configuration types for the specified service - */ - public Collection<String> getAllConfigurationTypes(String service) { - return serviceConfigurations.get(service).keySet(); } - /** - * Get configuration types for the specified service. - * This doesn't include any service excluded types. - * - * @param service service name - * - * @return collection of all configuration types for the specified service - */ - public Collection<String> getConfigurationTypes(String service) { - Set<String> serviceTypes = new HashSet<>(serviceConfigurations.get(service).keySet()); - serviceTypes.removeAll(getExcludedConfigurationTypes(service)); - return serviceTypes; - } + this.dbDependencyInfo = dbDependencyInfo; + this.componentAutoDeployInfo = componentAutoDeployInfo; + this.serviceConfigurations = serviceConfigurations; + this.requiredServiceConfigurations = requiredServiceConfigurations; + this.stackConfigurations = stackConfigurations; + this.excludedConfigurationTypes = excludedConfigurationTypes; + } + + /** @return stack name */ + public String getName() { + return name; + } + + /** @return stack version */ + public String getVersion() { + return version; + } + + public StackId getStackId() { + return new StackId(name, version); + } + + /** @return repo version */ + public String getRepoVersion() { return repoVersion; } + + Map<DependencyInfo, String> getDependencyConditionalServiceMap() { + return dependencyConditionalServiceMap; + } + + /** @return collection of all services for the stack */ + public Collection<String> getServices() { + return serviceComponents.keySet(); + } + + /** + * Get components contained in the stack for the specified service. + * + * @param service service name + * @return collection of component names for the specified service + */ + public Collection<String> getComponents(String service) { + return serviceComponents.get(service); + } + + /** @return map of service to associated components */ + public Map<String, Collection<String>> getComponents() { + return serviceComponents; + } /** - * Get the set of excluded configuration types for this service. + * Get info for the specified component. * - * @param service service name + * @param component component name * - * @return Set of names of excluded config types. Will not return null. + * @return component information for the requested component + * or null if the component doesn't exist in the stack */ - public Set<String> getExcludedConfigurationTypes(String service) { - return excludedConfigurationTypes.containsKey(service) ? - excludedConfigurationTypes.get(service) : - Collections.emptySet(); + @Deprecated + public ComponentInfo getComponentInfo(String component) { + ComponentInfo componentInfo = null; +// String service = getServiceForComponent(component); +// if (service != null) { +// try { +// componentInfo = controller.getAmbariMetaInfo().getComponent( +// getName(), getVersion(), service, component); +// } catch (AmbariException e) { +// // just return null if component doesn't exist +// } +// } + return componentInfo; + } + + /** + * Get all configuration types, including excluded types for the specified service. + * + * @param service service name + * + * @return collection of all configuration types for the specified service + */ + public Collection<String> getAllConfigurationTypes(String service) { + return serviceConfigurations.get(service).keySet(); + } + + /** + * Get configuration types for the specified service. + * This doesn't include any service excluded types. + * + * @param service service name + * + * @return collection of all configuration types for the specified service + */ + public Collection<String> getConfigurationTypes(String service) { + Set<String> serviceTypes = new HashSet<>(serviceConfigurations.get(service).keySet()); + serviceTypes.removeAll(getExcludedConfigurationTypes(service)); + return serviceTypes; + } + + /** + * Get the set of excluded configuration types for this service. + * + * @param service service name + * + * @return Set of names of excluded config types. Will not return null. + */ + public Set<String> getExcludedConfigurationTypes(String service) { + return excludedConfigurationTypes.containsKey(service) ? + excludedConfigurationTypes.get(service) : + Collections.emptySet(); + } + + /** + * Get config properties for the specified service and configuration type. + * + * @param service service name + * @param type configuration type + * + * @return map of property names to values for the specified service and configuration type + */ + public Map<String, String> getConfigurationProperties(String service, String type) { + Map<String, String> configMap = new HashMap<>(); + Map<String, ConfigProperty> configProperties = serviceConfigurations.get(service).get(type); + if (configProperties != null) { + for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) { + configMap.put(configProperty.getKey(), configProperty.getValue().getValue()); + } } - - /** - * Get config properties for the specified service and configuration type. - * - * @param service service name - * @param type configuration type - * - * @return map of property names to values for the specified service and configuration type - */ - public Map<String, String> getConfigurationProperties(String service, String type) { - Map<String, String> configMap = new HashMap<>(); - Map<String, ConfigProperty> configProperties = serviceConfigurations.get(service).get(type); - if (configProperties != null) { - for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) { - configMap.put(configProperty.getKey(), configProperty.getValue().getValue()); - } + return configMap; + } + + public Map<String, ConfigProperty> getConfigurationPropertiesWithMetadata(String service, String type) { + return serviceConfigurations.get(service).get(type); + } + + /** + * Get all required config properties for the specified service. + * + * @param service service name + * + * @return collection of all required properties for the given service + */ + public Collection<ConfigProperty> getRequiredConfigurationProperties(String service) { + Collection<ConfigProperty> requiredConfigProperties = new HashSet<>(); + Map<String, Map<String, ConfigProperty>> serviceProperties = requiredServiceConfigurations.get(service); + if (serviceProperties != null) { + for (Map.Entry<String, Map<String, ConfigProperty>> typePropertiesEntry : serviceProperties.entrySet()) { + requiredConfigProperties.addAll(typePropertiesEntry.getValue().values()); + } + } + return requiredConfigProperties; + } + + /** + * Get required config properties for the specified service which belong to the specified property type. + * + * @param service service name + * @param propertyType property type + * + * @return collection of required properties for the given service and property type + */ + public Collection<ConfigProperty> getRequiredConfigurationProperties(String service, PropertyInfo.PropertyType propertyType) { + Collection<ConfigProperty> matchingProperties = new HashSet<>(); + Map<String, Map<String, ConfigProperty>> requiredProperties = requiredServiceConfigurations.get(service); + if (requiredProperties != null) { + for (Map.Entry<String, Map<String, ConfigProperty>> typePropertiesEntry : requiredProperties.entrySet()) { + for (ConfigProperty configProperty : typePropertiesEntry.getValue().values()) { + if (configProperty.getPropertyTypes().contains(propertyType)) { + matchingProperties.add(configProperty); + } } - return configMap; + } } - - public Map<String, ConfigProperty> getConfigurationPropertiesWithMetadata(String service, String type) { - return serviceConfigurations.get(service).get(type); + return matchingProperties; + } + + public boolean isPasswordProperty(String service, String type, String propertyName) { + return (serviceConfigurations.containsKey(service) && + serviceConfigurations.get(service).containsKey(type) && + serviceConfigurations.get(service).get(type).containsKey(propertyName) && + serviceConfigurations.get(service).get(type).get(propertyName).getPropertyTypes(). + contains(PropertyInfo.PropertyType.PASSWORD)); + } + + //todo + public Map<String, String> getStackConfigurationProperties(String type) { + Map<String, String> configMap = new HashMap<>(); + Map<String, ConfigProperty> configProperties = stackConfigurations.get(type); + if (configProperties != null) { + for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) { + configMap.put(configProperty.getKey(), configProperty.getValue().getValue()); + } } - - /** - * Get all required config properties for the specified service. - * - * @param service service name - * - * @return collection of all required properties for the given service - */ - public Collection<ConfigProperty> getRequiredConfigurationProperties(String service) { - Collection<ConfigProperty> requiredConfigProperties = new HashSet<>(); - Map<String, Map<String, ConfigProperty>> serviceProperties = requiredServiceConfigurations.get(service); - if (serviceProperties != null) { - for (Map.Entry<String, Map<String, ConfigProperty>> typePropertiesEntry : serviceProperties.entrySet()) { - requiredConfigProperties.addAll(typePropertiesEntry.getValue().values()); + return configMap; + } + + public boolean isKerberosPrincipalNameProperty(String service, String type, String propertyName) { + return (serviceConfigurations.containsKey(service) && + serviceConfigurations.get(service).containsKey(type) && + serviceConfigurations.get(service).get(type).containsKey(propertyName) && + serviceConfigurations.get(service).get(type).get(propertyName).getPropertyTypes(). + contains(PropertyInfo.PropertyType.KERBEROS_PRINCIPAL)); + } + /** + * Get config attributes for the specified service and configuration type. + * + * @param service service name + * @param type configuration type + * + * @return map of attribute names to map of property names to attribute values + * for the specified service and configuration type + */ + public Map<String, Map<String, String>> getConfigurationAttributes(String service, String type) { + Map<String, Map<String, String>> attributesMap = new HashMap<>(); + Map<String, ConfigProperty> configProperties = serviceConfigurations.get(service).get(type); + if (configProperties != null) { + for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) { + String propertyName = configProperty.getKey(); + Map<String, String> propertyAttributes = configProperty.getValue().getAttributes(); + if (propertyAttributes != null) { + for (Map.Entry<String, String> propertyAttribute : propertyAttributes.entrySet()) { + String attributeName = propertyAttribute.getKey(); + String attributeValue = propertyAttribute.getValue(); + if (attributeValue != null) { + Map<String, String> attributes = getWithEmptyDefault(attributesMap, attributeName); + attributes.put(propertyName, attributeValue); } + } } - return requiredConfigProperties; + } } - - /** - * Get required config properties for the specified service which belong to the specified property type. - * - * @param service service name - * @param propertyType property type - * - * @return collection of required properties for the given service and property type - */ - public Collection<ConfigProperty> getRequiredConfigurationProperties(String service, PropertyInfo.PropertyType propertyType) { - Collection<ConfigProperty> matchingProperties = new HashSet<>(); - Map<String, Map<String, ConfigProperty>> requiredProperties = requiredServiceConfigurations.get(service); - if (requiredProperties != null) { - for (Map.Entry<String, Map<String, ConfigProperty>> typePropertiesEntry : requiredProperties.entrySet()) { - for (ConfigProperty configProperty : typePropertiesEntry.getValue().values()) { - if (configProperty.getPropertyTypes().contains(propertyType)) { - matchingProperties.add(configProperty); - } - } - } + return attributesMap; + } + + //todo: + public Map<String, Map<String, String>> getStackConfigurationAttributes(String type) { + Map<String, Map<String, String>> attributesMap = new HashMap<>(); + Map<String, ConfigProperty> configProperties = stackConfigurations.get(type); + if (configProperties != null) { + for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) { + String propertyName = configProperty.getKey(); + Map<String, String> propertyAttributes = configProperty.getValue().getAttributes(); + if (propertyAttributes != null) { + for (Map.Entry<String, String> propertyAttribute : propertyAttributes.entrySet()) { + String attributeName = propertyAttribute.getKey(); + String attributeValue = propertyAttribute.getValue(); + Map<String, String> attributes = getWithEmptyDefault(attributesMap, attributeName); + attributes.put(propertyName, attributeValue); + } } - return matchingProperties; + } } - - public boolean isPasswordProperty(String service, String type, String propertyName) { - return (serviceConfigurations.containsKey(service) && - serviceConfigurations.get(service).containsKey(type) && - serviceConfigurations.get(service).get(type).containsKey(propertyName) && - serviceConfigurations.get(service).get(type).get(propertyName).getPropertyTypes(). - contains(PropertyInfo.PropertyType.PASSWORD)); + return attributesMap; + } + + /** + * Get the service for the specified component. + * + * @param component component name + * + * @return service name that contains tha specified component + */ + public String getServiceForComponent(String component) { + return componentService.get(component); + } + + /** + * Get the names of the services which contains the specified components. + * + * @param components collection of components + * + * @return collection of services which contain the specified components + */ + public Collection<String> getServicesForComponents(Collection<String> components) { + Set<String> services = new HashSet<>(); + for (String component : components) { + services.add(getServiceForComponent(component)); + } + + return services; + } + + /** + * Obtain the service name which corresponds to the specified configuration. + * + * @param config configuration type + * + * @return name of service which corresponds to the specified configuration type + */ + public String getServiceForConfigType(String config) { + for (Map.Entry<String, Map<String, Map<String, ConfigProperty>>> entry : serviceConfigurations.entrySet()) { + Map<String, Map<String, ConfigProperty>> typeMap = entry.getValue(); + String serviceName = entry.getKey(); + if (typeMap.containsKey(config) && !getExcludedConfigurationTypes(serviceName).contains(config)) { + return serviceName; + } } - - //todo - public Map<String, String> getStackConfigurationProperties(String type) { - Map<String, String> configMap = new HashMap<>(); - Map<String, ConfigProperty> configProperties = stackConfigurations.get(type); - if (configProperties != null) { - for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) { - configMap.put(configProperty.getKey(), configProperty.getValue().getValue()); - } + throw new IllegalArgumentException( + "Specified configuration type is not associated with any service: " + config); + } + + /** + * Return the dependencies specified for the given component. + * + * @param component component to get dependency information for + * + * @return collection of dependency information for the specified component + */ + //todo: full dependency graph + public Collection<DependencyInfo> getDependenciesForComponent(String component) { + return dependencies.containsKey(component) ? dependencies.get(component) : + Collections.emptySet(); + } + + /** + * Get the service, if any, that a component dependency is conditional on. + * + * @param dependency dependency to get conditional service for + * + * @return conditional service for provided component or null if dependency + * is not conditional on a service + */ + public String getConditionalServiceForDependency(DependencyInfo dependency) { + return dependencyConditionalServiceMap.get(dependency); + } + + public String getExternalComponentConfig(String component) { + return dbDependencyInfo.get(component); + } + + /** + * Obtain the required cardinality for the specified component. + */ + public Cardinality getCardinality(String component) { + return new Cardinality(cardinalityRequirements.get(component)); + } + + /** + * Obtain auto-deploy information for the specified component. + */ + public AutoDeployInfo getAutoDeployInfo(String component) { + return componentAutoDeployInfo.get(component); + } + + public boolean isMasterComponent(String component) { + return masterComponents.contains(component); + } + + public Configuration getConfiguration(Collection<String> services) { + Map<String, Map<String, Map<String, String>>> attributes = new HashMap<>(); + Map<String, Map<String, String>> properties = new HashMap<>(); + + for (String service : services) { + Collection<String> serviceConfigTypes = getConfigurationTypes(service); + for (String type : serviceConfigTypes) { + Map<String, String> typeProps = getWithEmptyDefault(properties, type); + typeProps.putAll(getConfigurationProperties(service, type)); + + Map<String, Map<String, String>> stackTypeAttributes = getConfigurationAttributes(service, type); + if (!stackTypeAttributes.isEmpty()) { + if (! attributes.containsKey(type)) { + attributes.put(type, new HashMap<>()); + } + Map<String, Map<String, String>> typeAttributes = attributes.get(type); + for (Map.Entry<String, Map<String, String>> attribute : stackTypeAttributes.entrySet()) { + String attributeName = attribute.getKey(); + Map<String, String> attributeProps = getWithEmptyDefault(typeAttributes, attributeName); + attributeProps.putAll(attribute.getValue()); + } } - return configMap; - } - - public boolean isKerberosPrincipalNameProperty(String service, String type, String propertyName) { - return (serviceConfigurations.containsKey(service) && - serviceConfigurations.get(service).containsKey(type) && - serviceConfigurations.get(service).get(type).containsKey(propertyName) && - serviceConfigurations.get(service).get(type).get(propertyName).getPropertyTypes(). - contains(PropertyInfo.PropertyType.KERBEROS_PRINCIPAL)); + } } - /** - * Get config attributes for the specified service and configuration type. - * - * @param service service name - * @param type configuration type - * - * @return map of attribute names to map of property names to attribute values - * for the specified service and configuration type - */ - public Map<String, Map<String, String>> getConfigurationAttributes(String service, String type) { - Map<String, Map<String, String>> attributesMap = new HashMap<>(); - Map<String, ConfigProperty> configProperties = serviceConfigurations.get(service).get(type); - if (configProperties != null) { - for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) { - String propertyName = configProperty.getKey(); - Map<String, String> propertyAttributes = configProperty.getValue().getAttributes(); - if (propertyAttributes != null) { - for (Map.Entry<String, String> propertyAttribute : propertyAttributes.entrySet()) { - String attributeName = propertyAttribute.getKey(); - String attributeValue = propertyAttribute.getValue(); - if (attributeValue != null) { - Map<String, String> attributes = getWithEmptyDefault(attributesMap, attributeName); - attributes.put(propertyName, attributeValue); - } - } - } - } + return new Configuration(properties, attributes); + } + + public Configuration getConfiguration() { + Map<String, Map<String, Map<String, String>>> stackAttributes = new HashMap<>(); + Map<String, Map<String, String>> stackConfigs = new HashMap<>(); + + for (String service : getServices()) { + for (String type : getAllConfigurationTypes(service)) { + Map<String, String> typeProps = getWithEmptyDefault(stackConfigs, type); + typeProps.putAll(getConfigurationProperties(service, type)); + + Map<String, Map<String, String>> stackTypeAttributes = getConfigurationAttributes(service, type); + if (!stackTypeAttributes.isEmpty()) { + if (! stackAttributes.containsKey(type)) { + stackAttributes.put(type, new HashMap<>()); + } + Map<String, Map<String, String>> typeAttrs = stackAttributes.get(type); + for (Map.Entry<String, Map<String, String>> attribute : stackTypeAttributes.entrySet()) { + String attributeName = attribute.getKey(); + Map<String, String> attributes = getWithEmptyDefault(typeAttrs, attributeName); + attributes.putAll(attribute.getValue()); + } } - return attributesMap; + } } + return new Configuration(stackConfigs, stackAttributes); + } - //todo: - public Map<String, Map<String, String>> getStackConfigurationAttributes(String type) { - Map<String, Map<String, String>> attributesMap = new HashMap<>(); - Map<String, ConfigProperty> configProperties = stackConfigurations.get(type); - if (configProperties != null) { - for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) { - String propertyName = configProperty.getKey(); - Map<String, String> propertyAttributes = configProperty.getValue().getAttributes(); - if (propertyAttributes != null) { - for (Map.Entry<String, String> propertyAttribute : propertyAttributes.entrySet()) { - String attributeName = propertyAttribute.getKey(); - String attributeValue = propertyAttribute.getValue(); - Map<String, String> attributes = getWithEmptyDefault(attributesMap, attributeName); - attributes.put(propertyName, attributeValue); - } - } - } - } - return attributesMap; + static <OK, IK, IV> Map<IK, IV> getWithEmptyDefault(Map<OK, Map<IK, IV>> outerMap, OK outerKey) { + Map<IK, IV> innerMap = outerMap.get(outerKey); + if (null == innerMap) { + innerMap = new HashMap<>(); + outerMap.put(outerKey, innerMap); } + return innerMap; + } - /** - * Get the service for the specified component. - * - * @param component component name - * - * @return service name that contains tha specified component - */ - public String getServiceForComponent(String component) { - return componentService.get(component); - } - /** - * Get the names of the services which contains the specified components. - * - * @param components collection of components - * - * @return collection of services which contain the specified components - */ - public Collection<String> getServicesForComponents(Collection<String> components) { - Set<String> services = new HashSet<>(); - for (String component : components) { - services.add(getServiceForComponent(component)); - } + /** + * Contains a configuration property's value and attributes. + */ + public static class ConfigProperty { + private ValueAttributesInfo propertyValueAttributes = null; + private String name; + private String value; + private Map<String, String> attributes; + private Set<PropertyInfo.PropertyType> propertyTypes; + private String type; + private Set<PropertyDependencyInfo> dependsOnProperties = + Collections.emptySet(); - return services; + public ConfigProperty(ReadOnlyConfigurationResponse config) { + this.name = config.getPropertyName(); + this.value = config.getPropertyValue(); + this.attributes = config.getPropertyAttributes(); + this.propertyTypes = config.getPropertyType(); + this.type = normalizeType(config.getType()); + this.dependsOnProperties = config.getDependsOnProperties(); + this.propertyValueAttributes = config.getPropertyValueAttributes(); } - /** - * Obtain the service name which corresponds to the specified configuration. - * - * @param config configuration type - * - * @return name of service which corresponds to the specified configuration type - */ - public String getServiceForConfigType(String config) { - for (Map.Entry<String, Map<String, Map<String, ConfigProperty>>> entry : serviceConfigurations.entrySet()) { - Map<String, Map<String, ConfigProperty>> typeMap = entry.getValue(); - String serviceName = entry.getKey(); - if (typeMap.containsKey(config) && !getExcludedConfigurationTypes(serviceName).contains(config)) { - return serviceName; - } - } - throw new IllegalArgumentException( - "Specified configuration type is not associated with any service: " + config); + public ConfigProperty(String type, String name, String value) { + this.type = type; + this.name = name; + this.value = value; } - /** - * Return the dependencies specified for the given component. - * - * @param component component to get dependency information for - * - * @return collection of dependency information for the specified component - */ - //todo: full dependency graph - public Collection<DependencyInfo> getDependenciesForComponent(String component) { - return dependencies.containsKey(component) ? dependencies.get(component) : - Collections.emptySet(); + public String getName() { + return name; } - /** - * Get the service, if any, that a component dependency is conditional on. - * - * @param dependency dependency to get conditional service for - * - * @return conditional service for provided component or null if dependency - * is not conditional on a service - */ - public String getConditionalServiceForDependency(DependencyInfo dependency) { - return dependencyConditionalServiceMap.get(dependency); + public String getValue() { + return value; } - public String getExternalComponentConfig(String component) { - return dbDependencyInfo.get(component); + public void setValue(String value) { + this.value = value; } - /** - * Obtain the required cardinality for the specified component. - */ - public Cardinality getCardinality(String component) { - return new Cardinality(cardinalityRequirements.get(component)); + public String getType() { + return type; } - /** - * Obtain auto-deploy information for the specified component. - */ - public AutoDeployInfo getAutoDeployInfo(String component) { - return componentAutoDeployInfo.get(component); + public Set<PropertyInfo.PropertyType> getPropertyTypes() { + return propertyTypes; } - public boolean isMasterComponent(String component) { - return masterComponents.contains(component); + public void setPropertyTypes(Set<PropertyInfo.PropertyType> propertyTypes) { + this.propertyTypes = propertyTypes; } - public Configuration getConfiguration(Collection<String> services) { - Map<String, Map<String, Map<String, String>>> attributes = new HashMap<>(); - Map<String, Map<String, String>> properties = new HashMap<>(); - - for (String service : services) { - Collection<String> serviceConfigTypes = getConfigurationTypes(service); - for (String type : serviceConfigTypes) { - Map<String, String> typeProps = getWithEmptyDefault(properties, type); - typeProps.putAll(getConfigurationProperties(service, type)); - - Map<String, Map<String, String>> stackTypeAttributes = getConfigurationAttributes(service, type); - if (!stackTypeAttributes.isEmpty()) { - if (! attributes.containsKey(type)) { - attributes.put(type, new HashMap<>()); - } - Map<String, Map<String, String>> typeAttributes = attributes.get(type); - for (Map.Entry<String, Map<String, String>> attribute : stackTypeAttributes.entrySet()) { - String attributeName = attribute.getKey(); - Map<String, String> attributeProps = getWithEmptyDefault(typeAttributes, attributeName); - attributeProps.putAll(attribute.getValue()); - } - } - } - } - return new Configuration(properties, attributes); + public Map<String, String> getAttributes() { + return attributes; } - public Configuration getConfiguration() { - Map<String, Map<String, Map<String, String>>> stackAttributes = new HashMap<>(); - Map<String, Map<String, String>> stackConfigs = new HashMap<>(); - - for (String service : getServices()) { - for (String type : getAllConfigurationTypes(service)) { - Map<String, String> typeProps = getWithEmptyDefault(stackConfigs, type); - typeProps.putAll(getConfigurationProperties(service, type)); - - Map<String, Map<String, String>> stackTypeAttributes = getConfigurationAttributes(service, type); - if (!stackTypeAttributes.isEmpty()) { - if (! stackAttributes.containsKey(type)) { - stackAttributes.put(type, new HashMap<>()); - } - Map<String, Map<String, String>> typeAttrs = stackAttributes.get(type); - for (Map.Entry<String, Map<String, String>> attribute : stackTypeAttributes.entrySet()) { - String attributeName = attribute.getKey(); - Map<String, String> attributes = getWithEmptyDefault(typeAttrs, attributeName); - attributes.putAll(attribute.getValue()); - } - } - } - } - return new Configuration(stackConfigs, stackAttributes); + public void setAttributes(Map<String, String> attributes) { + this.attributes = attributes; } - static <OK, IK, IV> Map<IK, IV> getWithEmptyDefault(Map<OK, Map<IK, IV>> outerMap, OK outerKey) { - Map<IK, IV> innerMap = outerMap.get(outerKey); - if (null == innerMap) { - innerMap = new HashMap<>(); - outerMap.put(outerKey, innerMap); - } - return innerMap; + public Set<PropertyDependencyInfo> getDependsOnProperties() { + return this.dependsOnProperties; } + private String normalizeType(String type) { + //strip .xml from type + if (type.endsWith(".xml")) { + type = type.substring(0, type.length() - 4); + } + return type; + } - /** - * Contains a configuration property's value and attributes. - */ - public static class ConfigProperty { - private ValueAttributesInfo propertyValueAttributes = null; - private String name; - private String value; - private Map<String, String> attributes; - private Set<PropertyInfo.PropertyType> propertyTypes; - private String type; - private Set<PropertyDependencyInfo> dependsOnProperties = - Collections.emptySet(); - - public ConfigProperty(ReadOnlyConfigurationResponse config) { - this.name = config.getPropertyName(); - this.value = config.getPropertyValue(); - this.attributes = config.getPropertyAttributes(); - this.propertyTypes = config.getPropertyType(); - this.type = normalizeType(config.getType()); - this.dependsOnProperties = config.getDependsOnProperties(); - this.propertyValueAttributes = config.getPropertyValueAttributes(); - } - - public ConfigProperty(String type, String name, String value) { - this.type = type; - this.name = name; - this.value = value; - } - - public String getName() { - return name; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public String getType() { - return type; - } - - public Set<PropertyInfo.PropertyType> getPropertyTypes() { - return propertyTypes; - } - - public void setPropertyTypes(Set<PropertyInfo.PropertyType> propertyTypes) { - this.propertyTypes = propertyTypes; - } - - public Map<String, String> getAttributes() { - return attributes; - } - - public void setAttributes(Map<String, String> attributes) { - this.attributes = attributes; - } - - public Set<PropertyDependencyInfo> getDependsOnProperties() { - return this.dependsOnProperties; - } - - private String normalizeType(String type) { - //strip .xml from type - if (type.endsWith(".xml")) { - type = type.substring(0, type.length() - 4); - } - return type; - } - - public ValueAttributesInfo getPropertyValueAttributes() { - return propertyValueAttributes; - } + public ValueAttributesInfo getPropertyValueAttributes() { + return propertyValueAttributes; } + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java index 4b7dd32..044e78a 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java @@ -19,13 +19,16 @@ package org.apache.ambari.server.topology; +import static java.util.stream.Collectors.toList; +import static java.util.stream.Collectors.toMap; +import static java.util.stream.Collectors.toSet; + import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; -import java.util.stream.Collectors; import javax.annotation.Nonnull; @@ -33,7 +36,6 @@ import org.apache.ambari.server.controller.StackV2; import org.apache.ambari.server.orm.entities.BlueprintEntity; import org.apache.ambari.server.state.ConfigHelper; import org.apache.ambari.server.state.StackId; -import org.apache.commons.lang.StringUtils; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; @@ -46,14 +48,13 @@ public class BlueprintImplV2 implements BlueprintV2 { private String name; private SecurityConfiguration securityConfiguration; private Collection<RepositoryVersion> repositoryVersions; - private Collection<ServiceGroup> serviceGroups; - private Collection<? extends HostGroupV2> hostGroups; + private Map<String, ServiceGroup> serviceGroups; private Setting setting; + private Configuration configuration; // Transient fields @JsonIgnore - private Map<String, HostGroupV2> hostGroupMap = new HashMap<>(); - + private Map<String, HostGroupV2Impl> hostGroupMap = new HashMap<>(); @JsonIgnore private Map<StackId, StackV2> stacks; @@ -61,8 +62,12 @@ public class BlueprintImplV2 implements BlueprintV2 { @JsonIgnore private List<RepositorySetting> repoSettings; + @JsonIgnore + private Map<ServiceId, Service> services = new HashMap<>(); + public void setStacks(Map<StackId, StackV2> stacks) { this.stacks = stacks; + getAllServices().stream().forEach(s -> s.setStackFromBlueprint(this)); } @JsonProperty("Blueprints") @@ -86,13 +91,12 @@ public class BlueprintImplV2 implements BlueprintV2 { @JsonProperty("service_groups") public void setServiceGroups(Collection<ServiceGroup> serviceGroups) { - this.serviceGroups = serviceGroups; + this.serviceGroups = serviceGroups.stream().collect(toMap( sg -> sg.getName(), sg -> sg )); } @JsonProperty("host_groups") public void setHostGroups(Collection<HostGroupV2Impl> hostGroups) { - this.hostGroups = hostGroups; - this.hostGroupMap = hostGroups.stream().collect(Collectors.toMap( + this.hostGroupMap = hostGroups.stream().collect(toMap( hg -> hg.getName(), hg -> hg )); @@ -114,7 +118,8 @@ public class BlueprintImplV2 implements BlueprintV2 { } @Override - public Map<String, HostGroupV2> getHostGroups() { + @JsonProperty("host_groups") + public Map<String, ? extends HostGroupV2> getHostGroups() { return hostGroupMap; } @@ -125,18 +130,23 @@ public class BlueprintImplV2 implements BlueprintV2 { @Override public Collection<String> getStackIds() { - return repositoryVersions.stream().map(rv -> rv.getStackId()).collect(Collectors.toList()); + return repositoryVersions.stream().map(rv -> rv.getStackId()).collect(toList()); } @Override public Collection<ServiceGroup> getServiceGroups() { - return serviceGroups; + return serviceGroups.values(); + } + + @Override + public ServiceGroup getServiceGroup(String name) { + return serviceGroups.get(name); } @Override @JsonIgnore public Collection<ServiceId> getAllServiceIds() { - return hostGroups.stream().flatMap(hg -> hg.getServiceIds().stream()).collect(Collectors.toSet()); + return getHostGroups().values().stream().flatMap(hg -> hg.getServiceIds().stream()).collect(toSet()); } @Override @@ -146,70 +156,90 @@ public class BlueprintImplV2 implements BlueprintV2 { return serviceGroup.getServices(); } else { return serviceGroup.getServices().stream().filter( - service -> service.getType().equalsIgnoreCase(serviceType)).collect(Collectors.toList()); + service -> service.getType().equalsIgnoreCase(serviceType)).collect(toList()); } } @Override @JsonIgnore public StackV2 getStackById(String stackId) { - return null; + return stacks.get(new StackId(stackId)); } @Override @JsonIgnore public Collection<Service> getAllServices() { - return null; + return services.values(); + } + + @Override + @JsonIgnore + public Service getService(ServiceId serviceId) { + return services.get(serviceId); } @Override @JsonIgnore public Collection<String> getAllServiceTypes() { - return null; + return getServiceGroups().stream().flatMap(sg -> sg.getServices().stream()).map(s -> s.getType()).collect(toSet()); } @Override @JsonIgnore public Collection<Service> getServicesByType(String serviceType) { - return null; -// getAllServices().stream().filter( -// service -> service.getType().equalsIgnoreCase(serviceType)).collect(Collectors.toList()); + return serviceGroups.values().stream().flatMap(sg -> sg.getServiceByType(serviceType).stream()).collect(toList()); } @Override @JsonIgnore public Collection<ComponentV2> getComponents(Service service) { - return null; + return getHostGroupsForService(service.getId()).stream().flatMap( + hg -> hg.getComponents().stream()). + collect(toList()); } @Override @JsonIgnore public Collection<ComponentV2> getComponentsByType(Service service, String componentType) { return getComponents(service).stream().filter( - compnoent -> compnoent.getType().equalsIgnoreCase(componentType)).collect(Collectors.toList()); + compnoent -> compnoent.getType().equalsIgnoreCase(componentType)).collect(toList()); } @Override @JsonIgnore public Collection<ComponentV2> getComponents(ServiceId serviceId) { - return getHostGroupsForService(serviceId).stream().flatMap(hg -> hg.getComponents().stream()).collect(Collectors.toSet()); + return getHostGroupsForService(serviceId).stream().flatMap(hg -> hg.getComponents().stream()).collect(toSet()); } @Override @JsonIgnore public Collection<HostGroupV2> getHostGroupsForService(ServiceId serviceId) { - return hostGroups.stream().filter(hg -> !hg.getComponentsByServiceId(serviceId).isEmpty()).collect(Collectors.toList()); + return getHostGroups().values().stream().filter(hg -> !hg.getComponentsByServiceId(serviceId).isEmpty()).collect(toList()); } @Override @JsonIgnore public Collection<HostGroupV2> getHostGroupsForComponent(ComponentV2 component) { - return hostGroups.stream().filter(hg -> hg.getComponents().contains(component)).collect(Collectors.toList()); + return hostGroupMap.values().stream().filter(hg -> hg.getComponents().contains(component)).collect(toList()); } @Override + @JsonIgnore public Configuration getConfiguration() { - return null; + if (null == configuration) { + configuration = new Configuration(new HashMap<>(), new HashMap<>()); + getServiceGroups().stream().forEach( sg -> addChildConfiguration(configuration, sg.getConfiguration()) ); + getHostGroups().values().stream().forEach( + hg -> hg.getComponents().stream().forEach( + c -> addChildConfiguration(configuration, c.getConfiguration()))); + } + return configuration; + } + + private void addChildConfiguration(Configuration parent, Configuration child) { + child.setParentConfiguration(parent); + parent.getProperties().putAll(child.getProperties()); + parent.getAttributes().putAll(child.getAttributes()); } @Override @@ -217,86 +247,54 @@ public class BlueprintImplV2 implements BlueprintV2 { return this.setting; } - - @Nonnull @Override @JsonIgnore public Collection<String> getAllServiceNames() { - return getAllServices().stream().map(s -> s.getName()).collect(Collectors.toList()); + return getAllServices().stream().map(s -> s.getName()).collect(toList()); } @Nonnull @Override public Collection<String> getComponentNames(ServiceId serviceId) { - return getComponents(serviceId).stream().map(c -> c.getName()).collect(Collectors.toList()); + return getComponents(serviceId).stream().map(c -> c.getName()).collect(toList()); } @Override public String getRecoveryEnabled(ComponentV2 component) { - return null; - } - - public String getRecoveryEnabled(String serviceName, String componentName) { - // If component name was specified in the list of "component_settings", - // determine if recovery_enabled is true or false and return it. - Optional<String> recoveryEnabled = getSettingValue(Setting.SETTING_NAME_COMPONENT_SETTINGS, - Setting.SETTING_NAME_RECOVERY_ENABLED, - Optional.of(componentName)); - if (recoveryEnabled.isPresent()) { - return recoveryEnabled.get(); - } - - // If component name was specified in the list of "component_settings", - // determine if recovery_enabled is true or false and return it. - recoveryEnabled = getSettingValue(Setting.SETTING_NAME_SERVICE_SETTINGS, - Setting.SETTING_NAME_RECOVERY_ENABLED, - Optional.of(serviceName)); - if (recoveryEnabled.isPresent()) { - return recoveryEnabled.get(); - } - - // If service name is not specified, look up the cluster setting. - recoveryEnabled = getSettingValue(Setting.SETTING_NAME_RECOVERY_SETTINGS, - Setting.SETTING_NAME_RECOVERY_ENABLED, - Optional.empty()); - if (recoveryEnabled.isPresent()) { - return recoveryEnabled.get(); - } - - return null; - } - - private Optional<String> getSettingValue(String settingCategory, String settingName, Optional<String> nameFilter) { - if (this.setting != null) { - Set<HashMap<String, String>> settingValue = this.setting.getSettingValue(settingCategory); - for (Map<String, String> setting : settingValue) { - String name = setting.get(Setting.SETTING_NAME_NAME); - if (!nameFilter.isPresent() || StringUtils.equals(name, nameFilter.get())) { - String value = setting.get(settingName); - if (!StringUtils.isEmpty(value)) { - return Optional.of(value); - } - } - } - } - return Optional.empty(); - } + Optional<String> value = + setting.getSettingValue(Setting.SETTING_NAME_RECOVERY_SETTINGS, Setting.SETTING_NAME_RECOVERY_ENABLED); + // TODO: handle service and component level settings + return value.orElse(null); + } + +// private Optional<String> getSettingValue(String settingCategory, String settingName, Optional<String> nameFilter) { +// if (this.setting != null) { +// Set<HashMap<String, String>> settingValue = this.setting.getSettingValue(settingCategory); +// for (Map<String, String> setting : settingValue) { +// String name = setting.get(Setting.SETTING_NAME_NAME); +// if (!nameFilter.isPresent() || StringUtils.equals(name, nameFilter.get())) { +// String value = setting.get(settingName); +// if (!StringUtils.isEmpty(value)) { +// return Optional.of(value); +// } +// } +// } +// } +// return Optional.empty(); +// } @Override public String getCredentialStoreEnabled(String serviceName) { - // Look up the service and return the credential_store_enabled value. - Optional<String> credentialStoreEnabled = getSettingValue(Setting.SETTING_NAME_SERVICE_SETTINGS, - Setting.SETTING_NAME_CREDENTIAL_STORE_ENABLED, - Optional.of(serviceName)); - return credentialStoreEnabled.isPresent() ? credentialStoreEnabled.get() : null; + // TODO: this is a service level level setting, handle appropriately + return null; } @Override public boolean shouldSkipFailure() { - Optional<String> shouldSkipFailure = getSettingValue(Setting.SETTING_NAME_DEPLOYMENT_SETTINGS, - Setting.SETTING_NAME_SKIP_FAILURE, - Optional.empty()); + Optional<String> shouldSkipFailure = setting.getSettingValue( + Setting.SETTING_NAME_DEPLOYMENT_SETTINGS, + Setting.SETTING_NAME_SKIP_FAILURE); return shouldSkipFailure.isPresent() ? shouldSkipFailure.get().equalsIgnoreCase("true") : false; } @@ -312,7 +310,7 @@ public class BlueprintImplV2 implements BlueprintV2 { return true; } final Set<String> serviceNames = - getAllServices().stream().map(s -> s.getName()).collect(Collectors.toSet()); + getAllServices().stream().map(s -> s.getName()).collect(toSet()); return getStacks().stream().anyMatch( stack -> { String service = stack.getServiceForConfigType(configType); @@ -321,9 +319,46 @@ public class BlueprintImplV2 implements BlueprintV2 { ); } + public void postDeserialization() { + // Maintain a ServiceId -> Service map + this.services = getAllServiceIds().stream().collect(toMap( + serviceId -> serviceId, + serviceId -> { + ServiceGroup sg = getServiceGroup(serviceId.getServiceGroup()); + Service service = null != sg ? sg.getServiceByName(serviceId.getName()) : null; + if (null == service) { + throw new IllegalStateException("Cannot find service for service id: " + serviceId); + } + return service; + } + )); + + // Set Service -> ServiceGroup references and Service -> Service dependencies + getAllServices().stream().forEach( s -> { + s.setServiceGroup(serviceGroups.get(s.getServiceGroupId())); + Map<ServiceId, Service> dependencies = s.getDependentServiceIds().stream().collect(toMap( + serviceId -> serviceId, + serviceId -> getService(serviceId) + )); + s.setDependencyMap(dependencies); + }); + + + // Set HostGroup -> Services and Component -> Service references + for (HostGroupV2Impl hg: hostGroupMap.values()) { + hg.setServiceMap(hg.getServiceIds().stream().collect(toMap( + serviceId -> serviceId, + serviceId -> this.services.get(serviceId) + ))); + for (ComponentV2 comp: hg.getComponents()) { + comp.setService(hg.getService(comp.getServiceId())); + } + } + } + @Override public BlueprintEntity toEntity() { - throw new UnsupportedOperationException("This is not supported here and will be removed. Pls. use BlueprintConverter"); + throw new UnsupportedOperationException("This is not supported here and will be removed. Pls. use BlueprintV2Factory"); } @Override http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java index 29539db..b5d5430 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java @@ -53,7 +53,7 @@ public interface BlueprintV2 { * Get the hot groups contained in the blueprint. * @return map of host group name to host group */ - Map<String, HostGroupV2> getHostGroups(); + Map<String, ? extends HostGroupV2> getHostGroups(); /** * Get stacks associated with the blueprint. @@ -71,6 +71,8 @@ public interface BlueprintV2 { Collection<ServiceGroup> getServiceGroups(); + ServiceGroup getServiceGroup(String name); + /** * Get all of the services represented in the blueprint. * @@ -78,7 +80,7 @@ public interface BlueprintV2 { */ Collection<ServiceId> getAllServiceIds(); - ;Collection<Service> getAllServices(); + Collection<Service> getAllServices(); /** * Get the names of all the services represented in the blueprint. @@ -104,6 +106,8 @@ public interface BlueprintV2 { */ Collection<Service> getServicesByType(String serviceType); + Service getService(ServiceId serviceId); + /** * Get services by type from a service group. * @param serviceGroup http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java index a8c5b4c..3b656e2 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java @@ -87,6 +87,7 @@ public class BlueprintV2Factory { public BlueprintV2 convertFromEntity(BlueprintV2Entity blueprintEntity) throws NoSuchStackException, IOException { BlueprintImplV2 blueprintV2 = createObjectMapper().readValue(blueprintEntity.getContent(), BlueprintImplV2.class); + blueprintV2.postDeserialization(); Map<StackId, StackV2> stacks = new HashMap<>(); for (String stackIdString: blueprintV2.getStackIds()) { StackId stackId = new StackId(stackIdString); @@ -126,6 +127,7 @@ public class BlueprintV2Factory { ObjectMapper om = createObjectMapper(); String json = om.writeValueAsString(properties); BlueprintImplV2 blueprint = om.readValue(json, BlueprintImplV2.class); + blueprint.postDeserialization(); Map<String, StackV2> stacks = new HashMap<>(); for (String stackId: blueprint.getStackIds()) { stacks.put(stackId, stackFactory.create(stackId)); http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java index e59b1f9..68744d4 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java @@ -38,6 +38,9 @@ public class ComponentV2 implements Configurable { private boolean masterComponent = false; + @JsonIgnore + private Service service; + public ComponentV2() { } @@ -69,9 +72,8 @@ public class ComponentV2 implements Configurable { return serviceId; } - //TODO public Service getService() { - return null; + return service; } //TODO @@ -130,4 +132,7 @@ public class ComponentV2 implements Configurable { this.masterComponent = stack.isMasterComponent(this.type); } + public void setService(Service service) { + this.service = service; + } } http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java index 4745f59..8da24bd 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java @@ -104,10 +104,12 @@ public interface HostGroupV2 { Collection<ServiceId> getServiceIds(); /** - * @return collection of service ids associated with the host group components. + * @return collection of services associated with the host group components. */ Collection<Service> getServices(); + Service getService(ServiceId serviceId); + /** * @return collection of service names associated with the host group components. */ @@ -124,11 +126,6 @@ public interface HostGroupV2 { Configuration getConfiguration(); /** - * List of services - */ - Collection<Service> getServiceConfigs(); - - /** * Get the cardinality value that was specified for the host group. * This is simply meta-data for the stack that a deployer can use * and this information is not used by ambari. http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java index ca19df3..2c9d1dd 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java @@ -19,6 +19,7 @@ package org.apache.ambari.server.topology; import java.util.Collection; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; import javax.annotation.Nullable; @@ -27,9 +28,11 @@ import org.apache.ambari.server.controller.internal.ProvisionAction; import com.fasterxml.jackson.annotation.JsonIgnore; import com.google.common.base.Function; +import com.google.common.base.Preconditions; import com.google.common.base.Predicates; import com.google.common.collect.Collections2; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; public class HostGroupV2Impl implements HostGroupV2, Configurable { @@ -37,10 +40,12 @@ public class HostGroupV2Impl implements HostGroupV2, Configurable { private String name; private String blueprintName; private List<ComponentV2> components; - private List<ServiceId> services; + private List<ServiceId> serviceIds; private Configuration configuration; private String cardinality; private boolean containsMasterComponent; + @JsonIgnore + private Map<ServiceId, Service> serviceMap; public HostGroupV2Impl() { } @@ -84,8 +89,8 @@ public class HostGroupV2Impl implements HostGroupV2, Configurable { } @Override - public Collection<ComponentV2> getComponents(Service serviceId) { - return null; + public Collection<ComponentV2> getComponents(Service service) { + return getComponentsByServiceId(service.getId()); } @Override @@ -100,29 +105,37 @@ public class HostGroupV2Impl implements HostGroupV2, Configurable { @Override public Collection<ServiceId> getServiceIds() { - return services; + return serviceIds; } @Override @JsonIgnore public Collection<Service> getServices() { - return null; + return serviceMap.values(); } @Override @JsonIgnore - public Collection<String> getServiceNames() { - return services.stream().map(s -> s.getName()).collect(Collectors.toList()); + public Service getService(ServiceId serviceId) { + return serviceMap.get(serviceId); } @Override - public Configuration getConfiguration() { - return configuration; + @JsonIgnore + public Collection<String> getServiceNames() { + return serviceMap.values().stream().map(s -> s.getName()).collect(Collectors.toList()); + } + + @JsonIgnore + public void setServiceMap(Map<ServiceId, Service> serviceMap) { + Preconditions.checkArgument(serviceMap.keySet().equals(ImmutableSet.copyOf(this.serviceIds)), + "Maitained list of service ids doesn't match with received service map: %s vs %s", serviceIds, serviceMap.keySet()); + this.serviceMap = serviceMap; } @Override - public Collection<Service> getServiceConfigs() { - return null; + public Configuration getConfiguration() { + return configuration; } @Override @@ -141,7 +154,7 @@ public class HostGroupV2Impl implements HostGroupV2, Configurable { public void setComponents(List<ComponentV2> components) { this.components = components; this.containsMasterComponent = components.stream().anyMatch(c -> c.isMasterComponent()); - this.services = components.stream().map(c -> c.getServiceId()).collect(Collectors.toList()); + this.serviceIds = components.stream().map(c -> c.getServiceId()).collect(Collectors.toList()); } public void setConfiguration(Configuration configuration) { http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java index 81f235c..46c75c5 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java @@ -19,11 +19,17 @@ package org.apache.ambari.server.topology; +import java.util.Map; import java.util.Set; import org.apache.ambari.server.controller.StackV2; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; + public class Service implements Configurable { @@ -35,7 +41,16 @@ public class Service implements Configurable { private Configuration configuration; - private Set<ServiceId> dependencies; + private Set<ServiceId> dependencies = ImmutableSet.of(); + + @JsonIgnore + private Map<ServiceId, Service> dependencyMap = ImmutableMap.of(); + + @JsonIgnore + private ServiceGroup serviceGroup; + + @JsonIgnore + private StackV2 stack; /** * Gets the name of this service @@ -50,9 +65,8 @@ public class Service implements Configurable { return this.id.getServiceGroup(); } - //TODO public ServiceGroup getServiceGroup() { - return null; + return serviceGroup; } public String getType() { @@ -63,35 +77,36 @@ public class Service implements Configurable { return stackId; } - //TODO public StackV2 getStack() { - return null; + return stack; } public Set<ServiceId> getDependentServiceIds() { return dependencies; } - //TODO public Set<Service> getDependencies() { - return null; + return ImmutableSet.copyOf(dependencyMap.values()); } public Configuration getConfiguration() { return configuration; } - public void setType(String type) { this.type = type; + if (null == this.getName()) { + setName(type); + } } public void setName(String name) { this.id.setName(name); } - public void setServiceGroup(String serviceGroup) { - this.id.setServiceGroup(serviceGroup); + public void setServiceGroup(ServiceGroup serviceGroup) { + this.serviceGroup = serviceGroup; + this.id.setServiceGroup(serviceGroup.getName()); } @JsonProperty("stack_id") @@ -99,6 +114,10 @@ public class Service implements Configurable { this.stackId = stackId; } + public void setStackFromBlueprint(BlueprintV2 blueprint) { + this.stack = blueprint.getStackById(this.stackId); + } + public void setConfiguration(Configuration configuration) { this.configuration = configuration; } @@ -107,8 +126,27 @@ public class Service implements Configurable { this.dependencies = dependencies; } + /** + * Called during post-deserialization + * @param dependencyMap + */ + void setDependencyMap(Map<ServiceId, Service> dependencyMap) { + Preconditions.checkArgument(dependencyMap.keySet().equals(dependencies), + "Received dependency map is not consisted with persisted dependency references: %s vs. %s", + dependencyMap.keySet(), dependencies); + this.dependencyMap = dependencyMap; + } + public ServiceId getId() { return id; } + @Override + public String toString() { + return "Service{" + + "type='" + type + '\'' + + ", id=" + id + + ", stackId='" + stackId + '\'' + + '}'; + } } http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceGroup.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceGroup.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceGroup.java index 13967c0..7f38b2c 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceGroup.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceGroup.java @@ -18,17 +18,22 @@ package org.apache.ambari.server.topology; - -import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; +import java.util.List; +import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; + +import com.google.common.collect.ListMultimap; +import com.google.common.collect.Multimaps; public class ServiceGroup { private String name = null; - private Collection<Service> services = new ArrayList<>(); + private Map<String, Service> servicesByName; + private ListMultimap<String, Service> servicesByType; private Configuration configuration = null; @@ -46,7 +51,15 @@ public class ServiceGroup { } public Collection<Service> getServices() { - return services; + return servicesByName.values(); + } + + public Service getServiceByName(String name) { + return servicesByName.get(name); + } + + public List<Service> getServiceByType(String name) { + return servicesByType.get(name); } public Configuration getConfiguration() { @@ -57,14 +70,15 @@ public class ServiceGroup { return dependencies; } - public void setName(String name) { this.name = name; } public void setServices(Collection<Service> services) { - this.services = services; - services.forEach(s -> s.setServiceGroup(this.name)); + services.forEach(s -> s.setServiceGroup(this)); + this.servicesByName = services.stream().collect(Collectors.toMap(Service::getName, s -> s)); + this.servicesByType = Multimaps.index(services, Service::getType); + services.forEach(s -> s.setServiceGroup(this)); } public void setConfiguration(Configuration configuration) { http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceId.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceId.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceId.java index 669e031..2d81a07 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceId.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceId.java @@ -23,6 +23,8 @@ public class ServiceId { private String serviceGroup; private String name; + public ServiceId() { } + public static ServiceId of(String name, String serviceGroup) { ServiceId id = new ServiceId(); id.name = name; @@ -66,4 +68,12 @@ public class ServiceId { result = 31 * result + (name != null ? name.hashCode() : 0); return result; } + + @Override + public String toString() { + return "ServiceId{" + + "serviceGroup='" + serviceGroup + '\'' + + ", name='" + name + '\'' + + '}'; + } } http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/topology/Setting.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/Setting.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/Setting.java index 904c784..34542e1 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/Setting.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Setting.java @@ -20,8 +20,14 @@ package org.apache.ambari.server.topology; import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.Objects; +import java.util.Optional; import java.util.Set; +import java.util.stream.Collectors; + +import com.google.common.base.Preconditions; public class Setting { /** @@ -95,7 +101,17 @@ public class Setting { if (properties.containsKey(settingName)) { return properties.get(settingName); } - return Collections.emptySet(); } + + public Optional<String> getSettingValue(String settingCategory, String propertyName) { + List<String> values = getSettingValue(settingCategory).stream(). + flatMap(sv -> sv.entrySet().stream()). + filter(entry -> Objects.equals(entry.getKey(), propertyName)). + map(entry -> entry.getValue()). + collect(Collectors.toList()); + Preconditions.checkState(values.size() < 2, "Ambigous settings (%s) for category %s, property %s", + values.size(), settingCategory, settingCategory); + return values.isEmpty() ? Optional.empty() : Optional.of(values.get(0)); + } } http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java index 6b98b77..3bcf31b 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java @@ -20,6 +20,8 @@ package org.apache.ambari.server.topology.validators; import java.util.HashMap; import java.util.Map; +import org.apache.ambari.server.controller.StackV2; +import org.apache.ambari.server.state.StackId; import org.apache.ambari.server.topology.BlueprintImplV2; import org.apache.ambari.server.topology.HostGroupV2; import org.apache.ambari.server.topology.HostGroupV2Impl; @@ -32,6 +34,7 @@ import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.module.SimpleAbstractTypeResolver; import com.fasterxml.jackson.databind.module.SimpleModule; import com.google.common.base.Charsets; +import com.google.common.collect.ImmutableMap; import com.google.common.io.Resources; public class BlueprintImplV2Test { @@ -53,6 +56,14 @@ public class BlueprintImplV2Test { mapper.registerModule(module); mapper.enable(SerializationFeature.INDENT_OUTPUT); BlueprintImplV2 bp = mapper.readValue(BLUEPRINT_V2_JSON, BlueprintImplV2.class); + bp.postDeserialization(); + // -- add stack -- + StackV2 hdpCore = new StackV2("HDPCORE", "3.0.0", "3.0.0.0-1", new HashMap<>(), new HashMap<>(), new HashMap<>(), + new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>()); + StackV2 analytics = new StackV2("ANALYTICS", "1.0.0", "1.0.0.0-1", new HashMap<>(), new HashMap<>(), new HashMap<>(), + new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>()); + bp.setStacks(ImmutableMap.of(new StackId("HDPCORE", "3.0.0"), hdpCore, new StackId("ANALYTICS", "1.0.0"), analytics)); + // --------------- String bpJson = mapper.writeValueAsString(bp); System.out.println(bpJson); System.out.println("\n\n====================================================================================\n\n"); http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/test/resources/blueprintv2/blueprintv2.json ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/resources/blueprintv2/blueprintv2.json b/ambari-server/src/test/resources/blueprintv2/blueprintv2.json index 7884abf..b6b4e8d 100644 --- a/ambari-server/src/test/resources/blueprintv2/blueprintv2.json +++ b/ambari-server/src/test/resources/blueprintv2/blueprintv2.json @@ -25,7 +25,7 @@ ], "service_groups": [ { - "name": "Core SG", + "name": "CoreSG", "dependencies": [], "services": [ { @@ -88,7 +88,7 @@ "stack_id": "HDPCORE-3.0.0" } ], - "dependencies": ["Core SG"] + "dependencies": ["CoreSG"] } ], "host_groups": [ @@ -100,50 +100,44 @@ { "type": "NAMENODE", "service_name": "HDFS", - "service_group": "Core SG", + "service_group": "CoreSG", "configurations": [], "provision_action": "INSTALL_AND_START" }, { "type": "ZOOKEEPER_SERVER", "service_name": "ZK1", - "service_group": "Core SG", + "service_group": "CoreSG", "configurations": [] }, { "type": "ZOOKEEPER_SERVER", "service_name": "ZK2", - "service_group": "Core SG", + "service_group": "CoreSG", "configurations": [] }, { "type": "RESOURCEMANAGER", "service_name": "YARN", - "service_group": "Core SG", + "service_group": "CoreSG", "configurations": [] }, { "type": "HBASE_MASTER", "service_name": "HBASE", - "service_group": "Core SG", - "configurations": [] - }, - { - "type": "ZOOKEEPER_SERVER", - "service_name": "ZOOKEEPER", - "service_group": "Stream SG", + "service_group": "CoreSG", "configurations": [] }, { "type": "KAFKA_MASTER", "service_name": "KAFKA", - "service_group": "Stream SG", + "service_group": "StreamSG", "configurations": [] }, { "type": "NIFI_MASTER", "service_name": "NIFI", - "service_group": "Stream SG", + "service_group": "StreamSG", "configurations": [] } ]
