ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jspei...@apache.org
Subject git commit: AMBARI-7835. Blueprint export now properly handles configurations with no properties.
Date Tue, 21 Oct 2014 14:46:43 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 55fe12731 -> 64a73207e


AMBARI-7835.  Blueprint export now properly handles configurations with no properties.


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

Branch: refs/heads/trunk
Commit: 64a73207ec4a4131af420a84e374b94f4ee7c220
Parents: 55fe127
Author: Robert Nettleton <rnettleton@hortonworks.com>
Authored: Tue Oct 21 10:44:19 2014 -0400
Committer: John Speidel <jspeidel@hortonworks.com>
Committed: Tue Oct 21 10:44:19 2014 -0400

----------------------------------------------------------------------
 .../query/render/ClusterBlueprintRenderer.java  | 15 ++++-
 .../render/ClusterBlueprintRendererTest.java    | 65 ++++++++++++++++++--
 2 files changed, 75 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/64a73207/ambari-server/src/main/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRenderer.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRenderer.java
b/ambari-server/src/main/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRenderer.java
index 1afae39..847735d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRenderer.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRenderer.java
@@ -37,6 +37,8 @@ import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.apache.ambari.server.state.DesiredConfig;
 import org.apache.ambari.server.state.HostConfig;
 import org.apache.ambari.server.state.PropertyInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.net.InetAddress;
 import java.net.UnknownHostException;
@@ -66,6 +68,8 @@ public class ClusterBlueprintRenderer extends BaseRenderer implements Renderer
{
    */
   private Map<String, Collection<String>> propertiesToStrip = new HashMap<String,
Collection<String>>();
 
+  private final static Logger LOG = LoggerFactory.getLogger(ClusterBlueprintRenderer.class);
+
 
   // ----- Renderer ----------------------------------------------------------
 
@@ -538,7 +542,16 @@ public class ClusterBlueprintRenderer extends BaseRenderer implements
Renderer {
 
       // property map type is currently <String, Object>
       properties = (Map) configNode.getObject().getPropertiesMap().get("properties");
-      stripRequiredProperties(properties);
+
+      if (properties != null) {
+        stripRequiredProperties(properties);
+      } else {
+        LOG.warn("Empty configuration found for configuration type = " + type +
+          " during Blueprint export.  This may occur after an upgrade of Ambari, when" +
+          "attempting to export a Blueprint from a cluster started by an older version of
" +
+          "Ambari.");
+      }
+
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/64a73207/ambari-server/src/test/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRendererTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRendererTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRendererTest.java
index 04d86ad..6e58267 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRendererTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRendererTest.java
@@ -31,7 +31,6 @@ import org.apache.ambari.server.controller.AmbariManagementController;
 import org.apache.ambari.server.controller.internal.ResourceImpl;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.state.PropertyInfo;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import java.net.InetAddress;
@@ -99,7 +98,6 @@ public class ClusterBlueprintRendererTest {
     assertTrue(propertyTree.getChild("Host/HostComponent").getObject().contains("HostRoles/component_name"));
   }
 
-  @Ignore
   @Test
   public void testFinalizeResult() throws Exception{
 
@@ -124,7 +122,6 @@ public class ClusterBlueprintRendererTest {
     Resource blueprintResource = blueprintNode.getObject();
     Map<String, Map<String, Object>> properties = blueprintResource.getPropertiesMap();
 
-    assertEquals("blueprint-testCluster", properties.get("Blueprints").get("blueprint_name"));
     assertEquals("HDP", properties.get("Blueprints").get("stack_name"));
     assertEquals("1.3.3", properties.get("Blueprints").get("stack_version"));
 
@@ -176,11 +173,71 @@ public class ClusterBlueprintRendererTest {
   //todo: collection resource
 
   private void createClusterResultTree(TreeNode<Resource> resultTree) throws Exception{
-    Resource clusterResource = new ResourceImpl(Resource.Type.Cluster);
+    Resource clusterResource = new ResourceImpl(Resource.Type.Cluster) {
+      @Override
+      public Map<String, Map<String, Object>> getPropertiesMap() {
+        Map<String, Map<String, Object>> originalMap =
+          super.getPropertiesMap();
+
+        // override the properties map for simpler testing
+        originalMap.put("Clusters/desired_configs", Collections.<String, Object>emptyMap());
+
+        return originalMap;
+      };
+
+    };
+
     clusterResource.setProperty("Clusters/cluster_name", "testCluster");
     clusterResource.setProperty("Clusters/version", "HDP-1.3.3");
+
     TreeNode<Resource> clusterTree = resultTree.addChild(clusterResource, "Cluster:1");
 
+    // add empty services resource for basic unit testing
+    Resource servicesResource = new ResourceImpl(Resource.Type.Service);
+    clusterTree.addChild(servicesResource, "services");
+
+
+    Resource configurationsResource = new ResourceImpl(Resource.Type.Configuration);
+    TreeNode<Resource> configurations = clusterTree.addChild(configurationsResource,
"configurations");
+    Resource resourceOne = new ResourceImpl(Resource.Type.Configuration) {
+      @Override
+      public Map<String, Map<String, Object>> getPropertiesMap() {
+        Map<String, Map<String, Object>> originalMap =
+        super.getPropertiesMap();
+
+        // return null for properties, to simulate upgrade case
+        originalMap.put("properties", null);
+
+        return originalMap;
+      }
+    };
+
+    resourceOne.setProperty("type", "mapreduce-log4j");
+
+    configurations.addChild(resourceOne, "resourceOne");
+
+
+    Resource resourceTwo = new ResourceImpl(Resource.Type.Configuration) {
+      @Override
+      public Map<String, Map<String, Object>> getPropertiesMap() {
+        Map<String, Map<String, Object>> originalMap =
+          super.getPropertiesMap();
+
+        // return test properties, to simluate valid configuration entry
+        originalMap.put("properties", Collections.<String, Object>singletonMap("propertyOne",
"valueOne"));
+
+        return originalMap;
+      }
+    };
+
+    resourceTwo.setProperty("type", "test-type-one");
+
+    configurations.addChild(resourceTwo, "resourceTwo");
+
+    Resource blueprintOne = new ResourceImpl(Resource.Type.Blueprint);
+    blueprintOne.setProperty("Blueprints/blueprint_name", "blueprint-testCluster");
+    clusterTree.addChild(blueprintOne, "Blueprints");
+
     TreeNode<Resource> hostsTree = clusterTree.addChild(null, "hosts");
     hostsTree.setProperty("isCollection", "true");
 


Mime
View raw message