ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject ambari git commit: AMBARI-13681. Changing 'Skip service check failure' and 'Skip slave component failure' options after RU is kicked off does not work (ncole)
Date Tue, 03 Nov 2015 13:40:59 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 76dd478e5 -> 60b835847


AMBARI-13681. Changing 'Skip service check failure' and 'Skip slave component failure' options
after RU is kicked off does not work (ncole)


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

Branch: refs/heads/trunk
Commit: 60b835847603c165f4235856a1ae04981cc10bd8
Parents: 76dd478
Author: Nate Cole <ncole@hortonworks.com>
Authored: Mon Nov 2 13:28:24 2015 -0500
Committer: Nate Cole <ncole@hortonworks.com>
Committed: Tue Nov 3 07:58:29 2015 -0500

----------------------------------------------------------------------
 .../internal/UpgradeResourceProvider.java       | 11 +--
 .../server/orm/dao/HostRoleCommandDAO.java      | 72 +++++--------------
 .../internal/UpgradeResourceProviderTest.java   | 75 ++++++++++++++++++++
 .../server/orm/dao/HostRoleCommandDAOTest.java  | 39 ----------
 4 files changed, 97 insertions(+), 100 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/60b83584/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 7978a7a..915e431 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
@@ -96,10 +96,8 @@ import org.apache.ambari.server.state.stack.upgrade.ConfigureTask;
 import org.apache.ambari.server.state.stack.upgrade.Direction;
 import org.apache.ambari.server.state.stack.upgrade.Grouping;
 import org.apache.ambari.server.state.stack.upgrade.ManualTask;
-import org.apache.ambari.server.state.stack.upgrade.RestartGrouping;
 import org.apache.ambari.server.state.stack.upgrade.ServerSideActionTask;
 import org.apache.ambari.server.state.stack.upgrade.StageWrapper;
-import org.apache.ambari.server.state.stack.upgrade.StopGrouping;
 import org.apache.ambari.server.state.stack.upgrade.Task;
 import org.apache.ambari.server.state.stack.upgrade.TaskWrapper;
 import org.apache.ambari.server.state.stack.upgrade.UpdateStackGrouping;
@@ -438,23 +436,20 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
       boolean skipFailures = upgradeEntity.isComponentFailureAutoSkipped();
       boolean skipServiceCheckFailures = upgradeEntity.isServiceCheckFailureAutoSkipped();
 
-      // update skipping failures on commands which are not SERVICE_CHECKs
       if (null != skipFailuresRequestProperty) {
         skipFailures = Boolean.parseBoolean(skipFailuresRequestProperty);
-        s_hostRoleCommandDAO.updateAutomaticSkipOnFailure(requestId, skipFailures);
       }
 
-      // if the service check failure skip is present, then update all role
-      // commands that are SERVICE_CHECKs
       if (null != skipServiceCheckFailuresRequestProperty) {
         skipServiceCheckFailures = Boolean.parseBoolean(skipServiceCheckFailuresRequestProperty);
-        s_hostRoleCommandDAO.updateAutomaticSkipServiceCheckFailure(requestId,
-            skipServiceCheckFailures);
       }
 
+      s_hostRoleCommandDAO.updateAutomaticSkipOnFailure(requestId, skipFailures, skipServiceCheckFailures);
+
       upgradeEntity.setAutoSkipComponentFailures(skipFailures);
       upgradeEntity.setAutoSkipServiceCheckFailures(skipServiceCheckFailures);
       upgradeEntity = s_upgradeDAO.merge(upgradeEntity);
+
     }
 
     return getRequestStatus(null);

