ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alejan...@apache.org
Subject ambari git commit: AMBARI-15673. Stack Upgrade should allow suspended=false when aborting an upgrade to initiate a downgrade (alejandro)
Date Mon, 04 Apr 2016 19:18:32 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 43c67bc46 -> fa6550c4e


AMBARI-15673. Stack Upgrade should allow suspended=false when aborting an upgrade to initiate
a downgrade (alejandro)


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

Branch: refs/heads/trunk
Commit: fa6550c4ef38f9c15e7a341c02bdac046e0e28d4
Parents: 43c67bc
Author: Alejandro Fernandez <afernandez@hortonworks.com>
Authored: Mon Apr 4 12:00:33 2016 -0700
Committer: Alejandro Fernandez <afernandez@hortonworks.com>
Committed: Mon Apr 4 12:18:29 2016 -0700

----------------------------------------------------------------------
 .../internal/UpgradeResourceProvider.java       | 22 +++++---------------
 1 file changed, 5 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/fa6550c4/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 b3bf345..0384f6c 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
@@ -468,32 +468,20 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
     if (null != requestStatus) {
       HostRoleStatus status = HostRoleStatus.valueOf(requestStatus);
 
-      // when aborting an upgrade, the suspend flag must be present to indicate
-      // if the upgrade is merely being suspended
+      // When aborting an upgrade, the suspend flag must be present to indicate
+      // if the upgrade is merely being paused (suspended=true) or aborted to initiate a
downgrade (suspended=false).
       boolean suspended = false;
-      if( status == HostRoleStatus.ABORTED && !propertyMap.containsKey(UPGRADE_SUSPENDED)){
+      if (status == HostRoleStatus.ABORTED && !propertyMap.containsKey(UPGRADE_SUSPENDED)){
         throw new IllegalArgumentException(String.format(
             "When changing the state of an upgrade to %s, the %s property is required to
be either true or false.",
             status, UPGRADE_SUSPENDED ));
-      } else {
+      } else if (status == HostRoleStatus.ABORTED) {
         suspended = Boolean.valueOf((String) propertyMap.get(UPGRADE_SUSPENDED));
-        // If either the status is ABORTED or request to be suspended, then both should be
set.
-        if ((status == HostRoleStatus.ABORTED || suspended)) {
-          if (status == HostRoleStatus.ABORTED && !suspended) {
-            throw new IllegalArgumentException(String.format(
-                "If the status is set to ABORTED, must also set property %s to true", UPGRADE_SUSPENDED));
-          }
-          if (status != HostRoleStatus.ABORTED && suspended) {
-            throw new IllegalArgumentException(String.format(
-                "If property %s is set to true, must also set the status to ABORTED", UPGRADE_SUSPENDED));
-          }
-        }
       }
 
       setUpgradeRequestStatus(requestIdProperty, status, propertyMap);
 
-      // when the status of the upgrade's request is changing, we also update
-      // the suspended flag
+      // When the status of the upgrade's request is changing, we also update the suspended
flag.
       upgradeEntity.setSuspended(suspended);
       s_upgradeDAO.merge(upgradeEntity);
     }


Mime
View raw message