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/15 22:09:32 UTC
svn commit: r1457120 - in /incubator/ambari/trunk: ./
ambari-server/src/main/java/org/apache/ambari/server/controller/
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/
ambari-server/src/main/java/org/apache/ambari/server/state/...
Author: ncole
Date: Fri Mar 15 21:09:32 2013
New Revision: 1457120
URL: http://svn.apache.org/r1457120
Log:
AMBARI-1627. Fix to remove host configuration overrides
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/main/java/org/apache/ambari/server/controller/ConfigurationRequest.java
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostTest.java
Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1457120&r1=1457119&r2=1457120&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Fri Mar 15 21:09:32 2013
@@ -512,6 +512,8 @@ Trunk (unreleased changes):
AMBARI-1625. Oozie start fails on secure cluster. (swagle)
+ AMBARI-1627. Fix to remove host configuration overrides. (ncole)
+
AMBARI-1592. Fix configuration propagation.
AMBARI-1619. Fix for category path separators.
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=1457120&r1=1457119&r2=1457120&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 Fri Mar 15 21:09:32 2013
@@ -2777,7 +2777,7 @@ public class AmbariManagementControllerI
Config baseConfig = c.getConfig(cr.getType(), cr.getVersionTag());
if (null != baseConfig)
- h.addDesiredConfig(c.getClusterId(), cr.getServiceName(), baseConfig);
+ h.addDesiredConfig(c.getClusterId(), cr.isSelected(), baseConfig);
}
}
Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigurationRequest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigurationRequest.java?rev=1457120&r1=1457119&r2=1457120&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigurationRequest.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigurationRequest.java Fri Mar 15 21:09:32 2013
@@ -31,7 +31,7 @@ public class ConfigurationRequest {
private String type;
private String tag;
private Map<String, String> configs;
- private String serviceName;
+ private boolean selected = true;
public ConfigurationRequest() {
configs = new HashMap<String, String>();
@@ -107,18 +107,18 @@ public class ConfigurationRequest {
}
/**
- * Sets the service name (for host-level overrides)
- * @param name the service name
+ * Sets if the configuration is selected
+ * @param selected <code>true</code> if the configuration is selected.
*/
- public void setServiceName(String name) {
- serviceName = name;
+ public void setSelected(boolean selected) {
+ this.selected = selected;
}
/**
- * Gets the service name.
- * @return the service name
+ * Gets if the configuration is to be selected.
+ * @return <code>true</code> if the configuration is selected.
*/
- public String getServiceName() {
- return serviceName;
+ public boolean isSelected() {
+ return selected;
}
}
Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java?rev=1457120&r1=1457119&r2=1457120&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java Fri Mar 15 21:09:32 2013
@@ -395,8 +395,9 @@ public abstract class AbstractResourcePr
config.setType(entry.getValue().toString());
else if (propName.equals("tag"))
config.setVersionTag(entry.getValue().toString());
- else if (propName.equals("service_name"))
- config.setServiceName(entry.getValue().toString());
+ else if (propName.equals("selected")) {
+ config.setSelected(Boolean.parseBoolean(entry.getValue().toString()));
+ }
else if (absCategory.endsWith("/properties")) {
config.getProperties().put(propName, entry.getValue().toString());
}
Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java?rev=1457120&r1=1457119&r2=1457120&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java Fri Mar 15 21:09:32 2013
@@ -275,11 +275,11 @@ public interface Host {
/**
* Adds a desired configuration to the host instance.
* @param clusterId the cluster id that the config applies to
- * @param serviceName the name of the service that is the parent. Supply
- * <code>null</code> if the override applies to the cluster definition.
+ * @param selected <code>true</code> if the configuration is selected. Applies
+ * only to remove the override, otherwise this value should always be <code>true</code>.
* @param config the configuration object
*/
- public void addDesiredConfig(long clusterId, String serviceName, Config config);
+ public void addDesiredConfig(long clusterId, boolean selected, Config config);
/**
* Gets all the selected configurations for the host.
Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java?rev=1457120&r1=1457119&r2=1457120&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java Fri Mar 15 21:09:32 2013
@@ -1038,10 +1038,14 @@ public class HostImpl implements Host {
@Override
@Transactional
- public void addDesiredConfig(long clusterId, String serviceName, Config config) {
+ public void addDesiredConfig(long clusterId, boolean selected, Config config) {
HostConfigMappingEntity exist = getDesiredConfigEntity(clusterId, config.getType());
if (null != exist && exist.getVersion().equals(config.getVersionTag())) {
+ if (!selected) {
+ exist.setSelected(0);
+ hostConfigMappingDAO.merge(exist);
+ }
return;
}
@@ -1060,7 +1064,6 @@ public class HostImpl implements Host {
entity.setCreateTimestamp(Long.valueOf(new Date().getTime()));
entity.setHostName(hostEntity.getHostName());
entity.setSelected(1);
- entity.setServiceName(serviceName);
entity.setType(config.getType());
entity.setVersion(config.getVersionTag());
Modified: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java?rev=1457120&r1=1457119&r2=1457120&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java (original)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java Fri Mar 15 21:09:32 2013
@@ -355,7 +355,7 @@ public class ClusterTest {
// setup a host that also has a config override
Host host = clusters.getHost("h1");
- host.addDesiredConfig(c1.getClusterId(), null, config2);
+ host.addDesiredConfig(c1.getClusterId(), true, config2);
desiredConfigs = c1.getDesiredConfigs();
dc = desiredConfigs.get(config1.getType());
Modified: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostTest.java?rev=1457120&r1=1457119&r2=1457120&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostTest.java (original)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostTest.java Fri Mar 15 21:09:32 2013
@@ -370,7 +370,7 @@ public class HostTest {
new HashMap<String,String>() {{ put("a", "b"); put("x", "y"); }});
try {
- host.addDesiredConfig(c1.getClusterId(), null, config);
+ host.addDesiredConfig(c1.getClusterId(), true, config);
Assert.fail("Expect failure when version is not specified.");
}
catch (Exception e) {
@@ -378,7 +378,7 @@ public class HostTest {
}
config.setVersionTag("v1");
- host.addDesiredConfig(c1.getClusterId(), null, config);
+ host.addDesiredConfig(c1.getClusterId(), true, config);
Map<String, DesiredConfig> map = host.getDesiredConfigs(c1.getClusterId());
Assert.assertTrue("Expect desired config to contain global", map.containsKey("global"));
@@ -386,12 +386,16 @@ public class HostTest {
config = configFactory.createNew(c1, "global",
new HashMap<String,String>() {{ put("c", "d"); }});
config.setVersionTag("v2");
- host.addDesiredConfig(c1.getClusterId(), null, config);
+ host.addDesiredConfig(c1.getClusterId(), true, config);
map = host.getDesiredConfigs(c1.getClusterId());
Assert.assertTrue("Expect desired config to contain global", map.containsKey("global"));
Assert.assertEquals("Expect version to be 'v2'",
"v2", map.get("global").getVersion());
+ host.addDesiredConfig(c1.getClusterId(), false, config);
+ map = host.getDesiredConfigs(c1.getClusterId());
+ Assert.assertEquals("Expect no mapping configs", 0, map.size());
+
}
}