http://git-wip-us.apache.org/repos/asf/ambari/blob/60b83584/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java
index 14af03d..8b167ca 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java
@@ -478,67 +478,33 @@ public class HostRoleCommandDAO {
 
   /**
    * Updates the {@link HostRoleCommandEntity#isFailureAutoSkipped()} flag for
-   * all commands which are not {@link RoleCommand#SERVICE_CHECK}.
+   * all commands for the given request
    * <p/>
-   * This will execute a JPQL {@code UPDATE} statement, bypassing the
-   * {@link EntityManager}. It does this because the amount of
-   * {@link HostRoleCommandEntity}s could number in the 10's of 1000's. As a
-   * result, this will call {@link EntityManager#clear()} after the update to
-   * ensure that the updated entity state is reflected in future queries.
+   * This will update each entity to ensure that the cache is maintained in a correct
+   * state.  A batch update doesn't always reflect in JPA-managed entities
    *
    * @param requestId
    *          the request ID of the commands to update
-   * @param automaticallySkipOnFailure
+   * @param skipOnFailure
    *          {@code true} to automatically skip failures, {@code false}
    *          otherwise.
-   * @see HostRoleCommandDAO#updateAutomaticSkipServiceCheckFailure(long,
-   *      boolean)
+   * @param skipOnServiceCheckFailure
+   *          {@code true} to skip service check failures
    */
   @Transactional
-  public void updateAutomaticSkipOnFailure(long requestId, boolean automaticallySkipOnFailure)
{
-    EntityManager entityManager = entityManagerProvider.get();
-
-    TypedQuery<HostRoleCommandEntity> query = entityManager.createNamedQuery(
-        "HostRoleCommandEntity.updateAutoSkipExcludeRoleCommand", HostRoleCommandEntity.class);
-
-    query.setParameter("requestId", requestId);
-    query.setParameter("roleCommand", RoleCommand.SERVICE_CHECK);
-    query.setParameter("autoSkipOnFailure", automaticallySkipOnFailure ? 1 : 0);
-    query.executeUpdate();
-
-    entityManager.clear();
+  public void updateAutomaticSkipOnFailure(long requestId,
+      boolean skipOnFailure, boolean skipOnServiceCheckFailure) {
+
+    List<HostRoleCommandEntity> tasks = findByRequest(requestId);
+    for (HostRoleCommandEntity task : tasks) {
+      if (task.getRoleCommand() == RoleCommand.SERVICE_CHECK ) {
+        task.setAutoSkipOnFailure(skipOnServiceCheckFailure);
+        merge(task);
+      } else {
+        task.setAutoSkipOnFailure(skipOnFailure);
+        merge(task);
+      }
+    }
   }
 
-  /**
-   * Updates the {@link HostRoleCommandEntity#isFailureAutoSkipped()} flag for
-   * all commands which are of type {@link RoleCommand#SERVICE_CHECK}.
-   * <p/>
-   * This will execute a JPQL {@code UPDATE} statement, bypassing the
-   * {@link EntityManager}. It does this because the amount of
-   * {@link HostRoleCommandEntity}s could number in the 10's of 1000's. As a
-   * result, this will call {@link EntityManager#clear()} after the update to
-   * ensure that the updated entity state is reflected in future queries.
-   *
-   * @param requestId
-   *          the request ID of the service check commands to update
-   * @param automaticallySkipOnFailure
-   *          {@code true} to automatically skip service check failures,
-   *          {@code false} otherwise.
-   * @see HostRoleCommandDAO#updateAutomaticSkipOnFailure(long, boolean)
-   */
-  @Transactional
-  public void updateAutomaticSkipServiceCheckFailure(long requestId,
-      boolean automaticallySkipOnFailure) {
-    EntityManager entityManager = entityManagerProvider.get();
-
-    TypedQuery<HostRoleCommandEntity> query = entityManager.createNamedQuery(
-        "HostRoleCommandEntity.updateAutoSkipForRoleCommand", HostRoleCommandEntity.class);
-
-    query.setParameter("requestId", requestId);
-    query.setParameter("roleCommand", RoleCommand.SERVICE_CHECK);
-    query.setParameter("autoSkipOnFailure", automaticallySkipOnFailure ? 1 : 0);
-    query.executeUpdate();
-
-    entityManager.clear();
-  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/60b83584/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 1806f4c..3cbf62b 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
@@ -35,6 +35,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.ambari.server.Role;
+import org.apache.ambari.server.RoleCommand;
 import org.apache.ambari.server.actionmanager.ActionManager;
 import org.apache.ambari.server.actionmanager.HostRoleCommand;
 import org.apache.ambari.server.actionmanager.HostRoleStatus;
@@ -1127,6 +1128,80 @@ public class UpgradeResourceProviderTest {
     return status;
   }
 
+  @Test
+  public void testUpdateSkipFailures() throws Exception {
+    testCreateResourcesWithAutoSkipFailures();
+
+    List<UpgradeEntity> upgrades = upgradeDao.findUpgrades(1);
+    assertEquals(1, upgrades.size());
+
+    UpgradeEntity entity = upgrades.get(0);
+
+    HostRoleCommandDAO dao = injector.getInstance(HostRoleCommandDAO.class);
+
+    List<HostRoleCommandEntity> tasks = dao.findByRequest(entity.getRequestId());
+    for (HostRoleCommandEntity task : tasks) {
+      assertTrue(task.isFailureAutoSkipped());
+    }
+
+    Map<String, Object> requestProps = new HashMap<String, Object>();
+    requestProps.put(UpgradeResourceProvider.UPGRADE_CLUSTER_NAME, "c1");
+    requestProps.put(UpgradeResourceProvider.UPGRADE_VERSION, "2.2.0.0");
+    requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_FAILURES, Boolean.TRUE.toString());
+    requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_SC_FAILURES, Boolean.FALSE.toString());
+    requestProps.put(UpgradeResourceProvider.UPGRADE_REQUEST_ID, "" + entity.getRequestId());
+
+    ResourceProvider upgradeResourceProvider = createProvider(amc);
+    Request request = PropertyHelper.getUpdateRequest(requestProps, null);
+    upgradeResourceProvider.updateResources(request, null);
+
+    tasks = dao.findByRequest(entity.getRequestId());
+    for (HostRoleCommandEntity task : tasks) {
+      if (task.getRoleCommand() == RoleCommand.SERVICE_CHECK) {
+        assertFalse(task.isFailureAutoSkipped());
+      } else {
+        assertTrue(task.isFailureAutoSkipped());
+      }
+    }
+
+    requestProps = new HashMap<String, Object>();
+    requestProps.put(UpgradeResourceProvider.UPGRADE_CLUSTER_NAME, "c1");
+    requestProps.put(UpgradeResourceProvider.UPGRADE_VERSION, "2.2.0.0");
+    requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_FAILURES, Boolean.FALSE.toString());
+    requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_SC_FAILURES, Boolean.TRUE.toString());
+    requestProps.put(UpgradeResourceProvider.UPGRADE_REQUEST_ID, "" + entity.getRequestId());
+
+    request = PropertyHelper.getUpdateRequest(requestProps, null);
+    upgradeResourceProvider.updateResources(request, null);
+
+    tasks = dao.findByRequest(entity.getRequestId());
+    for (HostRoleCommandEntity task : tasks) {
+      if (task.getRoleCommand() == RoleCommand.SERVICE_CHECK) {
+        assertTrue(task.isFailureAutoSkipped());
+      } else {
+        assertFalse(task.isFailureAutoSkipped());
+      }
+    }
+
+    requestProps = new HashMap<String, Object>();
+    requestProps.put(UpgradeResourceProvider.UPGRADE_CLUSTER_NAME, "c1");
+    requestProps.put(UpgradeResourceProvider.UPGRADE_VERSION, "2.2.0.0");
+    requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_FAILURES, Boolean.FALSE.toString());
+    requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_SC_FAILURES, Boolean.FALSE.toString());
+    requestProps.put(UpgradeResourceProvider.UPGRADE_REQUEST_ID, "" + entity.getRequestId());
+
+    request = PropertyHelper.getUpdateRequest(requestProps, null);
+    upgradeResourceProvider.updateResources(request, null);
+
+    tasks = dao.findByRequest(entity.getRequestId());
+    for (HostRoleCommandEntity task : tasks) {
+      assertFalse(task.isFailureAutoSkipped());
+    }
+
+
+  }
+
+
   /**
    *
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/60b83584/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAOTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAOTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAOTest.java
index d7e9149..167e49c 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAOTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAOTest.java
@@ -108,45 +108,6 @@ public class HostRoleCommandDAOTest {
     Assert.assertEquals(0, tasks.size());
   }
 
-  /**
-   * Tests updating various commands to be skipped on failures automatically.
-   */
-  @Test
-  public void testUpdateAutoSkipOnFailures() {
-    OrmTestHelper helper = m_injector.getInstance(OrmTestHelper.class);
-    helper.createDefaultData();
-
-    Long requestId = Long.valueOf(100L);
-    ClusterEntity clusterEntity = m_clusterDAO.findByName("test_cluster1");
-
-    RequestEntity requestEntity = new RequestEntity();
-    requestEntity.setRequestId(requestId);
-    requestEntity.setClusterId(clusterEntity.getClusterId());
-    requestEntity.setStages(new ArrayList<StageEntity>());
-    m_requestDAO.create(requestEntity);
-
-    AtomicLong stageId = new AtomicLong(1);
-    HostEntity host = m_hostDAO.findByName("test_host1");
-    host.setHostRoleCommandEntities(new ArrayList<HostRoleCommandEntity>());
-
-    createStage(stageId.getAndIncrement(), 3, host, requestEntity, HostRoleStatus.PENDING,
false);
-    createStage(stageId.getAndIncrement(), 2, host, requestEntity, HostRoleStatus.PENDING,
false);
-    createStage(stageId.getAndIncrement(), 1, host, requestEntity, HostRoleStatus.PENDING,
false);
-
-    List<HostRoleCommandEntity> tasks = m_hostRoleCommandDAO.findByRequest(requestId);
-    Assert.assertEquals(6, tasks.size());
-
-    for (HostRoleCommandEntity task : tasks) {
-      Assert.assertFalse(task.isFailureAutoSkipped());
-    }
-
-    m_hostRoleCommandDAO.updateAutomaticSkipOnFailure(requestId, true);
-    tasks = m_hostRoleCommandDAO.findByRequest(requestId);
-
-    for (HostRoleCommandEntity task : tasks) {
-      Assert.assertTrue(task.isFailureAutoSkipped());
-    }
-  }
 
   /**
    * Creates a single stage with the specified number of commands.


Mime
View raw message