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-8796. Manual Tasks Are Not Created Correctly During Upgrade (ncole)
Date Thu, 18 Dec 2014 18:52:48 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 106590550 -> 6703610ec


AMBARI-8796. Manual Tasks Are Not Created Correctly During Upgrade (ncole)


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

Branch: refs/heads/trunk
Commit: 6703610ec30424ab66bafebbce8df0b5e7407537
Parents: 1065905
Author: Nate Cole <ncole@hortonworks.com>
Authored: Thu Dec 18 11:25:32 2014 -0500
Committer: Nate Cole <ncole@hortonworks.com>
Committed: Thu Dec 18 13:48:12 2014 -0500

----------------------------------------------------------------------
 .../internal/UpgradeResourceProvider.java       | 83 ++++++++++++++++----
 .../serveraction/upgrades/ConfigureAction.java  | 39 +++++++++
 .../state/stack/upgrade/ClusterGrouping.java    |  2 +-
 .../state/stack/upgrade/ColocatedGrouping.java  |  2 +-
 .../state/stack/upgrade/ConfigureTask.java      |  8 +-
 .../server/state/stack/upgrade/Grouping.java    | 76 +++++++++++++++---
 .../server/state/stack/upgrade/ManualTask.java  |  8 +-
 .../stack/upgrade/ServerSideActionTask.java     | 35 +++++++++
 .../state/stack/upgrade/StageWrapper.java       |  2 +-
 .../ambari/server/state/stack/upgrade/Task.java |  6 +-
 .../internal/UpgradeResourceProviderTest.java   |  2 -
 .../ambari/server/state/UpgradeHelperTest.java  | 53 ++++++++-----
 .../HDP/2.1.1/upgrades/upgrade_bucket_test.xml  | 75 ++++++++++++++++++
 .../stacks/HDP/2.1.1/upgrades/upgrade_test.xml  |  2 +-
 14 files changed, 338 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/6703610e/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
index c70a486..c733279 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
@@ -61,7 +61,6 @@ import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.orm.entities.UpgradeEntity;
 import org.apache.ambari.server.orm.entities.UpgradeGroupEntity;
 import org.apache.ambari.server.orm.entities.UpgradeItemEntity;
-import org.apache.ambari.server.serveraction.upgrades.ManualStageAction;
 import org.apache.ambari.server.stack.MasterHostResolver;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.ConfigHelper;
@@ -69,7 +68,11 @@ import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.UpgradeHelper;
 import org.apache.ambari.server.state.UpgradeHelper.UpgradeGroupHolder;
 import org.apache.ambari.server.state.stack.UpgradePack;
+import org.apache.ambari.server.state.stack.upgrade.ConfigureTask;
+import org.apache.ambari.server.state.stack.upgrade.ManualTask;
+import org.apache.ambari.server.state.stack.upgrade.ServerSideActionTask;
 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.apache.ambari.server.state.svccomphost.ServiceComponentHostServerActionEvent;
 import org.apache.ambari.server.utils.StageUtils;
