ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject [2/2] ambari git commit: AMBARI-12706. Stop-and-Start Upgrade: Handle Downgrade path (dlysnichenko)
Date Wed, 21 Oct 2015 12:14:22 GMT
AMBARI-12706. Stop-and-Start Upgrade: Handle Downgrade path (dlysnichenko)


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

Branch: refs/heads/branch-2.1
Commit: aed8e5e53d94759efb70521966c292e55511e065
Parents: c764f1c
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Wed Oct 21 15:13:12 2015 +0300
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Wed Oct 21 15:14:02 2015 +0300

----------------------------------------------------------------------
 .../server/orm/entities/UpgradeEntity.java      | 10 ++--
 .../ambari/server/state/stack/UpgradePack.java  | 11 +----
 .../server/state/stack/UpgradePackTest.java     | 50 ++++++++++++++------
 3 files changed, 44 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/aed8e5e5/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradeEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradeEntity.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradeEntity.java
index e14fc75..04f753e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradeEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradeEntity.java
@@ -92,7 +92,7 @@ public class UpgradeEntity {
   private Integer skipServiceCheckFailures = 0;
 
   @Column(name="downgrade_allowed", nullable = false)
-  private Integer downgrade_allowed = 1;
+  private Short downgrade_allowed = 1;
 
   @OneToMany(mappedBy = "upgradeEntity", cascade = { CascadeType.ALL })
   private List<UpgradeGroupEntity> upgradeGroupEntities;
@@ -209,12 +209,16 @@ public class UpgradeEntity {
   /**
    * @return possibility to process downgrade
    */
-  public Boolean isDowngradeAllowed() { return downgrade_allowed != 0; }
+  public Boolean isDowngradeAllowed() {
+    return downgrade_allowed != 0;
+  }
 
   /**
    * @param canDowngrade {@code true} to allow downgrade, {@code false} to disallow downgrade
    */
-  public void setDowngradeAllowed(boolean canDowngrade){ downgrade_allowed = (!canDowngrade
? 0 : 1); }
+  public void setDowngradeAllowed(boolean canDowngrade) {
+    this.downgrade_allowed = (!canDowngrade ? (short)0 : (short)1);
+  }
 
   /**
    * @param upgradeType the upgrade type to set

http://git-wip-us.apache.org/repos/asf/ambari/blob/aed8e5e5/ambari-server/src/main/java/org/apache/ambari/server/state/stack/UpgradePack.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/UpgradePack.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/UpgradePack.java
index d72756d..bea8537 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/UpgradePack.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/UpgradePack.java
@@ -93,7 +93,7 @@ public class UpgradePack {
    * Tag is optional and can be {@code null}, use {@code isDowngradeAllowed} getter instead.
    */
   @XmlElement(name = "downgrade-allowed", required = false)
-  private Boolean downgradeAllowed = null;
+  private boolean downgradeAllowed = true;
 
   /**
    * {@code true} to automatically skip service check failures. The default is
@@ -202,13 +202,9 @@ public class UpgradePack {
 
   /**
    * @return {@code true} if upgrade pack supports downgrade or {@code false} if not.
-   * Default {@code true}
    */
   public boolean isDowngradeAllowed(){
-    if (downgradeAllowed != null) {
-      return downgradeAllowed;  // if tag is present, just return exact value
-    }
-    return true;
+    return downgradeAllowed;
   }
 
   public boolean canBeApplied(String targetVersion){
@@ -284,14 +280,11 @@ public class UpgradePack {
   }
 
   private List<Grouping> getDowngradeGroupsForNonrolling() {
-    throw new UnsupportedOperationException("TODO AMBARI-12698");
-    /*
     List<Grouping> list = new ArrayList<Grouping>();
     for (Grouping g : groups) {
       list.add(g);
     }
     return list;
-    */
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/aed8e5e5/ambari-server/src/test/java/org/apache/ambari/server/state/stack/UpgradePackTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/stack/UpgradePackTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/stack/UpgradePackTest.java
index 0cd734e..2b49a51 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/stack/UpgradePackTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/stack/UpgradePackTest.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import java.util.Arrays;
+import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -231,22 +232,41 @@ public class UpgradePackTest {
     UpgradePack upgrade = upgrades.get("upgrade_test_nonrolling");
 
     List<String> expected_up = Arrays.asList(
-        "PRE_CLUSTER",
-        "Stop High-Level Daemons",
-        "Backups",
-        "Stop Low-Level Daemons",
-        "UPDATE_DESIRED_STACK_ID",
-        "ALL_HOST_OPS",
-        "ZOOKEEPER",
-        "HDFS",
-        "MR and YARN",
-        "POST_CLUSTER");
+      "PRE_CLUSTER",
+      "Stop High-Level Daemons",
+      "Backups",
+      "Stop Low-Level Daemons",
+      "UPDATE_DESIRED_STACK_ID",
+      "ALL_HOST_OPS",
+      "ZOOKEEPER",
+      "HDFS",
+      "MR and YARN",
+      "POST_CLUSTER");
 
-    int i = 0;
-    List<Grouping> groups = upgrade.getGroups(Direction.UPGRADE);
-    for (Grouping g : groups) {
-      assertEquals(expected_up.get(i), g.name);
-      i++;
+    List<String> expected_down = Arrays.asList(
+      "Stop High-Level Daemons",
+      "Stop Low-Level Daemons",
+      "Restore Backups",
+      "UPDATE_DESIRED_STACK_ID",
+      "ALL_HOST_OPS",
+      "ZOOKEEPER",
+      "HDFS",
+      "MR and YARN",
+      "POST_CLUSTER");
+
+
+    Iterator<String> itr_up = expected_up.iterator();
+    List<Grouping> upgrade_groups = upgrade.getGroups(Direction.UPGRADE);
+    for (Grouping g : upgrade_groups) {
+      assertEquals(true, itr_up.hasNext());
+      assertEquals(itr_up.next(), g.name);
+    }
+
+    Iterator<String> itr_down = expected_down.iterator();
+    List<Grouping> downgrade_groups = upgrade.getGroups(Direction.DOWNGRADE);
+    for (Grouping g : downgrade_groups) {
+      assertEquals(true, itr_down.hasNext());
+      assertEquals(itr_down.next(), g.name);
     }
   }
   


Mime
View raw message