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-17904. Downgrade Schedules Manual & Configuration Tasks For Components Which Didn't Upgrade (ncole)
Date Wed, 27 Jul 2016 02:48:25 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 eb4f14b6b -> aac5c9d58


AMBARI-17904. Downgrade Schedules Manual & Configuration Tasks For Components Which Didn't
Upgrade (ncole)


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

Branch: refs/heads/branch-2.4
Commit: aac5c9d582264d02f821a3b8696ab37abbc332d0
Parents: eb4f14b
Author: Nate Cole <ncole@hortonworks.com>
Authored: Tue Jul 26 22:48:17 2016 -0400
Committer: Nate Cole <ncole@hortonworks.com>
Committed: Tue Jul 26 22:48:17 2016 -0400

----------------------------------------------------------------------
 .../state/stack/upgrade/TaskWrapperBuilder.java |  6 +-
 .../ambari/server/state/UpgradeHelperTest.java  | 90 ++++++++++++++++++++
 2 files changed, 95 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/aac5c9d5/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/TaskWrapperBuilder.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/TaskWrapperBuilder.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/TaskWrapperBuilder.java
index f2ef8f0..36e71f9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/TaskWrapperBuilder.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/TaskWrapperBuilder.java
@@ -55,9 +55,13 @@ public class TaskWrapperBuilder {
     List<TaskWrapper> collection = new ArrayList<TaskWrapper>();
     for (Task t : tasks) {
       if (t.getType().equals(Task.Type.CONFIGURE) || t.getType().equals(Task.Type.MANUAL))
{
-        collection.add(new TaskWrapper(service, component, Collections.singleton(ambariServerHostname),
params, t));
+        // only add the CONFIGURE/MANUAL task if there are actual hosts for the service/component
+        if (null != hostsType.hosts && !hostsType.hosts.isEmpty()) {
+          collection.add(new TaskWrapper(service, component, Collections.singleton(ambariServerHostname),
params, t));
+        }
         continue;
       }
+
       if (t.getType().equals(Task.Type.EXECUTE)) {
         ExecuteTask et = (ExecuteTask) t;
         if (et.hosts == ExecuteHostType.MASTER) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/aac5c9d5/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 55b44bf..55cb23b 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
@@ -70,6 +70,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.springframework.security.core.context.SecurityContextHolder;
 
+import com.google.common.collect.Lists;
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
 import com.google.inject.Binder;
@@ -1647,6 +1648,95 @@ public class UpgradeHelperTest {
     assertEquals("Stopping ZooKeeper Server on h1 (Batch 1 of 3)", group.items.get(0).getText());
   }
 
+  @Test
+  public void testOrchestrationNoServerSideOnDowngrade() throws Exception {
+    Clusters clusters = injector.getInstance(Clusters.class);
+    ServiceFactory serviceFactory = injector.getInstance(ServiceFactory.class);
+
+    String clusterName = "c1";
+
+    StackId stackId = new StackId("HDP-2.1.1");
+    StackId stackId2 = new StackId("HDP-2.2.0");
+    clusters.addCluster(clusterName, stackId);
+    Cluster c = clusters.getCluster(clusterName);
+
+    helper.getOrCreateRepositoryVersion(stackId,
+        c.getDesiredStackVersion().getStackVersion());
+    helper.getOrCreateRepositoryVersion(stackId2,"2.2.0");
+
+    c.createClusterVersion(stackId,
+        c.getDesiredStackVersion().getStackVersion(), "admin",
+        RepositoryVersionState.INSTALLING);
+
+    for (int i = 0; i < 2; i++) {
+      String hostName = "h" + (i+1);
+      clusters.addHost(hostName);
+      Host host = clusters.getHost(hostName);
+
+      Map<String, String> hostAttributes = new HashMap<String, String>();
+      hostAttributes.put("os_family", "redhat");
+      hostAttributes.put("os_release_version", "6");
+
+      host.setHostAttributes(hostAttributes);
+
+      host.persist();
+      clusters.mapHostToCluster(hostName, clusterName);
+    }
+
+    // !!! add storm
+    c.addService(serviceFactory.createNew(c, "STORM"));
+
+    Service s = c.getService("STORM");
+    ServiceComponent sc = s.addServiceComponent("NIMBUS");
+    ServiceComponentHost sch1 = sc.addServiceComponentHost("h1");
+    ServiceComponentHost sch2 = sc.addServiceComponentHost("h2");
+
+    UpgradePack upgradePack = new UpgradePack() {
+      @Override
+      public List<Grouping> getGroups(Direction direction) {
+
+        Grouping g = new Grouping();
+
+        OrderService orderService = new OrderService();
+        orderService.serviceName = "STORM";
+        orderService.components = Collections.singletonList("NIMBUS");
+
+        g.name = "GROUP1";
+        g.title = "Nimbus Group";
+        g.services.add(orderService);
+
+        return Lists.newArrayList(g);
+      }
+
+      @Override
+      public Map<String, Map<String, ProcessingComponent>> getTasks() {
+        ManualTask mt = new ManualTask();
+        mt.messages = Lists.newArrayList("My New Message");
+
+        ProcessingComponent pc = new ProcessingComponent();
+        pc.name = "NIMBUS_MESSAGE";
+        pc.preTasks = Lists.<Task>newArrayList(mt);
+
+        return Collections.singletonMap("STORM", Collections.singletonMap("NIMBUS", pc));
+      }
+
+    };
+
+    MasterHostResolver resolver = new MasterHostResolver(m_configHelper, c);
+    UpgradeContext context = new UpgradeContext(resolver, stackId, stackId2, "2.2.0", Direction.UPGRADE,
UpgradeType.NON_ROLLING);
+    List<UpgradeGroupHolder> groups = m_upgradeHelper.createSequence(upgradePack, context);
+
+    assertEquals(1, groups.size());
+
+    sch1.setVersion("2.1.1");
+    sch2.setVersion("2.1.1");
+    resolver = new MasterHostResolver(m_configHelper, c, "2.1.1");
+    context = new UpgradeContext(resolver, stackId2, stackId, "2.1.1", Direction.DOWNGRADE,
UpgradeType.NON_ROLLING);
+    groups = m_upgradeHelper.createSequence(upgradePack, context);
+
+    assertTrue(groups.isEmpty());
+  }
+
   /**
    * Extend {@link org.apache.ambari.server.stack.MasterHostResolver} in order
    * to overwrite the JMX methods.


Mime
View raw message