ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [4/5] ambari git commit: AMBARI-18681. Add host structured_out to manual task for HOST_ORDERED (Duc Le via ncole)
Date Tue, 08 Nov 2016 20:36:50 GMT
AMBARI-18681. Add host structured_out to manual task for HOST_ORDERED (Duc Le via ncole)


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

Branch: refs/heads/trunk
Commit: 46891797c648639447d5a5404deb999e3cebf996
Parents: 3ce1973
Author: Nate Cole <ncole@hortonworks.com>
Authored: Tue Nov 8 15:26:16 2016 -0500
Committer: Nate Cole <ncole@hortonworks.com>
Committed: Tue Nov 8 15:26:16 2016 -0500

----------------------------------------------------------------------
 .../server/state/stack/upgrade/HostOrderGrouping.java     |  9 ++++++++-
 .../org/apache/ambari/server/state/UpgradeHelperTest.java | 10 ++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/46891797/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/HostOrderGrouping.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/HostOrderGrouping.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/HostOrderGrouping.java
index b999f2f..623fb76 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/HostOrderGrouping.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/HostOrderGrouping.java
@@ -36,12 +36,15 @@ import org.apache.commons.collections.CollectionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.gson.JsonObject;
+
 /**
  * Marker group for Host-Ordered upgrades.
  */
 @XmlType(name="host-order")
 public class HostOrderGrouping extends Grouping {
-
+  private static final String TYPE = "type";
+  private static final String HOST = "host";
   private static Logger LOG = LoggerFactory.getLogger(HostOrderGrouping.class);
 
   /**
@@ -172,6 +175,10 @@ public class HostOrderGrouping extends Grouping {
 
         ManualTask mt = new ManualTask();
         mt.messages.add(message);
+        JsonObject structuredOut = new JsonObject();
+        structuredOut.addProperty(TYPE, HostOrderItem.HostOrderActionType.HOST_UPGRADE.toString());
+        structuredOut.addProperty(HOST, hostName);
+        mt.structuredOut = structuredOut.toString();
 
         StageWrapper manualWrapper = new StageWrapper(StageWrapper.Type.SERVER_SIDE_ACTION,
"Manual Confirmation",
             new TaskWrapper(null, null, Collections.<String>emptySet(), mt));

http://git-wip-us.apache.org/repos/asf/ambari/blob/46891797/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
index 78969e4..6b4b85a 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
@@ -1959,6 +1959,16 @@ public class UpgradeHelperTest {
         assertEquals(StageWrapper.Type.STOP, w.getType());
       } else if (i == 1 || i == 4) {
         assertEquals(StageWrapper.Type.SERVER_SIDE_ACTION, w.getType());
+        assertEquals(1, w.getTasks().size());
+        assertEquals(1, w.getTasks().get(0).getTasks().size());
+        Task t = w.getTasks().get(0).getTasks().get(0);
+        assertEquals(ManualTask.class, t.getClass());
+        ManualTask mt = (ManualTask) t;
+        assertNotNull(mt.structuredOut);
+        assertTrue(mt.structuredOut.contains("type"));
+        assertTrue(mt.structuredOut.contains(HostOrderItem.HostOrderActionType.HOST_UPGRADE.toString()));
+        assertTrue(mt.structuredOut.contains("host"));
+        assertTrue(mt.structuredOut.contains(i == 1 ? "h1" : "h2"));
       } else {
         assertEquals(StageWrapper.Type.RESTART, w.getType());
       }


Mime
View raw message