ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject ambari git commit: AMBARI-13491 - Expose Failure Auto-Skip Setting On Upgrade Endpoint (jonathanhurley)
Date Tue, 20 Oct 2015 21:02:47 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 2aee7bf10 -> d2dc26350


AMBARI-13491 - Expose Failure Auto-Skip Setting On Upgrade Endpoint (jonathanhurley)


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

Branch: refs/heads/branch-2.1
Commit: d2dc2635002a719172c083e443a7a251b8ad2737
Parents: 2aee7bf
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Tue Oct 20 12:05:11 2015 -0400
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Tue Oct 20 17:02:14 2015 -0400

----------------------------------------------------------------------
 .../internal/UpgradeResourceProvider.java       |   6 +-
 .../server/orm/entities/UpgradeEntity.java      |  57 ++++++++++-
 .../server/upgrade/UpgradeCatalog213.java       | 100 +++++++++++++------
 .../main/resources/Ambari-DDL-MySQL-CREATE.sql  |   2 +
 .../main/resources/Ambari-DDL-Oracle-CREATE.sql |   2 +
 .../resources/Ambari-DDL-Postgres-CREATE.sql    |   2 +
 .../Ambari-DDL-Postgres-EMBEDDED-CREATE.sql     |   2 +
 .../resources/Ambari-DDL-SQLAnywhere-CREATE.sql |   2 +
 .../resources/Ambari-DDL-SQLServer-CREATE.sql   |   2 +
 .../internal/UpgradeResourceProviderTest.java   |  58 ++++++++++-
 .../ambari/server/orm/dao/UpgradeDAOTest.java   |  31 ++++++
 .../server/upgrade/UpgradeCatalog213Test.java   |  78 ++++++++-------
 12 files changed, 268 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d2dc2635/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 153fc9c..d1b5102 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
@@ -467,6 +467,8 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
     setResourceProperty(resource, UPGRADE_TO_VERSION, entity.getToVersion(), requestedIds);
     setResourceProperty(resource, UPGRADE_DIRECTION, entity.getDirection(), requestedIds);
     setResourceProperty(resource, UPGRADE_DOWNGRADE_ALLOWED, entity.isDowngradeAllowed(),
requestedIds);
+    setResourceProperty(resource, UPGRADE_SKIP_FAILURES, entity.isComponentFailureAutoSkipped(),
requestedIds);
+    setResourceProperty(resource, UPGRADE_SKIP_SC_FAILURES, entity.isServiceCheckFailureAutoSkipped(),
requestedIds);
 
     return resource;
   }
@@ -764,7 +766,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
               itemEntity.setTasks(wrapper.getTasksJson());
               itemEntity.setHosts(wrapper.getHostsJson());
               itemEntities.add(itemEntity);
-              
+
               // At this point, need to change the effective Stack Id so that subsequent
