Repository: ambari Updated Branches: refs/heads/trunk fa5447474 -> 64c9ef8a5
AMBARI-20818. Blueprint processor fails when StackAdvisor recommends unnecessary configuration types (magyari_sandor) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/64c9ef8a Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/64c9ef8a Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/64c9ef8a Branch: refs/heads/trunk Commit: 64c9ef8a58717f00251e57ebc61870b39d63c692 Parents: fa54474 Author: Sandor Magyari <[email protected]> Authored: Fri Apr 21 18:50:38 2017 +0200 Committer: Sandor Magyari <[email protected]> Committed: Tue Apr 25 13:38:32 2017 +0200 ---------------------------------------------------------------------- .../StackAdvisorBlueprintProcessor.java | 14 +++- .../BlueprintConfigurationProcessor.java | 87 ++++++++++---------- .../ambari/server/topology/Blueprint.java | 8 ++ .../ambari/server/topology/BlueprintImpl.java | 15 ++++ .../topology/ClusterConfigurationRequest.java | 59 +++++-------- .../StackAdvisorBlueprintProcessorTest.java | 4 + .../BlueprintConfigurationProcessorTest.java | 4 + .../ClusterConfigurationRequestTest.java | 18 ++-- .../ClusterDeployWithStartOnlyTest.java | 1 + ...InstallWithoutStartOnComponentLevelTest.java | 1 + .../ClusterInstallWithoutStartTest.java | 1 + 11 files changed, 119 insertions(+), 93 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/64c9ef8a/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 d306e25..7731b22 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 @@ -32,6 +32,7 @@ import org.apache.ambari.server.controller.internal.ConfigurationTopologyExcepti import org.apache.ambari.server.controller.internal.Stack; import org.apache.ambari.server.state.ValueAttributesInfo; import org.apache.ambari.server.topology.AdvisedConfiguration; +import org.apache.ambari.server.topology.Blueprint; import org.apache.ambari.server.topology.ClusterTopology; import org.apache.ambari.server.topology.ConfigRecommendationStrategy; import org.apache.ambari.server.topology.HostGroup; @@ -175,12 +176,17 @@ public class StackAdvisorBlueprintProcessor { Map<String, BlueprintConfigurations> recommendedConfigurations = response.getRecommendations().getBlueprint().getConfigurations(); + Blueprint blueprint = topology.getBlueprint(); + for (Map.Entry<String, BlueprintConfigurations> configEntry : recommendedConfigurations.entrySet()) { String configType = configEntry.getKey(); - BlueprintConfigurations blueprintConfig = filterBlueprintConfig(configType, configEntry.getValue(), - userProvidedConfigurations, topology); - topology.getAdvisedConfigurations().put(configType, new AdvisedConfiguration( - blueprintConfig.getProperties(), blueprintConfig.getPropertyAttributes())); + // add recommended config type only if related service is present in Blueprint + if (blueprint.isValidConfigType(configType)) { + BlueprintConfigurations blueprintConfig = filterBlueprintConfig(configType, configEntry.getValue(), + userProvidedConfigurations, topology); + topology.getAdvisedConfigurations().put(configType, new AdvisedConfiguration( + blueprintConfig.getProperties(), blueprintConfig.getPropertyAttributes())); + } } } http://git-wip-us.apache.org/repos/asf/ambari/blob/64c9ef8a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java index bb771a5..7381387 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java @@ -408,7 +408,10 @@ public class BlueprintConfigurationProcessor { } } - setMissingConfigurations(clusterConfig, configTypesUpdated); + // Explicitly set any properties that are required but not currently provided in the stack definition. + setRetryConfiguration(clusterConfig, configTypesUpdated); + setupHDFSProxyUsers(clusterConfig, configTypesUpdated); + addExcludedConfigProperties(clusterConfig, configTypesUpdated, clusterTopology.getBlueprint().getStack()); trimProperties(clusterConfig, clusterTopology); @@ -2778,59 +2781,52 @@ public class BlueprintConfigurationProcessor { }); } - /** - * Explicitly set any properties that are required but not currently provided in the stack definition. - * - * @param configuration configuration where properties are to be added - */ - void setMissingConfigurations(Configuration configuration, Set<String> configTypesUpdated) { + private Collection<String> setupHDFSProxyUsers(Configuration configuration, Set<String> configTypesUpdated) { // AMBARI-5206 final Map<String , String> userProps = new HashMap<>(); - setRetryConfiguration(configuration, configTypesUpdated); - Collection<String> services = clusterTopology.getBlueprint().getServices(); - // only add user properties to the map for - // services actually included in the blueprint definition - if (services.contains("OOZIE")) { - userProps.put("oozie_user", "oozie-env"); - } - - if (services.contains("HIVE")) { - userProps.put("hive_user", "hive-env"); - userProps.put("webhcat_user", "hive-env"); - } + if (services.contains("HDFS")) { + // only add user properties to the map for + // services actually included in the blueprint definition + if (services.contains("OOZIE")) { + userProps.put("oozie_user", "oozie-env"); + } - if (services.contains("HBASE")) { - userProps.put("hbase_user", "hbase-env"); - } + if (services.contains("HIVE")) { + userProps.put("hive_user", "hive-env"); + userProps.put("webhcat_user", "hive-env"); + } - if (services.contains("FALCON")) { - userProps.put("falcon_user", "falcon-env"); - } + if (services.contains("HBASE")) { + userProps.put("hbase_user", "hbase-env"); + } - String proxyUserHosts = "hadoop.proxyuser.%s.hosts"; - String proxyUserGroups = "hadoop.proxyuser.%s.groups"; + if (services.contains("FALCON")) { + userProps.put("falcon_user", "falcon-env"); + } - Map<String, Map<String, String>> existingProperties = configuration.getFullProperties(); - for (String property : userProps.keySet()) { - String configType = userProps.get(property); - Map<String, String> configs = existingProperties.get(configType); - if (configs != null) { - String user = configs.get(property); - if (user != null && !user.isEmpty()) { - ensureProperty(configuration, "core-site", String.format(proxyUserHosts, user), "*", configTypesUpdated); - ensureProperty(configuration, "core-site", String.format(proxyUserGroups, user), "*", configTypesUpdated); - } - } else { - LOG.debug("setMissingConfigurations: no user configuration found for type = " + configType + + String proxyUserHosts = "hadoop.proxyuser.%s.hosts"; + String proxyUserGroups = "hadoop.proxyuser.%s.groups"; + + Map<String, Map<String, String>> existingProperties = configuration.getFullProperties(); + for (String property : userProps.keySet()) { + String configType = userProps.get(property); + Map<String, String> configs = existingProperties.get(configType); + if (configs != null) { + String user = configs.get(property); + if (user != null && !user.isEmpty()) { + ensureProperty(configuration, "core-site", String.format(proxyUserHosts, user), "*", configTypesUpdated); + ensureProperty(configuration, "core-site", String.format(proxyUserGroups, user), "*", configTypesUpdated); + } + } else { + LOG.debug("setMissingConfigurations: no user configuration found for type = " + configType + ". This may be caused by an error in the blueprint configuration."); - } + } + } } - - addExcludedConfigProperties(configuration, configTypesUpdated, services, clusterTopology.getBlueprint().getStack()); - + return services; } /** @@ -2840,10 +2836,11 @@ public class BlueprintConfigurationProcessor { * In case the excluded config-type related service is not present in the blueprint, excluded configs are ignored * @param configuration * @param configTypesUpdated - * @param blueprintServices * @param stack */ - private void addExcludedConfigProperties(Configuration configuration, Set<String> configTypesUpdated, Collection<String> blueprintServices, Stack stack) { + private void addExcludedConfigProperties(Configuration configuration, Set<String> configTypesUpdated, Stack stack) { + Collection<String> blueprintServices = clusterTopology.getBlueprint().getServices(); + LOG.debug("Handling excluded properties for blueprint services: {}", blueprintServices); for (String blueprintService : blueprintServices) { http://git-wip-us.apache.org/repos/asf/ambari/blob/64c9ef8a/ambari-server/src/main/java/org/apache/ambari/server/topology/Blueprint.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/Blueprint.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/Blueprint.java index 6189b99..139a1ee 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/Blueprint.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Blueprint.java @@ -154,6 +154,14 @@ public interface Blueprint { void validateRequiredProperties() throws InvalidTopologyException; /** + * + * A config type is valid if there are services related to except cluster-env and global. + * @param configType + * @return + */ + boolean isValidConfigType(String configType); + + /** * Obtain the blueprint as an entity. * * @return entity representation of the blueprint http://git-wip-us.apache.org/repos/asf/ambari/blob/64c9ef8a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java index c90e35c..826e4e5 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java @@ -39,6 +39,7 @@ import org.apache.ambari.server.orm.entities.HostGroupConfigEntity; import org.apache.ambari.server.orm.entities.HostGroupEntity; import org.apache.ambari.server.orm.entities.StackEntity; import org.apache.ambari.server.stack.NoSuchStackException; +import org.apache.ambari.server.state.ConfigHelper; import org.apache.commons.lang.StringUtils; import com.google.gson.Gson; @@ -600,4 +601,18 @@ public class BlueprintImpl implements Blueprint { blueprintEntity.setSettings(settingEntityMap.values()); } } + + /** + * A config type is valid if there are services related to except cluster-env and global. + */ + public boolean isValidConfigType(String configType) { + if (ConfigHelper.CLUSTER_ENV.equals(configType) || "global".equals(configType)) { + return true; + } + String service = getStack().getServiceForConfigType(configType); + if (getServices().contains(service)) { + return true; + } + return false; + } } http://git-wip-us.apache.org/repos/asf/ambari/blob/64c9ef8a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java index 0e7d70b..ed25aea 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java @@ -66,6 +66,11 @@ public class ClusterConfigurationRequest { private Stack stack; private boolean configureSecurity = false; + public ClusterConfigurationRequest(AmbariContext ambariContext, ClusterTopology topology, boolean setInitial, StackAdvisorBlueprintProcessor stackAdvisorBlueprintProcessor, boolean configureSecurity) { + this(ambariContext, topology, setInitial, stackAdvisorBlueprintProcessor); + this.configureSecurity = configureSecurity; + } + public ClusterConfigurationRequest(AmbariContext ambariContext, ClusterTopology clusterTopology, boolean setInitial, StackAdvisorBlueprintProcessor stackAdvisorBlueprintProcessor) { this.ambariContext = ambariContext; @@ -82,6 +87,21 @@ public class ClusterConfigurationRequest { } /** + * Remove config-types from the given configuration if there is no any services related to them (except cluster-env and global). + */ + private void removeOrphanConfigTypes(Configuration configuration) { + Blueprint blueprint = clusterTopology.getBlueprint(); + + Collection<String> configTypes = configuration.getAllConfigTypes(); + for (String configType : configTypes) { + if (!blueprint.isValidConfigType(configType)) { + configuration.removeConfigType(configType); + LOG.info("Removing config type '{}' as related service is not present in either Blueprint or cluster creation template.", configType); + } + } + } + + /** * Remove config-types, if there is no any services related to them (except cluster-env and global). */ private void removeOrphanConfigTypes() { @@ -100,29 +120,6 @@ public class ClusterConfigurationRequest { } } - /** - * Remove config-types from the given configuration if there is no any services related to them (except cluster-env and global). - */ - private void removeOrphanConfigTypes(Configuration configuration) { - Blueprint blueprint = clusterTopology.getBlueprint(); - - Collection<String> configTypes = configuration.getAllConfigTypes(); - for (String configType : configTypes) { - if (!"cluster-env".equals(configType) && !"global".equals(configType)) { - String service = blueprint.getStack().getServiceForConfigType(configType); - if (!blueprint.getServices().contains(service)) { - configuration.removeConfigType(configType); - LOG.info("Removing config type '{}' as service '{}' is not present in either Blueprint or cluster creation template.", configType, service); - } - } - } - } - - public ClusterConfigurationRequest(AmbariContext ambariContext, ClusterTopology topology, boolean setInitial, StackAdvisorBlueprintProcessor stackAdvisorBlueprintProcessor, boolean configureSecurity) { - this(ambariContext, topology, setInitial, stackAdvisorBlueprintProcessor); - this.configureSecurity = configureSecurity; - } - // get names of required host groups public Collection<String> getRequiredHostGroups() { Collection<String> requiredHostGroups = new HashSet<>(); @@ -161,20 +158,6 @@ public class ClusterConfigurationRequest { setConfigurationsOnCluster(clusterTopology, TopologyManager.TOPOLOGY_RESOLVED_TAG, updatedConfigTypes); } - /** - * A config type is orphaned if there are services related to except cluster-env and global. - */ - private boolean isOrphanedConfigType(String configType, Blueprint blueprint) { - boolean isOrphanedConfigType = false; - if (!"cluster-env".equals(configType) && !"global".equals(configType)) { - String service = blueprint.getStack().getServiceForConfigType(configType); - if (!blueprint.getServices().contains(service)) { - isOrphanedConfigType = true; - } - } - return isOrphanedConfigType; - } - private Set<String> configureKerberos(Configuration clusterConfiguration, Map<String, Map<String, String>> existingConfigurations) throws AmbariException { Set<String> updatedConfigTypes = new HashSet<>(); @@ -215,7 +198,7 @@ public class ClusterConfigurationRequest { for (String configType : updatedConfigs.keySet()) { // apply only if config type has related services in Blueprint - if (!isOrphanedConfigType(configType, blueprint)) { + if (blueprint.isValidConfigType(configType)) { Map<String, String> propertyMap = updatedConfigs.get(configType); Map<String, String> clusterConfigProperties = existingConfigurations.get(configType); Map<String, String> stackDefaultConfigProperties = stackDefaultProps.get(configType); http://git-wip-us.apache.org/repos/asf/ambari/blob/64c9ef8a/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessorTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessorTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessorTest.java index 3c5f8ed..bc82999 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessorTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessorTest.java @@ -87,6 +87,7 @@ public class StackAdvisorBlueprintProcessorTest { expect(stack.getConfiguration(Arrays.asList("HDFS", "YARN", "HIVE"))).andReturn(createStackDefaults()).anyTimes(); expect(blueprint.getServices()).andReturn(Arrays.asList("HDFS", "YARN", "HIVE")).anyTimes(); expect(blueprint.getHostGroups()).andReturn(createHostGroupMap()).anyTimes(); + expect(blueprint.isValidConfigType("core-site")).andReturn(true).anyTimes(); expect(hostGroup.getComponentNames()).andReturn(Arrays.asList("comp1", "comp2")).anyTimes(); expect(stackAdvisorHelper.recommend(anyObject(StackAdvisorRequest.class))).andReturn(createRecommendationResponse()); expect(configuration.getFullProperties()).andReturn(props).anyTimes(); @@ -121,6 +122,7 @@ public class StackAdvisorBlueprintProcessorTest { expect(stack.getConfiguration(Arrays.asList("HDFS", "YARN", "HIVE"))).andReturn(createStackDefaults()).anyTimes(); expect(blueprint.getServices()).andReturn(Arrays.asList("HDFS", "YARN", "HIVE")).anyTimes(); expect(blueprint.getHostGroups()).andReturn(createHostGroupMap()).anyTimes(); + expect(blueprint.isValidConfigType("core-site")).andReturn(true).anyTimes(); expect(hostGroup.getComponentNames()).andReturn(Arrays.asList("comp1", "comp2")).anyTimes(); expect(stackAdvisorHelper.recommend(anyObject(StackAdvisorRequest.class))).andReturn(createRecommendationResponse()); expect(configuration.getFullProperties()).andReturn(props).anyTimes(); @@ -156,6 +158,7 @@ public class StackAdvisorBlueprintProcessorTest { expect(stack.getConfiguration(Arrays.asList("HDFS", "YARN", "HIVE"))).andReturn(createStackDefaults()).anyTimes(); expect(blueprint.getServices()).andReturn(Arrays.asList("HDFS", "YARN", "HIVE")).anyTimes(); expect(blueprint.getHostGroups()).andReturn(createHostGroupMap()).anyTimes(); + expect(blueprint.isValidConfigType("core-site")).andReturn(true).anyTimes(); expect(hostGroup.getComponentNames()).andReturn(Arrays.asList("comp1", "comp2")).anyTimes(); expect(stackAdvisorHelper.recommend(anyObject(StackAdvisorRequest.class))).andReturn(createRecommendationResponse()); expect(configuration.getFullProperties()).andReturn(props).anyTimes(); @@ -189,6 +192,7 @@ public class StackAdvisorBlueprintProcessorTest { expect(stack.getConfiguration(Arrays.asList("HDFS", "YARN", "HIVE"))).andReturn(createStackDefaults()).anyTimes(); expect(blueprint.getServices()).andReturn(Arrays.asList("HDFS", "YARN", "HIVE")).anyTimes(); expect(blueprint.getHostGroups()).andReturn(createHostGroupMap()).anyTimes(); + expect(blueprint.isValidConfigType("core-site")).andReturn(true).anyTimes(); expect(hostGroup.getComponentNames()).andReturn(Arrays.asList("comp1", "comp2")).anyTimes(); expect(stackAdvisorHelper.recommend(anyObject(StackAdvisorRequest.class))).andReturn(createRecommendationResponse()); expect(configuration.getFullProperties()).andReturn(props).anyTimes(); http://git-wip-us.apache.org/repos/asf/ambari/blob/64c9ef8a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java index 5c1836a..8ff70a1 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java @@ -5772,6 +5772,7 @@ public class BlueprintConfigurationProcessorTest extends EasyMockSupport { Collections.<String, Map<String, Map<String, String>>>emptyMap()); Collection<String> hgComponents1 = new HashSet<>(); + hgComponents1.add("DATANODE"); hgComponents1.add("OOZIE_SERVER"); hgComponents1.add("HIVE_SERVER"); hgComponents1.add("HBASE_MASTER"); @@ -5818,6 +5819,7 @@ public class BlueprintConfigurationProcessorTest extends EasyMockSupport { Collections.<String, Map<String, Map<String, String>>>emptyMap()); Collection<String> hgComponents1 = new HashSet<>(); + hgComponents1.add("DATANODE"); hgComponents1.add("OOZIE_SERVER"); hgComponents1.add("FALCON_SERVER"); TestHostGroup group1 = new TestHostGroup("group1", hgComponents1, Collections.singleton("host1")); @@ -5861,6 +5863,7 @@ public class BlueprintConfigurationProcessorTest extends EasyMockSupport { Collections.<String, Map<String, Map<String, String>>>emptyMap()); Collection<String> hgComponents1 = new HashSet<>(); + hgComponents1.add("DATANODE"); hgComponents1.add("OOZIE_SERVER"); hgComponents1.add("FALCON_SERVER"); TestHostGroup group1 = new TestHostGroup("group1", hgComponents1, Collections.singleton("host1")); @@ -5903,6 +5906,7 @@ public class BlueprintConfigurationProcessorTest extends EasyMockSupport { Collections.<String, Map<String, Map<String, String>>>emptyMap(), parentClusterConfig); Collection<String> hgComponents1 = new HashSet<>(); + hgComponents1.add("DATANODE"); hgComponents1.add("OOZIE_SERVER"); hgComponents1.add("FALCON_SERVER"); TestHostGroup group1 = new TestHostGroup("group1", hgComponents1, Collections.singleton("host1")); http://git-wip-us.apache.org/repos/asf/ambari/blob/64c9ef8a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterConfigurationRequestTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterConfigurationRequestTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterConfigurationRequestTest.java index 1440c4d..6c90d18 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterConfigurationRequestTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterConfigurationRequestTest.java @@ -248,6 +248,8 @@ public class ClusterConfigurationRequestTest { expect(topology.getConfigRecommendationStrategy()).andReturn(ConfigRecommendationStrategy.NEVER_APPLY).anyTimes(); expect(topology.getBlueprint()).andReturn(blueprint).anyTimes(); + expect(blueprint.isValidConfigType("testConfigType")).andReturn(true).anyTimes(); + expect(topology.getConfiguration()).andReturn(blueprintConfig).anyTimes(); expect(topology.getHostGroupInfo()).andReturn(Collections.<String, HostGroupInfo>emptyMap()).anyTimes(); expect(topology.getClusterId()).andReturn(Long.valueOf(1)).anyTimes(); @@ -368,9 +370,12 @@ public class ClusterConfigurationRequestTest { expect(topology.getHostGroupInfo()).andReturn(hostGroupInfoMap); expect(blueprint.getStack()).andReturn(stack).anyTimes(); expect(blueprint.getServices()).andReturn(services).anyTimes(); - expect(stack.getServiceForConfigType("hdfs-site")).andReturn("HDFS").anyTimes(); - expect(stack.getServiceForConfigType("admin-properties")).andReturn("RANGER").anyTimes(); - expect(stack.getServiceForConfigType("yarn-site")).andReturn("YARN").anyTimes(); + + expect(blueprint.isValidConfigType("hdfs-site")).andReturn(true).anyTimes(); + expect(blueprint.isValidConfigType("admin-properties")).andReturn(true).anyTimes(); + expect(blueprint.isValidConfigType("yarn-site")).andReturn(false).anyTimes(); + expect(blueprint.isValidConfigType("cluster-env")).andReturn(true).anyTimes(); + expect(blueprint.isValidConfigType("global")).andReturn(true).anyTimes(); EasyMock.replay(stack, blueprint, topology); // WHEN @@ -409,9 +414,10 @@ public class ClusterConfigurationRequestTest { expect(topology.getHostGroupInfo()).andReturn(hostGroupInfoMap); expect(blueprint.getStack()).andReturn(stack).anyTimes(); expect(blueprint.getServices()).andReturn(services).anyTimes(); - expect(stack.getServiceForConfigType("hdfs-site")).andReturn("HDFS").anyTimes(); - expect(stack.getServiceForConfigType("admin-properties")).andReturn("RANGER").anyTimes(); - expect(stack.getServiceForConfigType("yarn-site")).andReturn("YARN").anyTimes(); + + expect(blueprint.isValidConfigType("hdfs-site")).andReturn(true).anyTimes(); + expect(blueprint.isValidConfigType("cluster-env")).andReturn(true).anyTimes(); + expect(blueprint.isValidConfigType("global")).andReturn(true).anyTimes(); EasyMock.replay(stack, blueprint, topology); http://git-wip-us.apache.org/repos/asf/ambari/blob/64c9ef8a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterDeployWithStartOnlyTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterDeployWithStartOnlyTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterDeployWithStartOnlyTest.java index 6bcd6bc..c8d4d55 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterDeployWithStartOnlyTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterDeployWithStartOnlyTest.java @@ -251,6 +251,7 @@ public class ClusterDeployWithStartOnlyTest extends EasyMockSupport { expect(blueprint.getName()).andReturn(BLUEPRINT_NAME).anyTimes(); expect(blueprint.getServices()).andReturn(Arrays.asList("service1", "service2")).anyTimes(); expect(blueprint.getStack()).andReturn(stack).anyTimes(); + expect(blueprint.isValidConfigType(anyString())).andReturn(true).anyTimes(); // don't expect toEntity() expect(stack.getAllConfigurationTypes("service1")).andReturn(Arrays.asList("service1-site", "service1-env")).anyTimes(); http://git-wip-us.apache.org/repos/asf/ambari/blob/64c9ef8a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartOnComponentLevelTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartOnComponentLevelTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartOnComponentLevelTest.java index 0631b03..4c9815c 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartOnComponentLevelTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartOnComponentLevelTest.java @@ -247,6 +247,7 @@ public class ClusterInstallWithoutStartOnComponentLevelTest extends EasyMockSupp expect(blueprint.getName()).andReturn(BLUEPRINT_NAME).anyTimes(); expect(blueprint.getServices()).andReturn(Arrays.asList("service1", "service2")).anyTimes(); expect(blueprint.getStack()).andReturn(stack).anyTimes(); + expect(blueprint.isValidConfigType(anyString())).andReturn(true).anyTimes(); // don't expect toEntity() expect(stack.getAllConfigurationTypes("service1")).andReturn(Arrays.asList("service1-site", "service1-env")).anyTimes(); http://git-wip-us.apache.org/repos/asf/ambari/blob/64c9ef8a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartTest.java index c074d78..1bdeb1b 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartTest.java @@ -248,6 +248,7 @@ public class ClusterInstallWithoutStartTest extends EasyMockSupport { expect(blueprint.getName()).andReturn(BLUEPRINT_NAME).anyTimes(); expect(blueprint.getServices()).andReturn(Arrays.asList("service1", "service2")).anyTimes(); expect(blueprint.getStack()).andReturn(stack).anyTimes(); + expect(blueprint.isValidConfigType(anyString())).andReturn(true).anyTimes(); // don't expect toEntity() expect(stack.getAllConfigurationTypes("service1")).andReturn(Arrays.asList("service1-site", "service1-env")).anyTimes();
