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/03/26 19:01:30 UTC
svn commit: r1461246 - 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: Tue Mar 26 18:01:30 2013
New Revision: 1461246
URL: http://svn.apache.org/r1461246
Log:
AMBARI-1703. Fix for smoke test not getting new configurations
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=1461246&r1=1461245&r2=1461246&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Tue Mar 26 18:01:30 2013
@@ -568,6 +568,8 @@ Trunk (unreleased changes):
AMBARI-1657. User directories on HDFS do not get created with custom names
provided from Ambari UI. (swagle)
+ AMBARI-1703. Fix for smoke tests getting configurations. (ncole)
+
AMBARI-1678. Fix when there are no service overrides. (ncole)
AMBARI-1655. DELETE is not successful against ClusterStateEntity (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=1461246&r1=1461245&r2=1461246&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 Tue Mar 26 18:01:30 2013
@@ -3865,13 +3865,47 @@ public class AmbariManagementControllerI
stage.getExecutionCommandWrapper(hostName, actionRequest.getActionName()).getExecutionCommand()
.setRoleParams(actionRequest.getParameters());
- Map<String, Map<String, String>> configurations = new TreeMap<String, Map<String, String>>();
- Map<String, Config> allConfigs = clusters.getCluster(clusterName)
- .getService(actionRequest.getServiceName()).getDesiredConfigs();
- if (allConfigs != null) {
- for (Map.Entry<String, Config> entry: allConfigs.entrySet()) {
- configurations.put(entry.getValue().getType(), entry.getValue().getProperties());
+ Cluster cluster = clusters.getCluster(clusterName);
+
+ // [ type -> [ key, value ] ]
+ Map<String, Map<String, String>> configurations = new TreeMap<String, Map<String,String>>();
+
+ // Do not use service config mappings. Instead, the rules are:
+ // 1) Use the cluster desired config
+ // 2) override (1) with service-specific overrides
+ // 3) override (2) with host-specific overrides
+ // Yes, we may be sending more configs than are actually used, but that is
+ // because of the new design
+
+ for (Entry<String, DesiredConfig> entry : cluster.getDesiredConfigs().entrySet()) {
+ String type = entry.getKey();
+ String tag = entry.getValue().getVersion();
+ // 1) start with cluster config
+ Config config = cluster.getConfig(type, tag);
+
+ if (null == config)
+ continue;
+
+ Map<String, String> props = new HashMap<String, String>(config.getProperties());
+
+ // 2) apply the service overrides, if any are defined with different tags
+ Service service = cluster.getService(actionRequest.getServiceName());
+ Config svcConfig = service.getDesiredConfigs().get(type);
+ if (null != svcConfig && !svcConfig.getVersionTag().equals(tag)) {
+ props.putAll(svcConfig.getProperties());
+ }
+
+ // 3) apply the host overrides, if any
+ Host host = clusters.getHost(hostName);
+ DesiredConfig dc = host.getDesiredConfigs(cluster.getClusterId()).get(type);
+ if (null != dc) {
+ Config hostConfig = cluster.getConfig(type, dc.getVersion());
+ if (null != hostConfig) {
+ props.putAll(hostConfig.getProperties());
+ }
}
+
+ configurations.put(type, props);
}
ExecutionCommand execCmd = stage.getExecutionCommandWrapper(hostName,
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=1461246&r1=1461245&r2=1461246&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 Tue Mar 26 18:01:30 2013
@@ -20,6 +20,7 @@ package org.apache.ambari.server.control
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.util.ArrayList;
@@ -60,6 +61,7 @@ import org.apache.ambari.server.serverac
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.Config;
+import org.apache.ambari.server.state.ConfigFactory;
import org.apache.ambari.server.state.ConfigImpl;
import org.apache.ambari.server.state.Host;
import org.apache.ambari.server.state.Service;
@@ -3356,6 +3358,21 @@ public class AmbariManagementControllerT
Cluster cluster = clusters.getCluster("c1");
cluster.setDesiredStackVersion(new StackId("HDP-0.1"));
+
+ ConfigFactory cf = injector.getInstance(ConfigFactory.class);
+ Config config1 = cf.createNew(cluster, "global",
+ new HashMap<String, String>(){{ put("key1", "value1"); }});
+ config1.setVersionTag("version1");
+
+ Config config2 = cf.createNew(cluster, "core-site",
+ new HashMap<String, String>(){{ put("key1", "value1"); }});
+ config2.setVersionTag("version1");
+
+ cluster.addConfig(config1);
+ cluster.addConfig(config2);
+ cluster.addDesiredConfig(config1);
+ cluster.addDesiredConfig(config2);
+
Service hdfs = cluster.addService("HDFS");
Service mapReduce = cluster.addService("MAPREDUCE");
hdfs.persist();
@@ -3375,6 +3392,7 @@ public class AmbariManagementControllerT
actionRequests.add(actionRequest);
RequestStatusResponse response = controller.createActions(actionRequests);
+
assertEquals(1, response.getTasks().size());
ShortTaskStatus task = response.getTasks().get(0);
@@ -3388,7 +3406,9 @@ public class AmbariManagementControllerT
assertEquals(actionRequest.getActionName(), hostRoleCommand.getExecutionCommandWrapper().getExecutionCommand().getRole().name());
assertEquals(Role.HDFS_CLIENT.name(), hostRoleCommand.getEvent().getEvent().getServiceComponentName());
assertEquals(actionRequest.getParameters(), hostRoleCommand.getExecutionCommandWrapper().getExecutionCommand().getRoleParams());
-
+ assertNotNull(hostRoleCommand.getExecutionCommandWrapper().getExecutionCommand().getConfigurations());
+ assertEquals(2, hostRoleCommand.getExecutionCommandWrapper().getExecutionCommand().getConfigurations().size());
+
actionRequests.add(new ActionRequest("c1", "MAPREDUCE", Role.MAPREDUCE_SERVICE_CHECK.name(), null));
response = controller.createActions(actionRequests);