ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject ambari git commit: AMBARI-9820. RU change for correctness - reduce the slave percentage to 20 percent and provide host info to the task (ncole)
Date Thu, 26 Feb 2015 21:11:18 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk f701b9c7b -> 2068caa7e


AMBARI-9820. RU change for correctness - reduce the slave percentage to 20 percent and provide
host info to the task (ncole)


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

Branch: refs/heads/trunk
Commit: 2068caa7ebc029752b0db1eaef1372177e7003ba
Parents: f701b9c
Author: Nate Cole <ncole@hortonworks.com>
Authored: Thu Feb 26 13:36:41 2015 -0500
Committer: Nate Cole <ncole@hortonworks.com>
Committed: Thu Feb 26 15:31:35 2015 -0500

----------------------------------------------------------------------
 .../state/stack/upgrade/ColocatedGrouping.java  | 70 ++++++++++++++++++++
 .../stacks/HDP/2.2/upgrades/upgrade-2.2.xml     |  4 +-
 .../ambari/server/state/UpgradeHelperTest.java  | 15 +++++
 .../stacks/HDP/2.1.1/upgrades/upgrade_test.xml  |  2 +-
 4 files changed, 88 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2068caa7/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ColocatedGrouping.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ColocatedGrouping.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ColocatedGrouping.java
index 55a6aa4..6252d4e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ColocatedGrouping.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ColocatedGrouping.java
@@ -19,6 +19,7 @@ package org.apache.ambari.server.state.stack.upgrade;
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -36,6 +37,10 @@ import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
 /**
  * Used for co-located services grouped together.
  */
@@ -150,9 +155,11 @@ public class ColocatedGrouping extends Grouping {
       results.addAll(befores);
 
       if (!befores.isEmpty()) {
+
         ManualTask task = new ManualTask();
         task.summary = m_batch.summary;
         task.message = m_batch.message;
+        formatFirstBatch(ctx, task, befores);
 
         StageWrapper wrapper = new StageWrapper(
             StageWrapper.Type.SERVER_SIDE_ACTION,
@@ -222,6 +229,69 @@ public class ColocatedGrouping extends Grouping {
       return results;
     }
 
+    /**
+     * Formats the first batch's text and adds json for use if needed.
+     * @param ctx       the upgrade context to load component display names
+     * @param task      the manual task representing the verification message
+     * @param wrappers  the list of stage wrappers
+     */
+    private void formatFirstBatch(UpgradeContext ctx, ManualTask task, List<StageWrapper>
wrappers) {
+      List<String> compNames = new ArrayList<String>();
+      Map<String, Set<String>> compLocations = new HashMap<String, Set<String>>();
+
+      for (StageWrapper sw : wrappers) {
+        for (TaskWrapper tw : sw.getTasks()) {
+          if (StringUtils.isNotEmpty(tw.getService()) &&
+              StringUtils.isNotBlank(tw.getComponent())) {
+
+            for (String host : tw.getHosts()) {
+              if (!compLocations.containsKey(host)) {
+                compLocations.put(host, new HashSet<String>());
+              }
+              compLocations.get(host).add(tw.getComponent());
+            }
+
+            compNames.add(ctx.getComponentDisplay(
+                tw.getService(), tw.getComponent()));
+          }
+        }
+      }
+
+      // !!! add the display names to the message, if needed
+      if (task.message.contains("{{components}}")) {
+        StringBuilder sb = new StringBuilder();
+
+        if (compNames.size() == 1) {
+          sb.append(compNames.get(0));
+        } else if (compNames.size() > 1) {
+          String last = compNames.remove(compNames.size() - 1);
+          sb.append(StringUtils.join(compNames, ", "));
+          sb.append(" and ").append(last);
+        }
+
+        task.message = task.message.replace("{{components}}", sb.toString());
+      }
+
+      // !!! build the structured out to attach to the manual task
+      JsonArray arr = new JsonArray();
+      for (Entry<String, Set<String>> entry : compLocations.entrySet()) {
+        JsonObject obj = new JsonObject();
+        obj.addProperty("host_name", entry.getKey());
+
+        JsonArray comps = new JsonArray();
+        for (String comp : entry.getValue()) {
+          comps.add(new JsonPrimitive(comp));
+        }
+        obj.add("components", comps);
+
+        arr.add(obj);
+      }
+
+      JsonObject master = new JsonObject();
+      master.add("topology", arr);
+
+      task.structuredOut = master.toString();
+    }
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/2068caa7/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.2.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.2.xml b/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.2.xml
index ced9271..539b3e7 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.2.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.2.xml
@@ -114,9 +114,9 @@
       </service>
 
       <batch>
-        <percent>33</percent>
+        <percent>20</percent>
         <summary>Verification Required</summary>
-        <message>Core Services have been {{direction.past}}. You are advised to perform
cluster/workload-specific tests against your cluster to ensure proper operation before proceeding
with {{direction.text}} of the remaining services.</message>
+        <message>The initial batch of {{components}} hosts have been {{direction.past}}.
You are advised to check the hosts and perform cluster/workload-specific tests against your
cluster to ensure proper operation before proceeding with {{direction.text}} of the remaining
services.</message>
       </batch>
     </group>
     

http://git-wip-us.apache.org/repos/asf/ambari/blob/2068caa7/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 7e6047b..4a733b3 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
@@ -48,6 +48,7 @@ import org.apache.ambari.server.state.stack.upgrade.ConfigureTask;
 import org.apache.ambari.server.state.stack.upgrade.Direction;
 import org.apache.ambari.server.state.stack.upgrade.ManualTask;
 import org.apache.ambari.server.state.stack.upgrade.StageWrapper;
+import org.apache.ambari.server.state.stack.upgrade.Task;
 import org.apache.ambari.server.state.stack.upgrade.TaskWrapper;
 import org.easymock.EasyMock;
 import org.junit.After;
@@ -155,6 +156,20 @@ public class UpgradeHelperTest {
     assertTrue(group.items.get(1).getText().contains("ZooKeeper1 Server2"));
     assertEquals(group.items.get(5).getText(), "Service Check Zk");
 
+    group = groups.get(3);
+    assertEquals(8, group.items.size());
+    StageWrapper sw = group.items.get(3);
+    assertEquals("Validate Partial Upgrade", sw.getText());
+    assertEquals(1, sw.getTasks().size());
+    assertEquals(1, sw.getTasks().get(0).getTasks().size());
+    Task t = sw.getTasks().get(0).getTasks().get(0);
+    assertEquals(ManualTask.class, t.getClass());
+    ManualTask mt = (ManualTask) t;
+    assertTrue(mt.message.contains("DataNode and NodeManager"));
+    assertNotNull(mt.structuredOut);
+    assertTrue(mt.structuredOut.contains("DATANODE"));
+    assertTrue(mt.structuredOut.contains("NODEMANAGER"));
+
     UpgradeGroupHolder postGroup = groups.get(5);
     assertEquals(postGroup.name, "POST_CLUSTER");
     assertEquals(postGroup.title, "Finalize Upgrade");

http://git-wip-us.apache.org/repos/asf/ambari/blob/2068caa7/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test.xml b/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test.xml
index a9b1cad..088d15f 100644
--- a/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test.xml
+++ b/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test.xml
@@ -76,7 +76,7 @@
       
       <batch>
         <percent>20</percent>
-        <message>Please run additional tests</message>
+        <message>Please run additional tests on {{components}}</message>
       </batch>
     </group>
     


Mime
View raw message