ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbeerbo...@apache.org
Subject ambari git commit: AMBARI-8997 - Update upgrade definition to include skippable and retry allowed (tbeerbower)
Date Tue, 06 Jan 2015 19:23:51 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 25726ae17 -> 7b177ea5d


AMBARI-8997 - Update upgrade definition to include skippable and retry allowed (tbeerbower)


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

Branch: refs/heads/trunk
Commit: 7b177ea5d22ee655d5e0c94d4e53cbc0fbcfb571
Parents: 25726ae
Author: tbeerbower <tbeerbower@hortonworks.com>
Authored: Tue Jan 6 14:19:28 2015 -0500
Committer: tbeerbower <tbeerbower@hortonworks.com>
Committed: Tue Jan 6 14:20:55 2015 -0500

----------------------------------------------------------------------
 .../internal/UpgradeResourceProvider.java       | 49 ++++++++++----------
 .../ambari/server/state/UpgradeHelper.java      | 13 ++++++
 .../server/state/stack/upgrade/Grouping.java    |  6 +++
 .../stacks/HDP/2.2/upgrades/upgrade-2.2.xml     |  4 +-
 .../internal/UpgradeResourceProviderTest.java   | 27 ++++++++++-
 .../stacks/HDP/2.1.1/upgrades/upgrade_test.xml  |  2 +
 6 files changed, 74 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7b177ea5/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 042a895..2b580f6 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
@@ -93,12 +93,6 @@ import com.google.inject.Provider;
 @StaticallyInject
 public class UpgradeResourceProvider extends AbstractControllerResourceProvider {
 
-  /**
-   * Default failure retry/skip options for upgrades.
-   */
-  private static final boolean UPGRADE_DEFAULT_ALLOW_RETRY = true;
-  private static final boolean UPGRADE_DEFAULT_SKIPPABLE = true;
-
   protected static final String UPGRADE_CLUSTER_NAME = "Upgrade/cluster_name";
   protected static final String UPGRADE_VERSION = "Upgrade/repository_version";
   protected static final String UPGRADE_REQUEST_ID = "Upgrade/request_id";
@@ -386,6 +380,8 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
       UpgradeGroupEntity groupEntity = new UpgradeGroupEntity();
       groupEntity.setName(group.name);
       groupEntity.setTitle(group.title);
+      boolean skippable = group.skippable;
+      boolean allowRetry = group.allowRetry;
 
       List<UpgradeItemEntity> itemEntities = new ArrayList<UpgradeItemEntity>();
 
@@ -405,7 +401,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
 
               injectVariables(configHelper, cluster, itemEntity);
 
-              makeServerSideStage(cluster, req, version, itemEntity, (ServerSideActionTask)
task);
+              makeServerSideStage(cluster, req, version, itemEntity, (ServerSideActionTask)
task, skippable, allowRetry);
             }
           }
         } else {
@@ -418,7 +414,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
           injectVariables(configHelper, cluster, itemEntity);
 
           // upgrade items match a stage
-          createStage(cluster, req, version, itemEntity, wrapper);
+          createStage(cluster, req, version, itemEntity, wrapper, skippable, allowRetry);
         }
 
       }
