Repository: ambari Updated Branches: refs/heads/branch-2.2 683a7f690 -> 4c6353cf3
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/4c6353cf Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4c6353cf Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4c6353cf Branch: refs/heads/branch-2.2 Commit: 4c6353cf3fdae16fb80bd7042e30676be9e93c31 Parents: 683a7f6 Author: Alejandro Fernandez <[email protected]> Authored: Mon Apr 4 11:56:04 2016 -0700 Committer: Alejandro Fernandez <[email protected]> Committed: Mon Apr 4 12:19:12 2016 -0700 ---------------------------------------------------------------------- .../internal/UpgradeResourceProvider.java | 22 +++++--------------- 1 file changed, 5 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/4c6353cf/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 fccd19d..c6517c8 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 @@ -438,32 +438,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); }
