ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject git commit: AMBARI-4938. Allow setting empty configuration properties (ncole)
Date Tue, 04 Mar 2014 20:11:37 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 804cebf10 -> e1aa2ddae


AMBARI-4938.  Allow setting empty configuration properties (ncole)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e1aa2dda
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e1aa2dda
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e1aa2dda

Branch: refs/heads/trunk
Commit: e1aa2ddae22c53152a9c3faf3680483210668da5
Parents: 804cebf
Author: Nate Cole <ncole@hortonworks.com>
Authored: Tue Mar 4 12:47:28 2014 -0500
Committer: Nate Cole <ncole@hortonworks.com>
Committed: Tue Mar 4 15:11:11 2014 -0500

----------------------------------------------------------------------
 .../AmbariManagementControllerImpl.java         |  8 ++--
 .../HDP/2.0.6/services/ZOOKEEPER/metainfo.xml   |  1 +
 .../AmbariManagementControllerTest.java         | 45 +++++++++++++++++++-
 3 files changed, 50 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e1aa2dda/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index 10d07b6..3a8760f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -529,7 +529,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     if (null == request.getClusterName() || request.getClusterName().isEmpty()
         || null == request.getType() || request.getType().isEmpty()
         || null == request.getVersionTag() || request.getVersionTag().isEmpty()
-        || null == request.getProperties() || request.getProperties().isEmpty()) {
+        || null == request.getProperties()) {
       throw new IllegalArgumentException("Invalid Arguments,"
           + " clustername, config type, config version and configs should not"
           + " be null or empty");
@@ -895,7 +895,9 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     if (null != request.getDesiredConfig()) {
       ConfigurationRequest cr = request.getDesiredConfig();
 
-      if (null != cr.getProperties() && cr.getProperties().size() > 0) {
+      Config oldConfig = cluster.getDesiredConfigByType(cr.getType());
+      
+      if (null != cr.getProperties()) { 
         LOG.info(MessageFormat.format("Applying configuration with tag ''{0}'' to cluster
''{1}''",
             cr.getVersionTag(),
             request.getClusterName()));
@@ -906,8 +908,8 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
 
       Config baseConfig = cluster.getConfig(cr.getType(), cr.getVersionTag());
       if (null != baseConfig) {
-        Config oldConfig = cluster.getDesiredConfigByType(cr.getType());
         String authName = getAuthName();
+        
         if (cluster.addDesiredConfig(authName, baseConfig)) {
           Logger logger = LoggerFactory.getLogger("configchange");
           logger.info("cluster '" + request.getClusterName() + "' "

http://git-wip-us.apache.org/repos/asf/ambari/blob/e1aa2dda/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/ZOOKEEPER/metainfo.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/ZOOKEEPER/metainfo.xml
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/ZOOKEEPER/metainfo.xml
index 3e048a6..ebe3606 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/ZOOKEEPER/metainfo.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/ZOOKEEPER/metainfo.xml
@@ -65,6 +65,7 @@
       <configuration-dependencies>
         <config-type>global</config-type>
         <config-type>zookeeper-log4j</config-type>
+        <config-type>zoo.cfg</config-type>
       </configuration-dependencies>
     </service>
   </services>

http://git-wip-us.apache.org/repos/asf/ambari/blob/e1aa2dda/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 dcee4bf..d6886b4 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
@@ -9799,7 +9799,50 @@ public class AmbariManagementControllerTest {
     Assert.assertTrue("Service is started, command should create tasks",
         rsr.getTasks().size() > 0);
     
-  }  
+  }
+  
+  @Test
+  public void testEmptyConfigs() throws Exception {
+    String clusterName = "c1";
+    createCluster(clusterName);
+    Cluster cluster =  clusters.getCluster(clusterName);
+    cluster.setDesiredStackVersion(new StackId("HDP-0.1"));
+
+    ClusterRequest cr = new ClusterRequest(null, cluster.getClusterName(), null, null);
+
+    // test null map with no prior
+    cr.setDesiredConfig(
+        new ConfigurationRequest(clusterName, "typeA", "v1", null));
+    controller.updateClusters(Collections.singleton(cr), new HashMap<String, String>());
+    Config config = cluster.getDesiredConfigByType("typeA");
+    Assert.assertNull(config);
+    
+    // test empty map with no prior
+    cr.setDesiredConfig(
+        new ConfigurationRequest(clusterName, "typeA", "v1", new HashMap<String, String>()));
+    controller.updateClusters(Collections.singleton(cr), new HashMap<String, String>());
+    config = cluster.getDesiredConfigByType("typeA");
+    Assert.assertNotNull(config);
+    
+    // test empty properties on a new version
+    cr.setDesiredConfig(
+        new ConfigurationRequest(clusterName, "typeA", "v2", new HashMap<String, String>()));
+    controller.updateClusters(Collections.singleton(cr), new HashMap<String, String>());
+    config = cluster.getDesiredConfigByType("typeA");
+    Assert.assertNotNull(config);
+    Assert.assertEquals(Integer.valueOf(0), Integer.valueOf(config.getProperties().size()));
+    
+    // test new version
+    Map<String, String> map = new HashMap<String, String>();
+    map.clear();
+    map.put("c", "d");
+    cr.setDesiredConfig(
+        new ConfigurationRequest(clusterName, "typeA", "v3", map));
+    controller.updateClusters(Collections.singleton(cr), new HashMap<String, String>());
+    config = cluster.getDesiredConfigByType("typeA");
+    Assert.assertNotNull(config);
+    Assert.assertTrue(config.getProperties().containsKey("c"));
+  }
 }
 
   


Mime
View raw message