ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject [1/2] ambari git commit: AMBARI-18415. Stack definition: service component 'cardinality' inheritance not working properly (aonishuk)
Date Mon, 19 Sep 2016 13:54:52 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 24ec8483b -> f4cb404d7
  refs/heads/trunk 64fc477df -> d1ac8bd89


AMBARI-18415. Stack definition: service component 'cardinality' inheritance not working properly
(aonishuk)


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

Branch: refs/heads/trunk
Commit: d1ac8bd89403047a145b185b78c2073f09264472
Parents: 64fc477
Author: Andrew Onishuk <aonishuk@hortonworks.com>
Authored: Mon Sep 19 16:54:45 2016 +0300
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Mon Sep 19 16:54:45 2016 +0300

----------------------------------------------------------------------
 .../apache/ambari/server/stack/ComponentModule.java  |  3 +++
 .../apache/ambari/server/state/ComponentInfo.java    |  2 +-
 .../ambari/server/stack/ComponentModuleTest.java     | 15 ++++++++++-----
 3 files changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d1ac8bd8/ambari-server/src/main/java/org/apache/ambari/server/stack/ComponentModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/stack/ComponentModule.java
b/ambari-server/src/main/java/org/apache/ambari/server/stack/ComponentModule.java
index 537ae32..a90ea1a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/stack/ComponentModule.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/stack/ComponentModule.java
@@ -122,6 +122,9 @@ public class ComponentModule extends BaseModule<ComponentModule, ComponentInfo>
               componentInfo.getCustomCommands());
 
       mergeLogs(parentInfo.getLogs(), componentInfo.getLogs());
+    } else {
+      //set cardinality with default value "0+" if it was not provided and parent is absent.
+      componentInfo.setCardinality("0+");
     }
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d1ac8bd8/ambari-server/src/main/java/org/apache/ambari/server/state/ComponentInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ComponentInfo.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/ComponentInfo.java
index 2dae526..1e494b4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ComponentInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ComponentInfo.java
@@ -36,7 +36,7 @@ public class ComponentInfo {
   private String displayName;
   private String category;
   private boolean deleted;
-  private String cardinality = "0+";
+  private String cardinality;
   
   @XmlElement(name="versionAdvertised")
   private Boolean versionAdvertisedField;

http://git-wip-us.apache.org/repos/asf/ambari/blob/d1ac8bd8/ambari-server/src/test/java/org/apache/ambari/server/stack/ComponentModuleTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/stack/ComponentModuleTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/stack/ComponentModuleTest.java
index 905707c..519e5f3 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/stack/ComponentModuleTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/stack/ComponentModuleTest.java
@@ -155,11 +155,14 @@ public class ComponentModuleTest {
     String cardinality = "foo";
 
     ComponentInfo info = new ComponentInfo();
-    ComponentInfo parentInfo = new ComponentInfo();
+    // parent is null, child cardinality is null
+    assertEquals("0+", resolveComponent(info, null).getModuleInfo().getCardinality());
 
+    ComponentInfo parentInfo = new ComponentInfo();
+    info = new ComponentInfo();
     // parent has value set, child value is null
     parentInfo.setCardinality(cardinality);
-    assertEquals("0+", resolveComponent(info, parentInfo).getModuleInfo().getCardinality());
+    assertEquals("foo", resolveComponent(info, parentInfo).getModuleInfo().getCardinality());
 
     // child has value set, parent value is null
     info.setCardinality(cardinality);
@@ -552,10 +555,12 @@ public class ComponentModuleTest {
 
   private ComponentModule resolveComponent(ComponentInfo info, ComponentInfo parentInfo)
{
     info.setName("FOO");
-    parentInfo.setName("FOO");
-
     ComponentModule component = new ComponentModule(info);
-    ComponentModule parentComponent = new ComponentModule(parentInfo);
+    ComponentModule parentComponent = null;
+    if (parentInfo != null) {
+      parentInfo.setName("FOO");
+      parentComponent = new ComponentModule(parentInfo);
+    }
 
     component.resolve(parentComponent, Collections.<String, StackModule>emptyMap(),
Collections.<String, ServiceModule>emptyMap(), Collections.<String, ExtensionModule>emptyMap());
 


Mime
View raw message