tasks run on the newer value.
               // TODO AMBARI-12698, check if this works during a Stop-the-World Downgrade.
               if (UpdateStackGrouping.class.equals(group.groupClass)) {
@@ -808,6 +810,8 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
     entity.setDirection(direction);
     entity.setUpgradePackage(pack.getName());
     entity.setUpgradeType(pack.getType());
+    entity.setAutoSkipComponentFailures(skipComponentFailures);
+    entity.setAutoSkipServiceCheckFailures(skipServiceCheckFailures);
     entity.setDowngradeAllowed(pack.isDowngradeAllowed());
 
     req.getRequestStatusResponse();

http://git-wip-us.apache.org/repos/asf/ambari/blob/d2dc2635/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 297fc8d..e14fc75 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
@@ -33,14 +33,15 @@ import javax.persistence.OneToMany;
 import javax.persistence.Table;
 import javax.persistence.TableGenerator;
 
+import org.apache.ambari.server.actionmanager.HostRoleStatus;
 import org.apache.ambari.server.state.stack.upgrade.Direction;
 import org.apache.ambari.server.state.stack.upgrade.UpgradeType;
 
 /**
  * Models the data representation of an upgrade
  */
-@Table(name = "upgrade")
 @Entity
+@Table(name = "upgrade")
 @TableGenerator(name = "upgrade_id_generator",
     table = "ambari_sequences", pkColumnName = "sequence_name", valueColumnName = "sequence_value",
     pkColumnValue = "upgrade_id_seq", initialValue = 0)
@@ -84,6 +85,12 @@ public class UpgradeEntity {
   @Enumerated(value = EnumType.STRING)
   private UpgradeType upgradeType;
 
+  @Column(name = "skip_failures", nullable = false)
+  private Integer skipFailures = 0;
+
+  @Column(name = "skip_sc_failures", nullable = false)
+  private Integer skipServiceCheckFailures = 0;
+
   @Column(name="downgrade_allowed", nullable = false)
   private Integer downgrade_allowed = 1;
 
@@ -207,7 +214,7 @@ public class UpgradeEntity {
   /**
    * @param canDowngrade {@code true} to allow downgrade, {@code false} to disallow downgrade
    */
-  public void setDowngradeAllowed(boolean canDowngrade){ this.downgrade_allowed = (!canDowngrade
? 0 : 1); }
+  public void setDowngradeAllowed(boolean canDowngrade){ downgrade_allowed = (!canDowngrade
? 0 : 1); }
 
   /**
    * @param upgradeType the upgrade type to set
@@ -230,6 +237,52 @@ public class UpgradeEntity {
     this.upgradePackage = upgradePackage;
   }
 
+  /**
+   * Gets whether skippable components that failed are automatically skipped.
+   * They will be placed into the {@link HostRoleStatus#SKIPPED_FAILED} state.
+   *
+   * @return {@code true} if skippable failed components are automatically
+   *         skipped when they fail.
+   */
+  public boolean isComponentFailureAutoSkipped() {
+    return skipFailures != 0;
+  }
+
+  /**
+   * Sets whether skippable components that failed are automatically skipped.
+   *
+   * @param autoSkipComponentFailures
+   *          {@code true} to automatically skip component failures which are
+   *          marked as skippable.
+   */
+  public void setAutoSkipComponentFailures(boolean autoSkipComponentFailures) {
+    skipFailures = autoSkipComponentFailures ? 1 : 0;
+  }
+
+  /**
+   * Gets whether skippable service checks that failed are automatically
+   * skipped. They will be placed into the {@link HostRoleStatus#SKIPPED_FAILED}
+   * state.
+   *
+   * @return {@code true} if service checks are automatically skipped when they
+   *         fail.
+   */
+  public boolean isServiceCheckFailureAutoSkipped() {
+    return skipServiceCheckFailures != 0;
+  }
+
+  /**
+   * Sets whether skippable service checks that failed are automatically
+   * skipped.
+   *
+   * @param autoSkipServiceCheckFailures
+   *          {@code true} to automatically skip service check failures which
+   *          are marked as being skippable.
+   */
+  public void setAutoSkipServiceCheckFailures(boolean autoSkipServiceCheckFailures) {
+    skipServiceCheckFailures = autoSkipServiceCheckFailures ? 1 : 0;
+  }
+
   @Override
   public boolean equals(Object o) {
     if (this == o) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/d2dc2635/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog213.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog213.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog213.java
index 94d3319..3695faa 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog213.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog213.java
@@ -18,34 +18,42 @@
 
 package org.apache.ambari.server.upgrade;
 
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import com.google.inject.persist.Transactional;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.AmbariManagementController;
-import org.apache.ambari.server.orm.DBAccessor.DBColumnInfo;
 import org.apache.ambari.server.orm.DBAccessor;
 import org.apache.ambari.server.orm.DBAccessor.DBColumnInfo;
 import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
 import org.apache.ambari.server.orm.dao.ClusterDAO;
 import org.apache.ambari.server.orm.dao.ClusterVersionDAO;
 import org.apache.ambari.server.orm.dao.DaoUtils;
-import org.apache.ambari.server.orm.dao.UpgradeDAO;
 import org.apache.ambari.server.orm.dao.HostVersionDAO;
 import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
 import org.apache.ambari.server.orm.dao.StackDAO;
+import org.apache.ambari.server.orm.dao.UpgradeDAO;
 import org.apache.ambari.server.orm.entities.AlertDefinitionEntity;
-import org.apache.ambari.server.orm.entities.UpgradeEntity;
 import org.apache.ambari.server.orm.entities.ClusterEntity;
 import org.apache.ambari.server.orm.entities.ClusterVersionEntity;
 import org.apache.ambari.server.orm.entities.HostEntity;
 import org.apache.ambari.server.orm.entities.HostVersionEntity;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.orm.entities.StackEntity;
+import org.apache.ambari.server.orm.entities.UpgradeEntity;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
@@ -61,19 +69,11 @@ import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.text.MessageFormat;
-import java.util.Collection;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.persist.Transactional;
 
 /**
  * Upgrade catalog for version 2.1.3.
@@ -98,7 +98,10 @@ public class UpgradeCatalog213 extends AbstractUpgradeCatalog {
                                     "  ulimit -l {{datanode_max_locked_memory}}\n" +
                                     "fi\n" +
                                     "{% endif %};\n";
+
   private static final String DOWNGRADE_ALLOWED_COLUMN = "downgrade_allowed";
+  private static final String UPGRADE_SKIP_FAILURE_COLUMN = "skip_failures";
+  private static final String UPGRADE_SKIP_SC_FAILURE_COLUMN = "skip_sc_failures";
   public static final String UPGRADE_PACKAGE_COL = "upgrade_package";
   public static final String UPGRADE_TYPE_COL = "upgrade_type";
   public static final String REPO_VERSION_TABLE = "repo_version";
@@ -164,11 +167,10 @@ public class UpgradeCatalog213 extends AbstractUpgradeCatalog {
   }
 
   protected void executeUpgradeDDLUpdates() throws AmbariException, SQLException {
-    dbAccessor.addColumn(UPGRADE_TABLE, new DBColumnInfo(DOWNGRADE_ALLOWED_COLUMN, Short.class,
1, null, true));
+    updateUpgradesDDL();
   }
 
   private void addKerberosDescriptorTable() throws SQLException {
-
     List<DBAccessor.DBColumnInfo> columns = new ArrayList<DBAccessor.DBColumnInfo>();
     columns.add(new DBAccessor.DBColumnInfo(KERBEROS_DESCRIPTOR_NAME_COLUMN, String.class,
255, null, false));
     columns.add(new DBAccessor.DBColumnInfo(KERBEROS_DESCRIPTOR_COLUMN, char[].class, null,
null, false));
@@ -182,21 +184,43 @@ public class UpgradeCatalog213 extends AbstractUpgradeCatalog {
    */
   @Override
   protected void executePreDMLUpdates() throws AmbariException, SQLException {
-    populateDowngradeAllowed();
+    executeUpgradePreDMLUpdates();
   }
 
-  protected void populateDowngradeAllowed() throws AmbariException, SQLException {
+  /**
+   * Updates the following columns on the {@value #UPGRADE_TABLE} table to
+   * default values:
+   * <ul>
+   * <li>{value {@link #DOWNGRADE_ALLOWED_COLUMN}}</li>
+   * <li>{value {@link #UPGRADE_SKIP_FAILURE_COLUMN}}</li>
+   * <li>{value {@link #UPGRADE_SKIP_SC_FAILURE_COLUMN}}</li>
+   * </ul>
+   *
+   * @throws AmbariException
+   * @throws SQLException
+   */
+  protected void executeUpgradePreDMLUpdates() throws AmbariException, SQLException {
     UpgradeDAO upgradeDAO = injector.getInstance(UpgradeDAO.class);
     List<UpgradeEntity> upgrades = upgradeDAO.findAll();
     for (UpgradeEntity upgrade: upgrades){
       if (upgrade.isDowngradeAllowed() == null) {
         upgrade.setDowngradeAllowed(true);
         upgradeDAO.merge(upgrade);
-        LOG.info(String.format("Update upgrade id %s, upgrade pack %s from version %s to
%s",
-          upgrade.getId(), upgrade.getUpgradePackage(), upgrade.getFromVersion(), upgrade.getToVersion()));
       }
+
+      // ensure that these are set to false for existing upgrades
+      upgrade.setAutoSkipComponentFailures(false);
+      upgrade.setAutoSkipServiceCheckFailures(false);
+
+      LOG.info(String.format("Updated upgrade id %s, upgrade pack %s from version %s to %s",
+          upgrade.getId(), upgrade.getUpgradePackage(), upgrade.getFromVersion(),
+          upgrade.getToVersion()));
     }
+
+    // make the columns nullable now that they have defaults
     dbAccessor.setColumnNullable(UPGRADE_TABLE, DOWNGRADE_ALLOWED_COLUMN, false);
+    dbAccessor.setColumnNullable(UPGRADE_TABLE, UPGRADE_SKIP_FAILURE_COLUMN, false);
+    dbAccessor.setColumnNullable(UPGRADE_TABLE, UPGRADE_SKIP_SC_FAILURE_COLUMN, false);
   }
 
   @Override
@@ -241,7 +265,7 @@ public class UpgradeCatalog213 extends AbstractUpgradeCatalog {
     }
 
     // Populate values in upgrade table.
-    boolean success = this.populateUpgradeTable();
+    boolean success = populateUpgradeTable();
 
     if (!success) {
       throw new AmbariException("Errors found while populating the upgrade table with values
for columns upgrade_type and upgrade_package.");
@@ -333,7 +357,7 @@ public class UpgradeCatalog213 extends AbstractUpgradeCatalog {
 
                 if (null != cluster) {
                   stack = cluster.getDesiredStack();
-                  upgradePackage = this.calculateUpgradePackage(stack, version);
+                  upgradePackage = calculateUpgradePackage(stack, version);
                 } else {
                   LOG.error("Could not find a cluster with cluster_id " + clusterId);
                 }
@@ -540,7 +564,23 @@ public class UpgradeCatalog213 extends AbstractUpgradeCatalog {
       }
     }
   }
-  
+
+  /**
+   * Adds the following columns to the {@value #UPGRADE_TABLE} table:
+   * <ul>
+   * <li>{@value #DOWNGRADE_ALLOWED_COLUMN}</li>
+   * <li>{@value #UPGRADE_SKIP_FAILURE_COLUMN}</li>
+   * <li>{@value #UPGRADE_SKIP_SC_FAILURE_COLUMN}</li>
+   * </ul>
+   *
+   * @throws SQLException
+   */
+  protected void updateUpgradesDDL() throws SQLException{
+    dbAccessor.addColumn(UPGRADE_TABLE, new DBColumnInfo(DOWNGRADE_ALLOWED_COLUMN, Short.class,
1, null, true));
+    dbAccessor.addColumn(UPGRADE_TABLE, new DBColumnInfo(UPGRADE_SKIP_FAILURE_COLUMN, Short.class,
1, null, true));
+    dbAccessor.addColumn(UPGRADE_TABLE, new DBColumnInfo(UPGRADE_SKIP_SC_FAILURE_COLUMN,
Short.class, 1, null, true));
+  }
+
   /**
    * Modifies the JSON of some of the alert definitions which have changed
    * between Ambari versions.

http://git-wip-us.apache.org/repos/asf/ambari/blob/d2dc2635/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
index c7dd7e3..4ffe8da 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -891,6 +891,8 @@ CREATE TABLE upgrade (
   direction VARCHAR(255) DEFAULT 'UPGRADE' NOT NULL,
   upgrade_package VARCHAR(255) NOT NULL,
   upgrade_type VARCHAR(32) NOT NULL,
+  skip_failures TINYINT(1) NOT NULL DEFAULT 0,
+  skip_sc_failures TINYINT(1) NOT NULL DEFAULT 0,
   downgrade_allowed TINYINT(1) NOT NULL DEFAULT 1,
   PRIMARY KEY (upgrade_id),
   FOREIGN KEY (cluster_id) REFERENCES clusters(cluster_id),

http://git-wip-us.apache.org/repos/asf/ambari/blob/d2dc2635/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
index 08b4387..8fb6e68 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -880,6 +880,8 @@ CREATE TABLE upgrade (
   direction VARCHAR2(255) DEFAULT 'UPGRADE' NOT NULL,
   upgrade_package VARCHAR2(255) NOT NULL,
   upgrade_type VARCHAR2(32) NOT NULL,
+  skip_failures NUMBER(1) DEFAULT 0 NOT NULL,
+  skip_sc_failures NUMBER(1) DEFAULT 0 NOT NULL,
   downgrade_allowed NUMBER(1) DEFAULT 1 NOT NULL,
   PRIMARY KEY (upgrade_id),
   FOREIGN KEY (cluster_id) REFERENCES clusters(cluster_id),

http://git-wip-us.apache.org/repos/asf/ambari/blob/d2dc2635/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
index e60cb3c..fb98757 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -882,6 +882,8 @@ CREATE TABLE upgrade (
   direction VARCHAR(255) DEFAULT 'UPGRADE' NOT NULL,
   upgrade_package VARCHAR(255) NOT NULL,
   upgrade_type VARCHAR(32) NOT NULL,
+  skip_failures SMALLINT DEFAULT 0 NOT NULL,
+  skip_sc_failures SMALLINT DEFAULT 0 NOT NULL,
   downgrade_allowed SMALLINT DEFAULT 1 NOT NULL,
   PRIMARY KEY (upgrade_id),
   FOREIGN KEY (cluster_id) REFERENCES clusters(cluster_id),

http://git-wip-us.apache.org/repos/asf/ambari/blob/d2dc2635/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
index ada60a6..098444b 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
@@ -974,6 +974,8 @@ CREATE TABLE ambari.upgrade (
   direction VARCHAR(255) DEFAULT 'UPGRADE' NOT NULL,
   upgrade_package VARCHAR(255) NOT NULL,
   upgrade_type VARCHAR(32) NOT NULL,
+  skip_failures SMALLINT DEFAULT 0 NOT NULL,
+  skip_sc_failures SMALLINT DEFAULT 0 NOT NULL,
   downgrade_allowed SMALLINT DEFAULT 1 NOT NULL,
   PRIMARY KEY (upgrade_id),
   FOREIGN KEY (cluster_id) REFERENCES ambari.clusters(cluster_id),

http://git-wip-us.apache.org/repos/asf/ambari/blob/d2dc2635/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
index 07b3ff7..8eacfa8 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
@@ -879,6 +879,8 @@ CREATE TABLE upgrade (
   from_version VARCHAR(255) DEFAULT '' NOT NULL,
   to_version VARCHAR(255) DEFAULT '' NOT NULL,
   direction VARCHAR(255) DEFAULT 'UPGRADE' NOT NULL,
+  skip_failures BIT NOT NULL DEFAULT 0,
+  skip_sc_failures BIT NOT NULL DEFAULT 0,  
   downgrade_allowed BIT NOT NULL DEFAULT 1,
   PRIMARY KEY (upgrade_id),
   FOREIGN KEY (cluster_id) REFERENCES clusters(cluster_id),

http://git-wip-us.apache.org/repos/asf/ambari/blob/d2dc2635/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
index a7daad0..a947ce0 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
@@ -997,6 +997,8 @@ CREATE TABLE upgrade (
   direction VARCHAR(255) DEFAULT 'UPGRADE' NOT NULL,
   upgrade_package VARCHAR(255) NOT NULL,
   upgrade_type VARCHAR(32) NOT NULL,
+  skip_failures BIT NOT NULL DEFAULT 0,
+  skip_sc_failures BIT NOT NULL DEFAULT 0,
   downgrade_allowed BIT NOT NULL DEFAULT 1,
   PRIMARY KEY CLUSTERED (upgrade_id),
   FOREIGN KEY (cluster_id) REFERENCES clusters(cluster_id),

http://git-wip-us.apache.org/repos/asf/ambari/blob/d2dc2635/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 c0c9d5e..a779949 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
@@ -285,7 +285,7 @@ public class UpgradeResourceProviderTest {
 
     assertEquals("This is a manual task with a placeholder of placeholder-rendered-properly",
         zookeeperUpgradeItems.get(0).getText());
-    assertEquals("Restarting ZooKeeper Server on h1", zookeeperUpgradeItems.get(1).getText());
+    assertEquals("Restarting ZooKeeper Server on " + StageUtils.getHostName(), zookeeperUpgradeItems.get(1).getText());
     assertEquals("Skipping Configuration Task", zookeeperUpgradeItems.get(2).getText());
     assertEquals("Service Check ZooKeeper", zookeeperUpgradeItems.get(3).getText());
     assertEquals("Verifying Skipped Failures", zookeeperUpgradeItems.get(4).getText());
@@ -333,7 +333,7 @@ public class UpgradeResourceProviderTest {
 
     List<UpgradeItemEntity> zookeeperUpgradeItems = zookeeperGroup.getItems();
     assertEquals(3, zookeeperUpgradeItems.size());
-    assertEquals("Restarting ZooKeeper Server on h1", zookeeperUpgradeItems.get(0).getText());
+    assertEquals("Restarting ZooKeeper Server on " + StageUtils.getHostName(), zookeeperUpgradeItems.get(0).getText());
     assertEquals("Skipping Configuration Task", zookeeperUpgradeItems.get(1).getText());
     assertEquals("Service Check ZooKeeper", zookeeperUpgradeItems.get(2).getText());
 
@@ -378,7 +378,7 @@ public class UpgradeResourceProviderTest {
     List<UpgradeItemEntity> zookeeperUpgradeItems = zookeeperGroup.getItems();
     assertEquals(4, zookeeperUpgradeItems.size());
 
-    assertEquals("Restarting ZooKeeper Server on h1", zookeeperUpgradeItems.get(0).getText());
+    assertEquals("Restarting ZooKeeper Server on " + StageUtils.getHostName(), zookeeperUpgradeItems.get(0).getText());
     assertEquals("Skipping Configuration Task", zookeeperUpgradeItems.get(1).getText());
     assertEquals("Service Check ZooKeeper", zookeeperUpgradeItems.get(2).getText());
     assertEquals("Verifying Skipped Failures", zookeeperUpgradeItems.get(3).getText());
@@ -423,8 +423,10 @@ public class UpgradeResourceProviderTest {
     assertEquals(1, resources.size());
     res = resources.iterator().next();
     assertNotNull(res.getPropertyValue("Upgrade/progress_percent"));
-    assertNotNull(res.getPropertyValue("Upgrade/direction"));
-    assertEquals(Direction.UPGRADE, res.getPropertyValue("Upgrade/direction"));
+    assertNotNull(res.getPropertyValue(UpgradeResourceProvider.UPGRADE_DIRECTION));
+    assertEquals(Direction.UPGRADE, res.getPropertyValue(UpgradeResourceProvider.UPGRADE_DIRECTION));
+    assertEquals(false, res.getPropertyValue(UpgradeResourceProvider.UPGRADE_SKIP_FAILURES));
+    assertEquals(false, res.getPropertyValue(UpgradeResourceProvider.UPGRADE_SKIP_SC_FAILURES));
 
     // upgrade groups
     propertyIds.clear();
@@ -486,6 +488,52 @@ public class UpgradeResourceProviderTest {
     assertTrue(res.getPropertyValue("UpgradeItem/text").toString().startsWith("Please confirm"));
   }
 
+  /**
+   * Tests that retrieving an upgrade correctly populates less common upgrade
+   * options correctly.
+   */
+  @Test
+  public void testGetResourcesWithSpecialOptions() throws Exception {
+    Cluster cluster = clusters.getCluster("c1");
+
+    List<UpgradeEntity> upgrades = upgradeDao.findUpgrades(cluster.getClusterId());
+    assertEquals(0, upgrades.size());
+
+    Map<String, Object> requestProps = new HashMap<String, Object>();
+    requestProps.put(UpgradeResourceProvider.UPGRADE_CLUSTER_NAME, "c1");
+    requestProps.put(UpgradeResourceProvider.UPGRADE_VERSION, "2.1.1.1");
+    requestProps.put(UpgradeResourceProvider.UPGRADE_PACK, "upgrade_test");
+    requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_PREREQUISITE_CHECKS, "true");
+
+    // tests skipping SC failure options
+    requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_FAILURES, "true");
+    requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_SC_FAILURES, "true");
+
+    ResourceProvider upgradeResourceProvider = createProvider(amc);
+
+    Request request = PropertyHelper.getCreateRequest(Collections.singleton(requestProps),
null);
+    RequestStatus status = upgradeResourceProvider.createResources(request);
+    assertNotNull(status);
+
+    // upgrade
+    Set<String> propertyIds = new HashSet<String>();
+    propertyIds.add("Upgrade");
+
+    Predicate predicate = new PredicateBuilder()
+      .property(UpgradeResourceProvider.UPGRADE_REQUEST_ID).equals("1").and()
+      .property(UpgradeResourceProvider.UPGRADE_CLUSTER_NAME).equals("c1")
+      .toPredicate();
+
+    request = PropertyHelper.getReadRequest(propertyIds);
+    Set<Resource> resources = upgradeResourceProvider.getResources(request, predicate);
+
+    assertEquals(1, resources.size());
+    Resource resource = resources.iterator().next();
+
+    assertEquals(true, resource.getPropertyValue(UpgradeResourceProvider.UPGRADE_SKIP_FAILURES));
+    assertEquals(true, resource.getPropertyValue(UpgradeResourceProvider.UPGRADE_SKIP_SC_FAILURES));
+  }
+
   @Ignore
   @Test
   public void testCreatePartialDowngrade() throws Exception {

http://git-wip-us.apache.org/repos/asf/ambari/blob/d2dc2635/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/UpgradeDAOTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/UpgradeDAOTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/UpgradeDAOTest.java
index f8f7973..3ad2240 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/UpgradeDAOTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/UpgradeDAOTest.java
@@ -177,4 +177,35 @@ public class UpgradeDAOTest {
     assertNotNull(lastUpgradeForCluster);
     assertEquals(33L, (long)lastUpgradeForCluster.getId());
   }
+
+  /**
+   * Tests that certain columns in an {@link UpgradeEntity} are updatable.
+   *
+   * @throws Exception
+   */
+  @Test
+  public void testUpdatableColumns() throws Exception {
+    UpgradeEntity upgradeEntity = new UpgradeEntity();
+    upgradeEntity.setId(11L);
+    upgradeEntity.setClusterId(Long.valueOf(1));
+    upgradeEntity.setDirection(Direction.UPGRADE);
+    upgradeEntity.setRequestId(Long.valueOf(1));
+    upgradeEntity.setFromVersion("2.2.0.0-1234");
+    upgradeEntity.setToVersion("2.3.0.0-4567");
+    upgradeEntity.setUpgradeType(UpgradeType.ROLLING);
+    upgradeEntity.setUpgradePackage("test-upgrade");
+    dao.create(upgradeEntity);
+
+    UpgradeEntity lastUpgradeForCluster = dao.findLastUpgradeForCluster(1);
+    Assert.assertFalse(lastUpgradeForCluster.isComponentFailureAutoSkipped());
+    Assert.assertFalse(lastUpgradeForCluster.isServiceCheckFailureAutoSkipped());
+
+    lastUpgradeForCluster.setAutoSkipComponentFailures(true);
+    lastUpgradeForCluster.setAutoSkipServiceCheckFailures(true);
+    dao.merge(lastUpgradeForCluster);
+
+    lastUpgradeForCluster = dao.findLastUpgradeForCluster(1);
+    Assert.assertTrue(lastUpgradeForCluster.isComponentFailureAutoSkipped());
+    Assert.assertTrue(lastUpgradeForCluster.isServiceCheckFailureAutoSkipped());
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/d2dc2635/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog213Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog213Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog213Test.java
index 6579ec2..76e96d1 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog213Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog213Test.java
@@ -18,13 +18,31 @@
 
 package org.apache.ambari.server.upgrade;
 
-import com.google.inject.AbstractModule;
-import com.google.inject.Binder;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Module;
-import com.google.inject.Provider;
-import com.google.inject.persist.PersistService;
+import static org.easymock.EasyMock.anyLong;
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.createMockBuilder;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.createStrictMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.reset;
+import static org.easymock.EasyMock.verify;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.configuration.Configuration;
@@ -49,8 +67,8 @@ import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.ConfigHelper;
-import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.RepositoryVersionState;
+import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.StackInfo;
 import org.apache.ambari.server.state.stack.OsFamily;
@@ -64,29 +82,13 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
-import javax.persistence.EntityManager;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import static org.easymock.EasyMock.anyLong;
-import java.util.List;
-import java.util.Map;
-
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.createMockBuilder;
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.verify;
+import com.google.inject.AbstractModule;
+import com.google.inject.Binder;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+import com.google.inject.Provider;
+import com.google.inject.persist.PersistService;
 
 /**
  * {@link org.apache.ambari.server.upgrade.UpgradeCatalog213} unit tests.
@@ -141,6 +143,7 @@ public class UpgradeCatalog213Test {
     final DBAccessor dbAccessor = createNiceMock(DBAccessor.class);
 
     dbAccessor.addColumn(eq("upgrade"), anyObject(DBAccessor.DBColumnInfo.class));
+    expectLastCall().times(3);
 
     replay(dbAccessor);
     Module module = new Module() {
@@ -148,6 +151,7 @@ public class UpgradeCatalog213Test {
       public void configure(Binder binder) {
         binder.bind(DBAccessor.class).toInstance(dbAccessor);
         binder.bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
+        binder.bind(EntityManager.class).toInstance(entityManager);
       }
     };
 
@@ -250,7 +254,7 @@ public class UpgradeCatalog213Test {
     upgradeCatalog213.executeDMLUpdates();
 
     verify(upgradeCatalog213);
-    
+
     //verify(dbAccessor, configuration, resultSet, connection, statement);
 
     // Verify sections
@@ -382,10 +386,9 @@ public class UpgradeCatalog213Test {
     replay(clusterEntity, clusterDAO, hostVersionDAO, hostEntity1, hostEntity2);
   }
 
-
   @Test
-  public void testPopulateDowngradeAllowed() throws Exception {
-    Method executeStackPreDMLUpdates = UpgradeCatalog213.class.getDeclaredMethod("populateDowngradeAllowed");
+  public void testExecuteUpgradePreDMLUpdates() throws Exception {
+    Method executeStackPreDMLUpdates = UpgradeCatalog213.class.getDeclaredMethod("executeUpgradePreDMLUpdates");
 
     final UpgradeCatalog213 upgradeCatalog213 = createMockBuilder(UpgradeCatalog213.class)
       .addMockedMethod(executeStackPreDMLUpdates).createMock();
@@ -396,10 +399,11 @@ public class UpgradeCatalog213Test {
         bind(UpgradeCatalog213.class).toInstance(upgradeCatalog213);
         bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
         bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
+        bind(EntityManager.class).toInstance(entityManager);
       }
     });
 
-    upgradeCatalog213.populateDowngradeAllowed();
+    upgradeCatalog213.executeUpgradePreDMLUpdates();
     expectLastCall().once();
 
     replay(upgradeCatalog213);
@@ -807,6 +811,8 @@ public class UpgradeCatalog213Test {
 
     // executeUpgradeDDLUpdates
     mockedDbAccessor.addColumn(eq("upgrade"), capture(capturedColumn));
+    mockedDbAccessor.addColumn(eq("upgrade"), capture(capturedColumn));
+    mockedDbAccessor.addColumn(eq("upgrade"), capture(capturedColumn));
 
     // addKerberosDescriptorTable
     mockedDbAccessor.createTable(capture(capturedTableName), capture(capturedColumns), capture(capturedPKColumn));


Mime
View raw message