@@ -379,16 +382,37 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
       List<UpgradeItemEntity> itemEntities = new ArrayList<UpgradeItemEntity>();
 
       for (StageWrapper wrapper : group.items) {
-        UpgradeItemEntity itemEntity = new UpgradeItemEntity();
-        itemEntity.setText(wrapper.getText());
-        itemEntity.setTasks(wrapper.getTasksJson());
-        itemEntity.setHosts(wrapper.getHostsJson());
-        itemEntities.add(itemEntity);
+        if (wrapper.getType() == StageWrapper.Type.SERVER_SIDE_ACTION) {
+          // !!! each stage is guaranteed to be of one type.  but because there
+          // is a bug that prevents one stage with multiple tasks assigned for the same host,
+          // break them out into individual stages.
+
+          for (TaskWrapper taskWrapper : wrapper.getTasks()) {
+            for (Task task : taskWrapper.getTasks()) {
+              UpgradeItemEntity itemEntity = new UpgradeItemEntity();
+              itemEntity.setText(wrapper.getText());
+              itemEntity.setTasks(wrapper.getTasksJson());
+              itemEntity.setHosts(wrapper.getHostsJson());
+              itemEntities.add(itemEntity);
+
+              injectVariables(configHelper, cluster, itemEntity);
+
+              makeServerSideStage(cluster, req, version, itemEntity, (ServerSideActionTask)
task);
+            }
+          }
+        } else {
+          UpgradeItemEntity itemEntity = new UpgradeItemEntity();
+          itemEntity.setText(wrapper.getText());
+          itemEntity.setTasks(wrapper.getTasksJson());
+          itemEntity.setHosts(wrapper.getHostsJson());
+          itemEntities.add(itemEntity);
+
+          injectVariables(configHelper, cluster, itemEntity);
 
-        injectVariables(configHelper, cluster, itemEntity);
+          // upgrade items match a stage
+          createStage(cluster, req, version, itemEntity, wrapper);
+        }
 
-        // upgrade items match a stage
-        createStage(cluster, req, version, itemEntity, wrapper);
       }
 
       groupEntity.setItems(itemEntities);
@@ -436,8 +460,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
       case SERVICE_CHECK:
         makeServiceCheckStage(cluster, request, version, entity, wrapper);
         break;
-      case MANUAL:
-        makeManualStage(cluster, request, version, entity, wrapper);
+      default:
         break;
     }
 
@@ -446,10 +469,16 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
   private void makeActionStage(Cluster cluster, RequestStageContainer request, final String
version,
       UpgradeItemEntity entity, StageWrapper wrapper) throws AmbariException {
 
+    if (0 == wrapper.getHosts().size()) {
+      throw new AmbariException(
+          String.format("Cannot create action for '%s' with no hosts", wrapper.getText()));
+    }
+
     // add each host to this stage
     RequestResourceFilter filter = new RequestResourceFilter("", "",
         new ArrayList<String>(wrapper.getHosts()));
 
+
     Map<String, String> params = new HashMap<String, String>();
     params.put("tasks", entity.getTasks());
 
@@ -585,8 +614,31 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
     request.addStages(Collections.singletonList(stage));
   }
 
