Updated Branches: refs/heads/trunk 20702c6bf -> 86fed01eb
AMBARI-3718. Optimize stale config lookup for Hsot Component API call. (swagle) Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/86fed01e Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/86fed01e Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/86fed01e Branch: refs/heads/trunk Commit: 86fed01eb14df077cd36e641695196ee81275349 Parents: 20702c6 Author: Siddharth Wagle <swa...@hortonworks.com> Authored: Fri Nov 8 14:39:15 2013 -0800 Committer: Siddharth Wagle <swa...@hortonworks.com> Committed: Fri Nov 8 14:39:15 2013 -0800 ---------------------------------------------------------------------- .../server/api/util/StackExtensionHelper.java | 11 +++++ .../ambari/server/state/ConfigHelper.java | 19 ++++++--- .../apache/ambari/server/state/ServiceInfo.java | 33 +++++++++------ .../server/state/stack/ServiceMetainfoXml.java | 14 ++++++- .../HDP/2.0.6/services/HBASE/metainfo.xml | 6 ++- .../stacks/HDP/2.0.6/services/HDFS/metainfo.xml | 7 +++- .../stacks/HDP/2.0.6/services/HIVE/metainfo.xml | 6 ++- .../HDP/2.0.6/services/MAPREDUCE2/metainfo.xml | 5 +++ .../HDP/2.0.6/services/OOZIE/metainfo.xml | 5 ++- .../stacks/HDP/2.0.6/services/YARN/metainfo.xml | 6 +++ .../HDPLocal/2.0.6/services/HBASE/metainfo.xml | 6 ++- .../HDPLocal/2.0.6/services/HDFS/metainfo.xml | 7 +++- .../HDPLocal/2.0.6/services/HIVE/metainfo.xml | 6 ++- .../2.0.6/services/MAPREDUCE2/metainfo.xml | 6 +++ .../HDPLocal/2.0.6/services/OOZIE/metainfo.xml | 5 ++- .../HDPLocal/2.0.6/services/YARN/metainfo.xml | 6 +++ .../server/api/services/AmbariMetaInfoTest.java | 10 +++++ .../AmbariManagementControllerTest.java | 9 +++-- .../svccomphost/ServiceComponentHostTest.java | 42 +++++++++++++++++--- .../stacks/HDP/2.0.5/services/HDFS/metainfo.xml | 7 +++- .../HDP/2.0.5/services/MAPREDUCE2/metainfo.xml | 5 +++ .../stacks/HDP/2.0.5/services/YARN/metainfo.xml | 4 ++ .../stacks/HDP/2.0.6/services/YARN/metainfo.xml | 3 ++ 23 files changed, 188 insertions(+), 40 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java index 6463150..93f93bc 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java @@ -95,6 +95,7 @@ public class StackExtensionHelper { mergedServiceInfo.setComment(childService.getComment()); mergedServiceInfo.setUser(childService.getUser()); mergedServiceInfo.setVersion(childService.getVersion()); + mergedServiceInfo.setConfigDependencies(childService.getConfigDependencies()); // Add all child components to service List<String> deleteList = new ArrayList<String>(); List<String> appendList = new ArrayList<String>(); @@ -131,6 +132,15 @@ public class StackExtensionHelper { mergedServiceInfo.getProperties().add(parentPropertyInfo); } } + // Add all parent config dependencies + if (parentService.getConfigDependencies() != null && !parentService + .getConfigDependencies().isEmpty()) { + for (String configDep : parentService.getConfigDependencies()) { + if (!mergedServiceInfo.getConfigDependencies().contains(configDep)) { + mergedServiceInfo.getConfigDependencies().add(configDep); + } + } + } return mergedServiceInfo; } @@ -294,6 +304,7 @@ public class StackExtensionHelper { serviceInfo.setUser(smx.getUser()); serviceInfo.setVersion(smx.getVersion()); serviceInfo.setDeleted(smx.isDeleted()); + serviceInfo.setConfigDependencies(smx.getConfigDependencies()); serviceInfo.getComponents().addAll(smx.getComponents()); } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java index 91ab4f4..5fb7667 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java @@ -34,6 +34,7 @@ import org.apache.ambari.server.AmbariException; import org.apache.ambari.server.api.services.AmbariMetaInfo; import com.google.inject.Inject; +import org.apache.ambari.server.configuration.Configuration; /** * Helper class that works with config traversals. @@ -271,7 +272,7 @@ public class ConfigHelper { // desired is set, but actual is not if (!serviceInfo.hasConfigType(type)) { stale = false; - } else { + } else if (type.equals(Configuration.GLOBAL_CONFIG_TAG)) { // find out if the keys are stale by first checking the target service, // then all services Collection<String> keys = mergeKeyNames(cluster, type, tags.values()); @@ -279,6 +280,8 @@ public class ConfigHelper { if (serviceInfo.hasPropertyFor(type, keys) || !hasPropertyFor(stackId, type, keys)) { stale = true; } + } else { + stale = true; } } else { // desired and actual both define the type @@ -287,15 +290,19 @@ public class ConfigHelper { if (!isTagChanged(tags, actualTags)) { stale = false; - } else { - // tags are change, need to find out what has changed, and if it applies + } else if (type.equals(Configuration.GLOBAL_CONFIG_TAG)) { + // tags are changed, need to find out what has changed, + // and if it applies // to the service Collection<String> changed = findChangedKeys(cluster, type, tags.values(), actualTags.values()); if (serviceInfo.hasPropertyFor(type, changed)) { stale = true; } + } else if (!serviceInfo.hasConfigType(type)) { + stale = false; + } else { + stale = true; } - } } return stale; @@ -305,7 +312,7 @@ public class ConfigHelper { * @return <code>true</code> if any service on the stack defines a property * for the type. */ - // TODO: Create a static hash map for quick lookup + private boolean hasPropertyFor(StackId stack, String type, Collection<String> keys) throws AmbariException { @@ -364,7 +371,7 @@ public class ConfigHelper { map.put(CLUSTER_DEFAULT_TAG, hc.getDefaultVersionTag()); if (hc.getConfigGroupOverrides() != null) { for (Entry<Long, String> entry : hc.getConfigGroupOverrides().entrySet()) { - map.put(entry.toString(), entry.getValue()); + map.put(entry.getKey().toString(), entry.getValue()); } } return map; http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java index fa2c759..238c388 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java @@ -20,6 +20,7 @@ package org.apache.ambari.server.state; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -41,6 +42,7 @@ public class ServiceInfo { private boolean isDeleted = false; @JsonIgnore private volatile Map<String, Set<String>> configLayout = null; + private List<String> configDependencies; public boolean isDeleted() { return isDeleted; @@ -141,8 +143,8 @@ public class ServiceInfo { } public List<String> getConfigTypes() { - buildConfigLayout(); - return new ArrayList<String>(configLayout.keySet()); + return configDependencies != null ? configDependencies : + Collections.unmodifiableList(new ArrayList<String>()); } @@ -151,9 +153,7 @@ public class ServiceInfo { * @return <code>true</code> if the service defines the supplied type */ public boolean hasConfigType(String type) { - buildConfigLayout(); - - return configLayout.containsKey(type); + return configDependencies != null && configDependencies.contains(type); } /** @@ -170,7 +170,8 @@ public class ServiceInfo { public boolean hasPropertyFor(String type, Collection<String> keyNames) { if (!hasConfigType(type)) return false; - + + buildConfigLayout(); Set<String> keys = configLayout.get(type); for (String staleCheck : keyNames) { @@ -180,7 +181,7 @@ public class ServiceInfo { return false; } - + /** * Builds the config map specific to this service. */ @@ -189,19 +190,27 @@ public class ServiceInfo { synchronized(this) { if (null == configLayout) { configLayout = new HashMap<String, Set<String>>(); - + for (PropertyInfo pi : getProperties()) { String type = pi.getFilename(); int idx = type.indexOf(".xml"); - type = type.substring(0, idx); - + type = type.substring(0, idx); + if (!configLayout.containsKey(type)) - configLayout.put(type, new HashSet<String>()); - + configLayout.put(type, new HashSet<String>()); + configLayout.get(type).add(pi.getName()); } } } } } + + public List<String> getConfigDependencies() { + return configDependencies; + } + + public void setConfigDependencies(List<String> configDependencies) { + this.configDependencies = configDependencies; + } } http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/main/java/org/apache/ambari/server/state/stack/ServiceMetainfoXml.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/ServiceMetainfoXml.java b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/ServiceMetainfoXml.java index ff5788d..9104d95 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/ServiceMetainfoXml.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/ServiceMetainfoXml.java @@ -42,7 +42,10 @@ public class ServiceMetainfoXml { @XmlElementWrapper(name="components") @XmlElements(@XmlElement(name="component")) private List<ComponentInfo> components; - + + @XmlElementWrapper(name="configuration-dependencies") + @XmlElement(name="config-type") + private List<String> configDependencies; /** * @return the user */ @@ -77,5 +80,12 @@ public class ServiceMetainfoXml { public boolean isDeleted() { return deleted; } - + + public List<String> getConfigDependencies() { + return configDependencies; + } + + public void setConfigDependencies(List<String> configDependencies) { + this.configDependencies = configDependencies; + } } http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/metainfo.xml b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/metainfo.xml index dfaa256..c17a87e 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/metainfo.xml +++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HBASE/metainfo.xml @@ -36,5 +36,9 @@ <category>CLIENT</category> </component> </components> - + <configuration-dependencies> + <config-type>global</config-type> + <config-type>hbase-site</config-type> + <config-type>hbase-policy</config-type> + </configuration-dependencies> </metainfo> http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HDFS/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HDFS/metainfo.xml b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HDFS/metainfo.xml index 564c2f4..19ac76b 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HDFS/metainfo.xml +++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HDFS/metainfo.xml @@ -51,5 +51,10 @@ <category>SLAVE</category> </component> </components> - + <configuration-dependencies> + <config-type>core-site</config-type> + <config-type>global</config-type> + <config-type>hdfs-site</config-type> + <config-type>hadoop-policy</config-type> + </configuration-dependencies> </metainfo> http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/metainfo.xml b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/metainfo.xml index 818a461..ca91fc2 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/metainfo.xml +++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/metainfo.xml @@ -38,6 +38,8 @@ <category>CLIENT</category> </component> </components> - - + <configuration-dependencies> + <config-type>global</config-type> + <config-type>hive-site</config-type> + </configuration-dependencies> </metainfo> http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/MAPREDUCE2/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/MAPREDUCE2/metainfo.xml b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/MAPREDUCE2/metainfo.xml index 885cd32..3790da2 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/MAPREDUCE2/metainfo.xml +++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/MAPREDUCE2/metainfo.xml @@ -29,4 +29,9 @@ <category>CLIENT</category> </component> </components> + <configuration-dependencies> + <config-type>core-site</config-type> + <config-type>global</config-type> + <config-type>mapred-site</config-type> + </configuration-dependencies> </metainfo> http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/metainfo.xml b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/metainfo.xml index bb01f62..515e669 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/metainfo.xml +++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/metainfo.xml @@ -31,5 +31,8 @@ <category>CLIENT</category> </component> </components> - + <configuration-dependencies> + <config-type>global</config-type> + <config-type>oozie-site</config-type> + </configuration-dependencies> </metainfo> http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/metainfo.xml b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/metainfo.xml index 9d0e871..8187329 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/metainfo.xml +++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/metainfo.xml @@ -33,4 +33,10 @@ <category>CLIENT</category> </component> </components> + <configuration-dependencies> + <config-type>global</config-type> + <config-type>core-site</config-type> + <config-type>yarn-site</config-type> + <config-type>capacity-scheduler</config-type> + </configuration-dependencies> </metainfo> http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/HBASE/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/HBASE/metainfo.xml b/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/HBASE/metainfo.xml index dfaa256..c17a87e 100644 --- a/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/HBASE/metainfo.xml +++ b/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/HBASE/metainfo.xml @@ -36,5 +36,9 @@ <category>CLIENT</category> </component> </components> - + <configuration-dependencies> + <config-type>global</config-type> + <config-type>hbase-site</config-type> + <config-type>hbase-policy</config-type> + </configuration-dependencies> </metainfo> http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/HDFS/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/HDFS/metainfo.xml b/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/HDFS/metainfo.xml index 564c2f4..19ac76b 100644 --- a/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/HDFS/metainfo.xml +++ b/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/HDFS/metainfo.xml @@ -51,5 +51,10 @@ <category>SLAVE</category> </component> </components> - + <configuration-dependencies> + <config-type>core-site</config-type> + <config-type>global</config-type> + <config-type>hdfs-site</config-type> + <config-type>hadoop-policy</config-type> + </configuration-dependencies> </metainfo> http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/HIVE/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/HIVE/metainfo.xml b/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/HIVE/metainfo.xml index 818a461..ca91fc2 100644 --- a/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/HIVE/metainfo.xml +++ b/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/HIVE/metainfo.xml @@ -38,6 +38,8 @@ <category>CLIENT</category> </component> </components> - - + <configuration-dependencies> + <config-type>global</config-type> + <config-type>hive-site</config-type> + </configuration-dependencies> </metainfo> http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/MAPREDUCE2/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/MAPREDUCE2/metainfo.xml b/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/MAPREDUCE2/metainfo.xml index 885cd32..069873a 100644 --- a/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/MAPREDUCE2/metainfo.xml +++ b/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/MAPREDUCE2/metainfo.xml @@ -29,4 +29,10 @@ <category>CLIENT</category> </component> </components> + <configuration-dependencies> + <config-type>core-site</config-type> + <config-type>global</config-type> + <config-type>mapred-site</config-type> + <config-type>mapred-queue-acls</config-type> + </configuration-dependencies> </metainfo> http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/OOZIE/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/OOZIE/metainfo.xml b/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/OOZIE/metainfo.xml index bb01f62..515e669 100644 --- a/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/OOZIE/metainfo.xml +++ b/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/OOZIE/metainfo.xml @@ -31,5 +31,8 @@ <category>CLIENT</category> </component> </components> - + <configuration-dependencies> + <config-type>global</config-type> + <config-type>oozie-site</config-type> + </configuration-dependencies> </metainfo> http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/YARN/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/YARN/metainfo.xml b/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/YARN/metainfo.xml index 9d0e871..8187329 100644 --- a/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/YARN/metainfo.xml +++ b/ambari-server/src/main/resources/stacks/HDPLocal/2.0.6/services/YARN/metainfo.xml @@ -33,4 +33,10 @@ <category>CLIENT</category> </component> </components> + <configuration-dependencies> + <config-type>global</config-type> + <config-type>core-site</config-type> + <config-type>yarn-site</config-type> + <config-type>capacity-scheduler</config-type> + </configuration-dependencies> </metainfo> http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java index 5848c9f..87c0822 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java @@ -65,6 +65,7 @@ public class AmbariMetaInfoTest { private static String STACK_VERSION_HDP_02 = "0.2"; private static final String STACK_MINIMAL_VERSION_HDP = "0.0"; private static String SERVICE_NAME_HDFS = "HDFS"; + private static String SERVICE_NAME_MAPRED2 = "MAPREDUCE2"; private static String SERVICE_COMPONENT_NAME = "NAMENODE"; private static final String OS_TYPE = "centos5"; private static final String REPO_ID = "HDP-UTILS-1.1.0.15"; @@ -202,6 +203,14 @@ public class AmbariMetaInfoTest { assertNotNull(si); } + @Test + public void testConfigDependencies() throws Exception { + ServiceInfo serviceInfo = metaInfo.getServiceInfo(STACK_NAME_HDP, EXT_STACK_NAME, + SERVICE_NAME_MAPRED2); + assertNotNull(serviceInfo); + assertTrue(!serviceInfo.getConfigDependencies().isEmpty()); + } + /** * Method: getSupportedServices(String stackName, String version) */ @@ -519,6 +528,7 @@ public class AmbariMetaInfoTest { Assert.assertEquals("mapreduce.shuffle", originalProperty.getValue()); Assert.assertEquals("Auxilliary services of NodeManager", originalProperty.getDescription()); + Assert.assertEquals(3, redefinedService.getConfigDependencies().size()); } @Test http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java index 3eef47f..b5aa668 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java @@ -133,6 +133,7 @@ public class AmbariManagementControllerTest { private static final String STACK_NAME = "HDP"; private static final String STACK_VERSION = "0.2"; + private static final String NEW_STACK_VERSION = "2.0.6"; private static final String OS_TYPE = "centos5"; private static final String REPO_ID = "HDP-1.1.1.16"; private static final String PROPERTY_NAME = "hbase.regionserver.msginterval"; @@ -6054,12 +6055,12 @@ public class AmbariManagementControllerTest { public void testGetStackServices() throws Exception { - StackServiceRequest request = new StackServiceRequest(STACK_NAME, STACK_VERSION, null); + StackServiceRequest request = new StackServiceRequest(STACK_NAME, NEW_STACK_VERSION, null); Set<StackServiceResponse> responses = controller.getStackServices(Collections.singleton(request)); - Assert.assertEquals(STACK_SERVICES_CNT, responses.size()); + Assert.assertEquals(12, responses.size()); - StackServiceRequest requestWithParams = new StackServiceRequest(STACK_NAME, STACK_VERSION, SERVICE_NAME); + StackServiceRequest requestWithParams = new StackServiceRequest(STACK_NAME, NEW_STACK_VERSION, SERVICE_NAME); Set<StackServiceResponse> responsesWithParams = controller.getStackServices(Collections.singleton(requestWithParams)); Assert.assertEquals(1, responsesWithParams.size()); for (StackServiceResponse responseWithParams: responsesWithParams) { @@ -6068,7 +6069,7 @@ public class AmbariManagementControllerTest { } - StackServiceRequest invalidRequest = new StackServiceRequest(STACK_NAME, STACK_VERSION, NON_EXT_VALUE); + StackServiceRequest invalidRequest = new StackServiceRequest(STACK_NAME, NEW_STACK_VERSION, NON_EXT_VALUE); try { controller.getStackServices(Collections.singleton(invalidRequest)); } catch (StackAccessException e) { http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java index 8be68f8..e19250e 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java @@ -739,15 +739,47 @@ public class ServiceComponentHostTest { // change 'global' property only affecting global/HDFS makeConfig(cluster, "global", "version2", - new HashMap<String,String>() {{ - put("a", "b"); - put("dfs_namenode_name_dir", "/foo3"); // HDFS only - put("mapred_log_dir_prefix", "/foo2"); // MR2 only - }}); + new HashMap<String,String>() {{ + put("a", "b"); + put("dfs_namenode_name_dir", "/foo3"); // HDFS only + put("mapred_log_dir_prefix", "/foo2"); // MR2 only + }}); Assert.assertTrue(sch1.convertToResponse().isStaleConfig()); Assert.assertTrue(sch2.convertToResponse().isStaleConfig()); Assert.assertFalse(sch3.convertToResponse().isStaleConfig()); + + // Change core-site property, only HDFS property + makeConfig(cluster, "core-site", "version1", + new HashMap<String,String>() {{ + put("a", "b"); + put("fs.trash.interval", "360"); // HDFS only + }}); + + Assert.assertTrue(sch1.convertToResponse().isStaleConfig()); + Assert.assertTrue(sch2.convertToResponse().isStaleConfig()); + Assert.assertTrue(sch3.convertToResponse().isStaleConfig()); + + actual.put("core-site", new HashMap<String, String>() {{ + put("tag", "version1"); + }}); + + sch1.updateActualConfigs(actual); + + final Config c1 = configFactory.createNew(cluster, "core-site", + new HashMap<String, String>() {{ put("fs.trash.interval", "400"); }}); + c1.setVersionTag("version2"); + c1.persist(); + cluster.addConfig(c1); + configGroup = configGroupFactory.createNew(cluster, "g2", + "t2", "", new HashMap<String, Config>() {{ put("core-site", c1); }}, + new HashMap<String, Host>() {{ put("h3", host); }}); + configGroup.persist(); + cluster.addConfigGroup(configGroup); + + Assert.assertTrue(sch1.convertToResponse().isStaleConfig()); + Assert.assertTrue(sch2.convertToResponse().isStaleConfig()); + Assert.assertTrue(sch3.convertToResponse().isStaleConfig()); } /** http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/HDFS/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/HDFS/metainfo.xml b/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/HDFS/metainfo.xml index e679468..d1fc36b 100644 --- a/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/HDFS/metainfo.xml +++ b/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/HDFS/metainfo.xml @@ -51,5 +51,10 @@ <category>SLAVE</category> </component> </components> - + <configuration-dependencies> + <config-type>core-site</config-type> + <config-type>global</config-type> + <config-type>hdfs-site</config-type> + <config-type>hadoop-policy</config-type> + </configuration-dependencies> </metainfo> http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/MAPREDUCE2/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/MAPREDUCE2/metainfo.xml b/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/MAPREDUCE2/metainfo.xml index 363bf12..2868140 100644 --- a/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/MAPREDUCE2/metainfo.xml +++ b/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/MAPREDUCE2/metainfo.xml @@ -29,4 +29,9 @@ <category>CLIENT</category> </component> </components> + <configuration-dependencies> + <config-type>core-site</config-type> + <config-type>global</config-type> + <config-type>mapred-site</config-type> + </configuration-dependencies> </metainfo> http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/YARN/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/YARN/metainfo.xml b/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/YARN/metainfo.xml index 8517e31..b196c83 100644 --- a/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/YARN/metainfo.xml +++ b/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/YARN/metainfo.xml @@ -33,4 +33,8 @@ <category>CLIENT</category> </component> </components> + <configuration-dependencies> + <config-type>yarn-site</config-type> + <config-type>global</config-type> + </configuration-dependencies> </metainfo> http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/86fed01e/ambari-server/src/test/resources/stacks/HDP/2.0.6/services/YARN/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/resources/stacks/HDP/2.0.6/services/YARN/metainfo.xml b/ambari-server/src/test/resources/stacks/HDP/2.0.6/services/YARN/metainfo.xml index 3d31715..6f02f79 100644 --- a/ambari-server/src/test/resources/stacks/HDP/2.0.6/services/YARN/metainfo.xml +++ b/ambari-server/src/test/resources/stacks/HDP/2.0.6/services/YARN/metainfo.xml @@ -39,4 +39,7 @@ <category>CLIENT</category> </component> </components> + <configuration-dependencies> + <config-type>core-site</config-type> + </configuration-dependencies> </metainfo>