You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2013/04/22 22:27:23 UTC
svn commit: r1470703 - in /incubator/ambari/trunk: ./
ambari-server/src/main/java/org/apache/ambari/server/controller/
ambari-server/src/test/java/org/apache/ambari/server/controller/
Author: ncole
Date: Mon Apr 22 20:27:22 2013
New Revision: 1470703
URL: http://svn.apache.org/r1470703
Log:
AMBARI-1977. Honor service configs if there are no matching cluster configs
Modified:
incubator/ambari/trunk/CHANGES.txt
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1470703&r1=1470702&r2=1470703&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Mon Apr 22 20:27:22 2013
@@ -1219,6 +1219,8 @@ Trunk (unreleased changes):
AMBARI-1657. User directories on HDFS do not get created with custom names
provided from Ambari UI. (swagle)
+ AMBARI-1977. Honor service configs when there are no matching cluster configs (ncole)
+
AMBARI-1976. When host expires, update each component for host with unknown state. (ncole)
AMBARI-1980. Fix for nagios_alerts element when there is an error. (ncole)
Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java?rev=1470703&r1=1470702&r2=1470703&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java Mon Apr 22 20:27:22 2013
@@ -1915,9 +1915,6 @@ public class AmbariManagementControllerI
// 2) override (1) with service-specific overrides
// 3) override (2) with host-specific overrides
- // since we are dealing with host components in this loop, get the
- // config mappings for the service this host component applies to
-
for (Entry<String, DesiredConfig> entry : cluster.getDesiredConfigs().entrySet()) {
String type = entry.getKey();
String tag = entry.getValue().getVersion();
@@ -1948,10 +1945,28 @@ public class AmbariManagementControllerI
tags.put("host_override_tag", hostConfig.getVersionTag());
}
}
-
+
configurations.put(type, props);
configTags.put(type, tags);
}
+
+ // HACK HACK HACK if the service has configs that are NOT included
+ // in cluster-level, then use them anyway. THIS IS GENERALLY A BAD
+ // IDEA, but is included for backward compatability. Do not check host
+ // overrides, because that wasn't in the version where this code would
+ // be the case.
+ Service service = cluster.getService(serviceName);
+ for (Config c : service.getDesiredConfigs().values()) {
+ String type = c.getType();
+ if (!configurations.containsKey(type)) {
+ configurations.put(type, new HashMap<String,String>(c.getProperties()));
+
+ HashMap<String,String> tags = new HashMap<String,String>();
+ tags.put("tag", c.getVersionTag());
+ configTags.put(type, tags);
+ }
+ }
+
}
private List<Stage> doStageCreation(Cluster cluster,
Modified: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java?rev=1470703&r1=1470702&r2=1470703&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java (original)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java Mon Apr 22 20:27:22 2013
@@ -4697,6 +4697,95 @@ public class AmbariManagementControllerT
}
Assert.assertEquals(true, serviceCheckFound);
}
+
+ @Test
+ public void testConfigsAttachedToServiceNotCluster() throws AmbariException {
+ String clusterName = "foo1";
+ createCluster(clusterName);
+ clusters.getCluster(clusterName).setDesiredStackVersion(new StackId("HDP-0.1"));
+
+ String serviceName = "HDFS";
+ createService(clusterName, serviceName, null);
+ String componentName1 = "NAMENODE";
+ String componentName2 = "DATANODE";
+ String componentName3 = "HDFS_CLIENT";
+
+ Map<String, String> mapRequestProps = new HashMap<String, String>();
+ mapRequestProps.put("context", "Called from a test");
+
+ createServiceComponent(clusterName, serviceName, componentName1,
+ State.INIT);
+ createServiceComponent(clusterName, serviceName, componentName2,
+ State.INIT);
+ createServiceComponent(clusterName, serviceName, componentName3,
+ State.INIT);
+
+ String host1 = "h1";
+ clusters.addHost(host1);
+ clusters.getHost("h1").setOsType("centos5");
+ clusters.getHost("h1").persist();
+ String host2 = "h2";
+ clusters.addHost(host2);
+ clusters.getHost("h2").setOsType("centos6");
+ clusters.getHost("h2").persist();
+
+ clusters.mapHostToCluster(host1, clusterName);
+ clusters.mapHostToCluster(host2, clusterName);
+
+
+ // null service should work
+ createServiceComponentHost(clusterName, null, componentName1,
+ host1, null);
+ createServiceComponentHost(clusterName, serviceName, componentName2,
+ host1, null);
+ createServiceComponentHost(clusterName, serviceName, componentName2,
+ host2, null);
+ createServiceComponentHost(clusterName, serviceName, componentName3,
+ host1, null);
+ createServiceComponentHost(clusterName, serviceName, componentName3,
+ host2, null);
+
+ // Create and attach config
+ Map<String, String> configs = new HashMap<String, String>();
+ configs.put("a", "b");
+
+ ConfigurationRequest cr1,cr2;
+ cr1 = new ConfigurationRequest(clusterName, "core-site","version1",
+ configs);
+ cr2 = new ConfigurationRequest(clusterName, "hdfs-site","version1",
+ configs);
+
+ // create, but don't assign
+ controller.createConfiguration(cr1);
+ controller.createConfiguration(cr2);
+
+ Map<String,String> configVersions = new HashMap<String,String>() {{
+ put("core-site", "version1");
+ put("hdfs-site", "version1");
+ }};
+ ServiceRequest sr = new ServiceRequest(clusterName, serviceName, configVersions, null);
+ controller.updateServices(Collections.singleton(sr), new HashMap<String,String>(), false, false);
+
+ // Install
+ installService(clusterName, serviceName, false, false);
+ // Start
+ long requestId = startService(clusterName, serviceName, true, false);
+
+ Assert.assertEquals(0, clusters.getCluster(clusterName).getDesiredConfigs().size());
+
+ List<Stage> stages = actionDB.getAllStages(requestId);
+ boolean serviceCheckFound = false;
+ for (Stage stage : stages) {
+ for (HostRoleCommand hrc : stage.getOrderedHostRoleCommands()) {
+ if (hrc.getRole().equals(Role.HDFS_SERVICE_CHECK)) {
+ serviceCheckFound = true;
+ Assert.assertEquals(2, hrc.getExecutionCommandWrapper()
+ .getExecutionCommand().getConfigurationTags().size());
+ }
+ }
+ }
+ Assert.assertEquals(true, serviceCheckFound);
+ }
@Test
public void testStackVersionAsHostLevelParams() throws AmbariException {