-  private void makeManualStage(Cluster cluster, RequestStageContainer request, String version,
-      UpgradeItemEntity entity, StageWrapper wrapper) throws AmbariException {
+  private void makeServerSideStage(Cluster cluster, RequestStageContainer request, String
version,
+      UpgradeItemEntity entity, ServerSideActionTask task) throws AmbariException {
+
+    Map<String, String> commandParams = new HashMap<String, String>();
+    commandParams.put("clusterName", cluster.getClusterName());
+
+    String itemText = entity.getText();
+    switch (task.getType()) {
+      case MANUAL: {
+        itemText = ((ManualTask) task).message;
+        break;
+      }
+      case CONFIGURE: {
+        ConfigureTask ct = (ConfigureTask) task;
+        commandParams.put("type", ct.configType);
+        commandParams.put("key", ct.key);
+        commandParams.put("value", ct.value);
+        itemText = String.format("Updating config %s/%s to %s", ct.configType, ct.key, ct.value);
+        break;
+      }
+      default:
+        break;
+    }
+
+    entity.setText(itemText);
 
     Map<String, String> restartCommandParams = new HashMap<String, String>();
     restartCommandParams.put("version", version);
@@ -600,7 +652,6 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
     ExecuteCommandJson jsons = commandExecutionHelper.get().getCommandJson(
         actionContext, cluster);
 
-
     Stage stage = stageFactory.get().createNew(request.getId().longValue(),
         "/tmp/ambari",
         cluster.getClusterName(),
@@ -620,12 +671,12 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
     // !!! hack hack hack
     String host = cluster.getAllHostsDesiredConfigs().keySet().iterator().next();
 
-    stage.addServerActionCommand(ManualStageAction.class.getName(),
+    stage.addServerActionCommand(task.getImplementationClass(),
         Role.AMBARI_SERVER_ACTION,
         RoleCommand.EXECUTE,
         cluster.getClusterName(), host,
         new ServiceComponentHostServerActionEvent(StageUtils.getHostName(), System.currentTimeMillis()),
-        Collections.<String, String>emptyMap(), 15);
+        commandParams, 1200);
 
     request.addStages(Collections.singletonList(stage));
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6703610e/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ConfigureAction.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ConfigureAction.java
b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ConfigureAction.java
new file mode 100644
index 0000000..4474d05
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ConfigureAction.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.serveraction.upgrades;
+
+import java.util.concurrent.ConcurrentMap;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.actionmanager.HostRoleStatus;
+import org.apache.ambari.server.agent.CommandReport;
+import org.apache.ambari.server.serveraction.AbstractServerAction;
+
+/**
+ * Action that represents a manual stage.
+ */
+public class ConfigureAction extends AbstractServerAction {
+
+  @Override
+  public CommandReport execute(
+      ConcurrentMap<String, Object> requestSharedDataContext)
+      throws AmbariException, InterruptedException {
+    // TODO Auto-generated method stub
+    return createCommandReport(0, HostRoleStatus.COMPLETED, "{}", "", "");
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6703610e/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ClusterGrouping.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ClusterGrouping.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ClusterGrouping.java
index 15a730f..12e84e8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ClusterGrouping.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ClusterGrouping.java
@@ -126,7 +126,7 @@ public class ClusterGrouping extends Grouping {
           switch (task.getType()) {
             case MANUAL:
               wrapper = new StageWrapper(
-                  StageWrapper.Type.MANUAL,
+                  StageWrapper.Type.SERVER_SIDE_ACTION,
                   execution.title,
                   new TaskWrapper(null, null, Collections.<String>emptySet(), task));
               break;

http://git-wip-us.apache.org/repos/asf/ambari/blob/6703610e/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 704851e..2c6a6e2 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
@@ -141,7 +141,7 @@ public class ColocatedGrouping extends Grouping {
       task.message = batch.message;
 
       StageWrapper wrapper = new StageWrapper(
-          StageWrapper.Type.MANUAL,
+          StageWrapper.Type.SERVER_SIDE_ACTION,
           "Validate partial upgrade",
           new TaskWrapper(null, null, Collections.<String>emptySet(), task));
       results.add(wrapper);

http://git-wip-us.apache.org/repos/asf/ambari/blob/6703610e/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ConfigureTask.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ConfigureTask.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ConfigureTask.java
index c61dc1c..cd10260 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ConfigureTask.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ConfigureTask.java
@@ -24,13 +24,19 @@ import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
 
+import org.apache.ambari.server.serveraction.upgrades.ConfigureAction;
+
 /**
  * Upgrade task that represents a configuration should change.
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name="configure")
-public class ConfigureTask extends Task {
+public class ConfigureTask extends ServerSideActionTask {
+
+  public ConfigureTask() {
+    implClass = ConfigureAction.class.getName();
+  }
 
   @XmlTransient
   private Task.Type type = Task.Type.CONFIGURE;

http://git-wip-us.apache.org/repos/asf/ambari/blob/6703610e/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/Grouping.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/Grouping.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/Grouping.java
index 4a03ea0..7fd58cd 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/Grouping.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/Grouping.java
@@ -69,11 +69,13 @@ public class Grouping {
      */
     @Override
     public void add(HostsType hostsType, String service, boolean clientOnly, ProcessingComponent
pc) {
-      if (null != pc.preTasks && pc.preTasks.size() > 0) {
-        List<TaskWrapper> preTasks = TaskWrapperBuilder.getTaskList(service, pc.name,
hostsType, pc.preTasks);
+
+      List<TaskBucket> buckets = buckets(pc.preTasks);
+      for (TaskBucket bucket : buckets) {
+        List<TaskWrapper> preTasks = TaskWrapperBuilder.getTaskList(service, pc.name,
hostsType, bucket.tasks);
         Set<String> preTasksEffectiveHosts = TaskWrapperBuilder.getEffectiveHosts(preTasks);
         StageWrapper stage = new StageWrapper(
-            StageWrapper.Type.RU_TASKS,
+            bucket.type,
             getStageText("Preparing", pc.name, preTasksEffectiveHosts),
             preTasks
             );
@@ -94,13 +96,15 @@ public class Grouping {
         }
       }
 
-      if (null != pc.postTasks && pc.postTasks.size() > 0) {
-        List<TaskWrapper> postTasks = TaskWrapperBuilder.getTaskList(service, pc.name,
hostsType, pc.postTasks);
-        Set<String> postTasksEffectiveHosts = TaskWrapperBuilder.getEffectiveHosts(postTasks);
+      buckets = buckets(pc.postTasks);
+      for (TaskBucket bucket : buckets) {
+        List<TaskWrapper> preTasks = TaskWrapperBuilder.getTaskList(service, pc.name,
hostsType, bucket.tasks);
+        Set<String> preTasksEffectiveHosts = TaskWrapperBuilder.getEffectiveHosts(preTasks);
         StageWrapper stage = new StageWrapper(
-            StageWrapper.Type.RU_TASKS,
-            getStageText("Completing", pc.name, postTasksEffectiveHosts),
-            postTasks);
+            bucket.type,
+            getStageText("Completing", pc.name, preTasksEffectiveHosts),
+            preTasks
+            );
         stages.add(stage);
       }
 
@@ -131,4 +135,58 @@ public class Grouping {
       return stages;
     }
   }
+
+  /**
+   * Group all like-typed tasks together.  When they change, create a new type.
+   */
+  private static List<TaskBucket> buckets(List<Task> tasks) {
+    if (null == tasks || tasks.isEmpty())
+      return Collections.emptyList();
+
+    List<TaskBucket> holders = new ArrayList<TaskBucket>();
+
+    TaskBucket current = null;
+
+    int i = 0;
+    for (Task t : tasks) {
+      if (i == 0) {
+        current = new TaskBucket(t);
+        holders.add(current);
+      } else if (i > 0 && t.getType() != tasks.get(i-1).getType()) {
+        current = new TaskBucket(t);
+        holders.add(current);
+      } else {
+        current.tasks.add(t);
+      }
+
+      i++;
+    }
+
+    return holders;
+
+  }
+
+  private static class TaskBucket {
+    private StageWrapper.Type type;
+    private List<Task> tasks = new ArrayList<Task>();
+    private TaskBucket(Task initial) {
+      switch (initial.getType()) {
+        case CONFIGURE:
+        case MANUAL:
+          type = StageWrapper.Type.SERVER_SIDE_ACTION;
+          break;
+        case EXECUTE:
+          type = StageWrapper.Type.RU_TASKS;
+          break;
+        case RESTART:
+          type = StageWrapper.Type.RESTART;
+          break;
+        case SERVICE_CHECK:
+          type = StageWrapper.Type.SERVICE_CHECK;
+          break;
+      }
+      tasks.add(initial);
+    }
+
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6703610e/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ManualTask.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ManualTask.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ManualTask.java
index 1c06e7f..171367b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ManualTask.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ManualTask.java
@@ -24,13 +24,19 @@ import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
 
+import org.apache.ambari.server.serveraction.upgrades.ManualStageAction;
+
 /**
  * Identifies that an upgrade step that requires confirmation before continuing.
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name="manual")
-public class ManualTask extends Task {
+public class ManualTask extends ServerSideActionTask {
+
+  public ManualTask() {
+    implClass = ManualStageAction.class.getName();
+  }
 
   @XmlTransient
   private Task.Type type = Task.Type.MANUAL;

http://git-wip-us.apache.org/repos/asf/ambari/blob/6703610e/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ServerSideActionTask.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ServerSideActionTask.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ServerSideActionTask.java
new file mode 100644
index 0000000..b98510b
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ServerSideActionTask.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.state.stack.upgrade;
+
+import javax.xml.bind.annotation.XmlAttribute;
+
+/**
+ *
+ */
+public abstract class ServerSideActionTask extends Task {
+
+  @XmlAttribute(name="class")
+  protected String implClass;
+
+
+  public String getImplementationClass() {
+    return implClass;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6703610e/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/StageWrapper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/StageWrapper.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/StageWrapper.java
index 0c4d363..836bccb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/StageWrapper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/StageWrapper.java
@@ -103,7 +103,7 @@ public class StageWrapper {
    * Indicates the type of wrapper.
    */
   public enum Type {
-    MANUAL,
+    SERVER_SIDE_ACTION,
     RESTART,
     RU_TASKS,
     SERVICE_CHECK

http://git-wip-us.apache.org/repos/asf/ambari/blob/6703610e/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/Task.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/Task.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/Task.java
index c1e65ca..f41aa68 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/Task.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/Task.java
@@ -64,15 +64,15 @@ public abstract class Task {
     /**
      * @return {@code true} if the task is manual or automated.
      */
-    public boolean isManual() {
-      return this == MANUAL;
+    public boolean isServerAction() {
+      return this == MANUAL || this == CONFIGURE;
     }
 
     /**
      * @return {@code true} if the task is a command type (as opposed to an action)
      */
     public boolean isCommand() {
-      return this == RESTART;
+      return this == RESTART || this == SERVICE_CHECK;
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6703610e/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
index 7f5c298..dc36648 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
@@ -49,7 +49,6 @@ import org.apache.ambari.server.orm.dao.UpgradeDAO;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.orm.entities.UpgradeEntity;
 import org.apache.ambari.server.orm.entities.UpgradeGroupEntity;
-import org.apache.ambari.server.orm.entities.UpgradeItemEntity;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Host;
@@ -57,7 +56,6 @@ import org.apache.ambari.server.state.RepositoryVersionState;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.StackId;
-import org.apache.ambari.server.state.UpgradeState;
 import org.apache.ambari.server.view.ViewRegistry;
 import org.junit.After;
 import org.junit.Before;

http://git-wip-us.apache.org/repos/asf/ambari/blob/6703610e/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 198191b..cf5eea3 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
@@ -42,9 +42,7 @@ import org.easymock.EasyMock;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.Mockito;
 
-import com.google.inject.AbstractModule;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.persist.PersistService;
@@ -68,7 +66,7 @@ public class UpgradeHelperTest {
     helper = injector.getInstance(OrmTestHelper.class);
     ambariMetaInfo = injector.getInstance(AmbariMetaInfo.class);
     ambariMetaInfo.init();
-    
+
     m_masterHostResolver = EasyMock.createMock(MasterHostResolver.class);
   }
 
@@ -89,12 +87,12 @@ public class UpgradeHelperTest {
 
     Cluster cluster = makeCluster();
 
-    
+
     UpgradeHelper helper = new UpgradeHelper();
     List<UpgradeGroupHolder> groups = helper.createUpgrade(cluster, m_masterHostResolver,
upgrade);
 
-    
-    
+
+
     assertEquals(5, groups.size());
 
     assertEquals("PRE_CLUSTER", groups.get(0).name);
@@ -104,10 +102,33 @@ public class UpgradeHelperTest {
     assertEquals("POST_CLUSTER", groups.get(4).name);
 
     assertEquals(6, groups.get(1).items.size());
-    assertEquals(6, groups.get(2).items.size());
+    assertEquals(8, groups.get(2).items.size());
     assertEquals(7, groups.get(3).items.size());
   }
 
+  @Test
+  public void testBuckets() throws Exception {
+    Map<String, UpgradePack> upgrades = ambariMetaInfo.getUpgradePacks("foo", "bar");
+    assertTrue(upgrades.isEmpty());
+
+    upgrades = ambariMetaInfo.getUpgradePacks("HDP", "2.1.1");
+    assertTrue(upgrades.containsKey("upgrade_bucket_test"));
+    UpgradePack upgrade = upgrades.get("upgrade_bucket_test");
+    assertNotNull(upgrade);
+
+    Cluster cluster = makeCluster();
+
+    UpgradeHelper helper = new UpgradeHelper();
+    List<UpgradeGroupHolder> groups = helper.createUpgrade(cluster, m_masterHostResolver,
upgrade);
+
+    assertEquals(1, groups.size());
+    UpgradeGroupHolder group = groups.iterator().next();
+
+    assertEquals(7, group.items.size());
+
+  }
+
+
   /**
    * Create an HA cluster
    * @throws AmbariException
@@ -170,17 +191,17 @@ public class UpgradeHelperTest {
     HostsType type = new HostsType();
     type.hosts = new HashSet<String>(Arrays.asList("h1", "h2", "h3"));
     expect(m_masterHostResolver.getMasterAndHosts("ZOOKEEPER", "ZOOKEEPER_SERVER")).andReturn(type).anyTimes();
-    
+
     type = new HostsType();
     type.hosts = new HashSet<String>(Arrays.asList("h1", "h2"));
     type.master = "h1";
     type.secondary = "h2";
     expect(m_masterHostResolver.getMasterAndHosts("HDFS", "NAMENODE")).andReturn(type).anyTimes();
-    
+
     type = new HostsType();
     type.hosts = new HashSet<String>(Arrays.asList("h2", "h3"));
     expect(m_masterHostResolver.getMasterAndHosts("HDFS", "DATANODE")).andReturn(type).anyTimes();
-    
+
     type = new HostsType();
     type.hosts = new HashSet<String>(Arrays.asList("h2"));
     expect(m_masterHostResolver.getMasterAndHosts("YARN", "RESOURCEMANAGER")).andReturn(type).anyTimes();
@@ -188,18 +209,12 @@ public class UpgradeHelperTest {
     type = new HostsType();
     type.hosts = new HashSet<String>(Arrays.asList("h1", "h3"));
     expect(m_masterHostResolver.getMasterAndHosts("YARN", "NODEMANAGER")).andReturn(type).anyTimes();
-    
-    
+
+
     replay(m_masterHostResolver);
 
     return c;
   }
-  
-  
-  private static class MockModule extends AbstractModule {
-    protected void configure() {
-      
-    }
-  }
+
 
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6703610e/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_bucket_test.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_bucket_test.xml
b/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_bucket_test.xml
new file mode 100644
index 0000000..b777d94
--- /dev/null
+++ b/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_bucket_test.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<upgrade xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <target>2.2.*</target>
+  
+  <order>
+  
+    <group name="ZOOKEEPER" title="Zookeeper">
+      <service name="ZOOKEEPER">
+        <component>ZOOKEEPER_SERVER</component>
+      </service>
+    </group>
+  </order>  
+
+  <processing>
+  
+    <service name="ZOOKEEPER">
+      <component name="ZOOKEEPER_SERVER">
+        <pre-upgrade>
+          <task xsi:type="manual">
+            <message>this is pre</message>
+          </task>
+          <task xsi:type="execute">
+            <command>ls</command>
+          </task>
+          <task xsi:type="execute">
+            <command>ls</command>
+          </task>
+          
+        </pre-upgrade>
+        
+        <post-upgrade>
+          <task xsi:type="execute">
+            <command>ls</command>
+          </task>
+          <task xsi:type="manual">
+            <message>this is pre</message>
+          </task>
+          <task xsi:type="manual">
+            <message>this is pre</message>
+          </task>
+          <task xsi:type="execute">
+            <command>ls</command>
+          </task>
+          <task xsi:type="execute">
+            <command>ls</command>
+          </task>
+
+          <task xsi:type="manual">
+            <command>ls</command>
+          </task>
+          
+        </post-upgrade>
+        
+        
+      </component>
+    </service>
+
+  </processing>
+</upgrade>

http://git-wip-us.apache.org/repos/asf/ambari/blob/6703610e/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 70328ad..40eb7f3 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
@@ -91,7 +91,7 @@
       <component name="ZOOKEEPER_SERVER">
         <pre-upgrade>
           <task xsi:type="manual">
-            <message>this is pre</message>
+            <message>Preparing with a manual</message>
           </task>
         </pre-upgrade>
         <upgrade>


Mime
View raw message