ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From swa...@apache.org
Subject git commit: AMBARI-4378. Rolling restart toleration count - support absolute values only. (swagle)
Date Wed, 22 Jan 2014 01:35:32 GMT
Updated Branches:
  refs/heads/trunk c41796157 -> 4f00cb0bf


AMBARI-4378. Rolling restart toleration count - support absolute values only. (swagle)


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

Branch: refs/heads/trunk
Commit: 4f00cb0bf819ecd70dcf673f57b3d1351e50a795
Parents: c417961
Author: Siddharth Wagle <swagle@hortonworks.com>
Authored: Tue Jan 21 17:34:25 2014 -0800
Committer: Siddharth Wagle <swagle@hortonworks.com>
Committed: Tue Jan 21 17:34:25 2014 -0800

----------------------------------------------------------------------
 .../scheduler/ExecutionScheduleManager.java     | 16 +++++++++-----
 .../scheduler/ExecutionScheduleManagerTest.java | 23 ++++++++++----------
 2 files changed, 22 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4f00cb0b/ambari-server/src/main/java/org/apache/ambari/server/scheduler/ExecutionScheduleManager.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/scheduler/ExecutionScheduleManager.java
b/ambari-server/src/main/java/org/apache/ambari/server/scheduler/ExecutionScheduleManager.java
index a3bae50..d6d0439 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/scheduler/ExecutionScheduleManager.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/scheduler/ExecutionScheduleManager.java
@@ -610,6 +610,15 @@ public class ExecutionScheduleManager {
     return convertToBatchRequestResponse(response);
   }
 
+  /**
+   * Check if the allowed threshold for failed tasks has exceeded.
+   * This needs to be an absolute value of tasks.
+   * @param executionId
+   * @param clusterName
+   * @param taskCounts
+   * @return
+   * @throws AmbariException
+   */
   public boolean hasToleranceThresholdExceeded(Long executionId,
       String clusterName, Map<String, Integer> taskCounts) throws AmbariException {
 
@@ -621,14 +630,11 @@ public class ExecutionScheduleManager {
         + executionId);
     }
 
-    int percentageFailed =
-      (int) ((taskCounts.get(BatchRequestJob.BATCH_REQUEST_FAILED_TASKS_KEY) * 100.0f) /
-      taskCounts.get(BatchRequestJob.BATCH_REQUEST_TOTAL_TASKS_KEY));
-
     BatchSettings batchSettings = requestExecution.getBatch().getBatchSettings();
     if (batchSettings != null
         && batchSettings.getTaskFailureToleranceLimit() != null) {
-      return percentageFailed > batchSettings.getTaskFailureToleranceLimit();
+      return taskCounts.get(BatchRequestJob.BATCH_REQUEST_FAILED_TASKS_KEY) >
+        batchSettings.getTaskFailureToleranceLimit();
     }
 
     return false;

http://git-wip-us.apache.org/repos/asf/ambari/blob/4f00cb0b/ambari-server/src/test/java/org/apache/ambari/server/scheduler/ExecutionScheduleManagerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/scheduler/ExecutionScheduleManagerTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/scheduler/ExecutionScheduleManagerTest.java
index 24e70eb..7b15c3b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/scheduler/ExecutionScheduleManagerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/scheduler/ExecutionScheduleManagerTest.java
@@ -487,13 +487,11 @@ public class ExecutionScheduleManagerTest {
     String clusterName = "c1";
 
     BatchSettings batchSettings = new BatchSettings();
-    batchSettings.setTaskFailureToleranceLimit(10);
+    batchSettings.setTaskFailureToleranceLimit(1);
 
     Map<Long, RequestExecution> executionMap = new HashMap<Long, RequestExecution>();
     executionMap.put(executionId, requestExecutionMock);
 
-
-
     expect(clustersMock.getCluster(clusterName)).andReturn(clusterMock).anyTimes();
     expect(clusterMock.getAllRequestExecutions()).andReturn(executionMap).anyTimes();
     expect(requestExecutionMock.getBatch()).andReturn(batchMock).anyTimes();
@@ -502,8 +500,9 @@ public class ExecutionScheduleManagerTest {
     replay(clustersMock, clusterMock, configurationMock, requestExecutionMock,
       executionSchedulerMock, batchMock);
 
-    ExecutionScheduleManager scheduleManager = new ExecutionScheduleManager(configurationMock,
executionSchedulerMock,
-      tokenStorageMock, clustersMock, actionDBAccessorMock, gson);
+    ExecutionScheduleManager scheduleManager =
+      new ExecutionScheduleManager(configurationMock, executionSchedulerMock,
+        tokenStorageMock, clustersMock, actionDBAccessorMock, gson);
 
     HashMap<String, Integer> taskCounts = new HashMap<String, Integer>() {{
       put(BatchRequestJob.BATCH_REQUEST_FAILED_TASKS_KEY, 2);
@@ -527,6 +526,7 @@ public class ExecutionScheduleManagerTest {
     Configuration configurationMock = createNiceMock(Configuration.class);
     ExecutionScheduler executionSchedulerMock = createMock(ExecutionScheduler.class);
     InternalTokenStorage tokenStorageMock = createMock(InternalTokenStorage.class);
+    ActionDBAccessor actionDBAccessorMock = createMock(ActionDBAccessor.class);
     Gson gson = new Gson();
     RequestExecution requestExecutionMock = createMock(RequestExecution.class);
     Batch batchMock = createMock(Batch.class);
@@ -542,9 +542,10 @@ public class ExecutionScheduleManagerTest {
     Map<Long, RequestExecution> executionMap = new HashMap<Long, RequestExecution>();
     executionMap.put(executionId, requestExecutionMock);
 
-    ExecutionScheduleManager scheduleManager = createMockBuilder(ExecutionScheduleManager.class).
-      withConstructor(configurationMock, executionSchedulerMock,
-        tokenStorageMock, clustersMock, gson).createMock();
+    ExecutionScheduleManager scheduleManager =
+      createMockBuilder(ExecutionScheduleManager.class).withConstructor
+        (configurationMock, executionSchedulerMock, tokenStorageMock,
+          clustersMock, actionDBAccessorMock, gson).createMock();
 
     expectLastCall().anyTimes();
 
@@ -568,14 +569,12 @@ public class ExecutionScheduleManagerTest {
 
     replay(clustersMock, clusterMock, configurationMock, requestExecutionMock,
       executionSchedulerMock, scheduleManager, batchMock, batchRequestMock,
-      triggerMock, jobDetailMock);
-
+      triggerMock, jobDetailMock, actionDBAccessorMock);
 
     scheduleManager.finalizeBatch(executionId, clusterName);
 
-
     verify(clustersMock, clusterMock, configurationMock, requestExecutionMock,
       executionSchedulerMock, scheduleManager, batchMock, batchRequestMock,
-      triggerMock, jobDetailMock);
+      triggerMock, jobDetailMock, actionDBAccessorMock);
   }
 }


Mime
View raw message