@@ -456,17 +452,18 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
   }
 
   private void createStage(Cluster cluster, RequestStageContainer request, final String version,
-      UpgradeItemEntity entity, StageWrapper wrapper) throws AmbariException {
+      UpgradeItemEntity entity, StageWrapper wrapper, boolean skippable, boolean allowRetry)
+      throws AmbariException {
 
     switch (wrapper.getType()) {
       case RESTART:
-        makeRestartStage(cluster, request, version, entity, wrapper);
+        makeRestartStage(cluster, request, version, entity, wrapper, skippable, allowRetry);
         break;
       case RU_TASKS:
-        makeActionStage(cluster, request, version, entity, wrapper);
+        makeActionStage(cluster, request, version, entity, wrapper, skippable, allowRetry);
         break;
       case SERVICE_CHECK:
-        makeServiceCheckStage(cluster, request, version, entity, wrapper);
+        makeServiceCheckStage(cluster, request, version, entity, wrapper, skippable, allowRetry);
         break;
       default:
         break;
@@ -475,7 +472,8 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
   }
 
   private void makeActionStage(Cluster cluster, RequestStageContainer request, final String
version,
-      UpgradeItemEntity entity, StageWrapper wrapper) throws AmbariException {
+                               UpgradeItemEntity entity, StageWrapper wrapper,
+                               boolean skippable, boolean allowRetry) throws AmbariException
{
 
     if (0 == wrapper.getHosts().size()) {
       throw new AmbariException(
@@ -524,7 +522,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
         jsons.getCommandParamsForStage(),
         jsons.getHostParamsForStage());
 
-    stage.setSkippable(UPGRADE_DEFAULT_SKIPPABLE);
+    stage.setSkippable(skippable);
 
     long stageId = request.getLastStageId() + 1;
     if (0L == stageId) {
@@ -535,7 +533,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
 
     // !!! TODO verify the action is valid
 
-    actionExecutionHelper.get().addExecutionCommandsToStage(actionContext, stage, UPGRADE_DEFAULT_ALLOW_RETRY);
+    actionExecutionHelper.get().addExecutionCommandsToStage(actionContext, stage, allowRetry);
 
     // need to set meaningful text on the command
     for (Map<String, HostRoleCommand> map : stage.getHostRoleCommands().values()) {
@@ -548,7 +546,8 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
   }
 
   private void makeRestartStage(Cluster cluster, RequestStageContainer request, final String
version,
-      UpgradeItemEntity entity, StageWrapper wrapper) throws AmbariException {
+                                UpgradeItemEntity entity, StageWrapper wrapper,
+                                boolean skippable, boolean allowRetry) throws AmbariException
{
 
     List<RequestResourceFilter> filters = new ArrayList<RequestResourceFilter>();
 
@@ -580,7 +579,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
         jsons.getCommandParamsForStage(),
         jsons.getHostParamsForStage());
 
-    stage.setSkippable(UPGRADE_DEFAULT_SKIPPABLE);
+    stage.setSkippable(skippable);
 
     long stageId = request.getLastStageId() + 1;
     if (0L == stageId) {
@@ -594,13 +593,14 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
     Map<String, String> requestParams = new HashMap<String, String>();
     requestParams.put("command", "RESTART");
 
-    commandExecutionHelper.get().addExecutionCommandsToStage(actionContext, stage, requestParams,
UPGRADE_DEFAULT_ALLOW_RETRY);
+    commandExecutionHelper.get().addExecutionCommandsToStage(actionContext, stage, requestParams,
allowRetry);
 
     request.addStages(Collections.singletonList(stage));
   }
 
   private void makeServiceCheckStage(Cluster cluster, RequestStageContainer request, String
version,
-      UpgradeItemEntity entity, StageWrapper wrapper) throws AmbariException {
+                                     UpgradeItemEntity entity, StageWrapper wrapper,
+                                     boolean skippable, boolean allowRetry) throws AmbariException
{
 
     List<RequestResourceFilter> filters = new ArrayList<RequestResourceFilter>();
 
@@ -629,7 +629,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
         jsons.getCommandParamsForStage(),
         jsons.getHostParamsForStage());
 
-    stage.setSkippable(UPGRADE_DEFAULT_SKIPPABLE);
+    stage.setSkippable(skippable);
 
     long stageId = request.getLastStageId() + 1;
     if (0L == stageId) {
@@ -640,13 +640,14 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
 
     Map<String, String> requestParams = new HashMap<String, String>();
 
-    commandExecutionHelper.get().addExecutionCommandsToStage(actionContext, stage, requestParams,
UPGRADE_DEFAULT_ALLOW_RETRY);
+    commandExecutionHelper.get().addExecutionCommandsToStage(actionContext, stage, requestParams,
allowRetry);
 
     request.addStages(Collections.singletonList(stage));
   }
 
   private void makeServerSideStage(Cluster cluster, RequestStageContainer request, String
version,
-      UpgradeItemEntity entity, ServerSideActionTask task) throws AmbariException {
+                                   UpgradeItemEntity entity, ServerSideActionTask task,
+                                   boolean skippable, boolean allowRtery) throws AmbariException
{
 
     Map<String, String> commandParams = new HashMap<String, String>();
     commandParams.put("clusterName", cluster.getClusterName());
@@ -690,7 +691,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
         jsons.getCommandParamsForStage(),
         jsons.getHostParamsForStage());
 
-    stage.setSkippable(UPGRADE_DEFAULT_SKIPPABLE);
+    stage.setSkippable(skippable);
 
     long stageId = request.getLastStageId() + 1;
     if (0L == stageId) {
@@ -707,7 +708,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
         RoleCommand.EXECUTE,
         cluster.getClusterName(), host,
         new ServiceComponentHostServerActionEvent(StageUtils.getHostName(), System.currentTimeMillis()),
-        commandParams, null, 1200, UPGRADE_DEFAULT_ALLOW_RETRY);
+        commandParams, null, 1200, allowRtery);
 
     request.addStages(Collections.singletonList(stage));
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/7b177ea5/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
index fcd2bcc..ae793be 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
@@ -84,6 +84,8 @@ public class UpgradeHelper {
       UpgradeGroupHolder groupHolder = new UpgradeGroupHolder();
       groupHolder.name = group.name;
       groupHolder.title = group.title;
+      groupHolder.skippable = group.skippable;
+      groupHolder.allowRetry = group.allowRetry;
 
       StageWrapperBuilder builder = group.getBuilder();
 
@@ -173,6 +175,17 @@ public class UpgradeHelper {
     public String title;
 
     /**
+     * Indicate whether retry is allowed for the stages in this group.
+     */
+    public boolean allowRetry = true;
+
+    /**
+     * Indicates whether the stages in this group are skippable on failure.  If a
+     * stage is skippable, a failed result can be skipped without failing the entire upgrade.
+     */
+    public boolean skippable = false;
+
+    /**
      * List of stages for the group
      */
     public List<StageWrapper> items = new ArrayList<StageWrapper>();

http://git-wip-us.apache.org/repos/asf/ambari/blob/7b177ea5/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 076cac8..3a7a0bf 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
@@ -44,6 +44,12 @@ public class Grouping {
   @XmlAttribute(name="title")
   public String title;
 
+  @XmlElement(name="skippable", defaultValue="false")
+  public boolean skippable = false;
+
+  @XmlElement(name="allow-retry", defaultValue="true")
+  public boolean allowRetry = true;
+
   @XmlElement(name="service")
   public List<UpgradePack.OrderService> services = new ArrayList<UpgradePack.OrderService>();
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/7b177ea5/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 86290db..b9d338b 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
@@ -68,6 +68,7 @@
     </group>
 
     <group name="HIVE" title="Hive">
+      <skippable>true</skippable>
       <service name="HIVE">
         <component>HIVE_METASTORE</component>
         <component>HIVE_SERVER</component>
@@ -76,7 +77,8 @@
     </group>
 
     <group name="FALCON" title="Falcon">
-      <service name="Falcon">
+      <skippable>true</skippable>
+      <service name="FALCON">
         <component>FALCON_SERVER</component>
         <component>FALCON_CLIENT</component>
       </service>

http://git-wip-us.apache.org/repos/asf/ambari/blob/7b177ea5/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 d2f2d9d..15c0c0c 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,6 +49,7 @@ 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;
@@ -164,9 +165,11 @@ public class UpgradeResourceProviderTest {
     UpgradeEntity entity = upgrades.get(0);
     assertEquals(cluster.getClusterId(), entity.getClusterId().longValue());
 
-    assertEquals(4, entity.getUpgradeGroups().size());
+    List<UpgradeGroupEntity> upgradeGroups = entity.getUpgradeGroups();
+    assertEquals(4, upgradeGroups.size());
 
-    UpgradeGroupEntity group = entity.getUpgradeGroups().get(1);
+
+    UpgradeGroupEntity group = upgradeGroups.get(1);
     assertEquals(4, group.getItems().size());
 
     assertTrue(group.getItems().get(0).getText().contains("Preparing"));
@@ -189,6 +192,26 @@ public class UpgradeResourceProviderTest {
     // same number of tasks as stages here
     assertEquals(9, tasks.size());
 
+    Set<Long> slaveStageIds = new HashSet<Long>();
+
+    UpgradeGroupEntity coreSlavesGroup = upgradeGroups.get(2);
+
+    for (UpgradeItemEntity itemEntity : coreSlavesGroup.getItems()) {
+      slaveStageIds.add(itemEntity.getStageId());
+    }
+
+    for (Stage stage : stages) {
+
+      // For this test the core slaves group stages should be skippable and NOT allow retry.
+      assertEquals(slaveStageIds.contains(stage.getStageId()), stage.isSkippable());
+
+      for (Map<String, HostRoleCommand> taskMap : stage.getHostRoleCommands().values())
{
+
+        for (HostRoleCommand task : taskMap.values()) {
+          assertEquals(!slaveStageIds.contains(stage.getStageId()), task.isRetryAllowed());
+        }
+      }
+    }
     return status;
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/7b177ea5/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 c8da762..bf608ec 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
@@ -53,6 +53,8 @@
       </service>
     </group>
     <group name="CORE_SLAVES" title="Core Slaves" xsi:type="colocated">
+      <skippable>true</skippable>      <!-- set skippable for test -->
+      <allow-retry>false</allow-retry> <!-- set no retry for test -->
       <service name="HDFS">
         <component>DATANODE</component>
       </service>


Mime
View raw message