hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wan...@apache.org
Subject hadoop git commit: YARN-4315. NaN in Queue percentage for cluster apps page. (Bibin A Chundatt via wangda)
Date Tue, 29 Dec 2015 21:30:46 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 1f8162b74 -> 3efbde537


YARN-4315. NaN in Queue percentage for cluster apps page. (Bibin A Chundatt via wangda)

(cherry picked from commit 561abb9fee5f57f74c2b5868a065b818678622fa)


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

Branch: refs/heads/branch-2
Commit: 3efbde5378d73667b3fb53be656ccf108f6dd2fb
Parents: 1f8162b
Author: Wangda Tan <wangda@apache.org>
Authored: Tue Dec 29 13:28:00 2015 -0800
Committer: Wangda Tan <wangda@apache.org>
Committed: Tue Dec 29 13:29:19 2015 -0800

----------------------------------------------------------------------
 hadoop-yarn-project/CHANGES.txt                 |  2 +
 .../scheduler/SchedulerApplicationAttempt.java  | 17 ++++----
 .../TestSchedulerApplicationAttempt.java        | 43 ++++++++++++++++++--
 3 files changed, 52 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/3efbde53/hadoop-yarn-project/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt
index b192264..82422ca 100644
--- a/hadoop-yarn-project/CHANGES.txt
+++ b/hadoop-yarn-project/CHANGES.txt
@@ -1193,6 +1193,8 @@ Release 2.7.3 - UNRELEASED
     YARN-4452. NPE when submit Unmanaged application. (Naganarasimha G R via
     junping_du)
 
+    YARN-4315. NaN in Queue percentage for cluster apps page. (Bibin A Chundatt via wangda)
+
 Release 2.7.2 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3efbde53/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java
index 22c346d..09f3598 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java
@@ -694,17 +694,20 @@ public class SchedulerApplicationAttempt implements SchedulableEntity
{
         Resources.clone(attemptResourceUsage.getReserved());
     Resource cluster = rmContext.getScheduler().getClusterResource();
     ResourceCalculator calc = rmContext.getScheduler().getResourceCalculator();
-    float queueUsagePerc = calc.divide(cluster, usedResourceClone, Resources
-        .multiply(cluster, queue.getQueueInfo(false, false).getCapacity()))
-        * 100;
-    float clusterUsagePerc =
-        calc.divide(cluster, usedResourceClone, cluster) * 100;
+    float queueUsagePerc = 0.0f;
+    float clusterUsagePerc = 0.0f;
+    if (!calc.isInvalidDivisor(cluster)) {
+      queueUsagePerc =
+          calc.divide(cluster, usedResourceClone, Resources.multiply(cluster,
+              queue.getQueueInfo(false, false).getCapacity())) * 100;
+      clusterUsagePerc = calc.divide(cluster, usedResourceClone, cluster) * 100;
+    }
     return ApplicationResourceUsageReport.newInstance(liveContainers.size(),
         reservedContainers.size(), usedResourceClone, reservedResourceClone,
         Resources.add(usedResourceClone, reservedResourceClone),
         runningResourceUsage.getMemorySeconds(),
-        runningResourceUsage.getVcoreSeconds(),
-        queueUsagePerc, clusterUsagePerc);
+        runningResourceUsage.getVcoreSeconds(), queueUsagePerc,
+        clusterUsagePerc);
   }
 
   public synchronized Map<ContainerId, RMContainer> getLiveContainersMap() {

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3efbde53/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerApplicationAttempt.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerApplicationAttempt.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerApplicationAttempt.java
index ddf3ccf..987aa68 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerApplicationAttempt.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerApplicationAttempt.java
@@ -17,10 +17,9 @@
  */
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler;
 
-import org.apache.hadoop.yarn.api.records.*;
-import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
 import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 import java.util.Arrays;
 import java.util.HashMap;
@@ -28,6 +27,17 @@ import java.util.Map;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.Container;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.api.records.NodeId;
+import org.apache.hadoop.yarn.api.records.Priority;
+import org.apache.hadoop.yarn.api.records.QueueInfo;
+import org.apache.hadoop.yarn.api.records.QueueState;
+import org.apache.hadoop.yarn.api.records.Resource;
+import org.apache.hadoop.yarn.api.records.ResourceRequest;
+import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
 import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler;
 import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
@@ -212,4 +222,31 @@ public class TestSchedulerApplicationAttempt {
     assertEquals(60.0f,
         app.getResourceUsageReport().getClusterUsagePercentage(), 0.01f);
   }
+
+  @Test
+  public void testAppPercentagesOnswitch() throws Exception {
+    FifoScheduler scheduler = mock(FifoScheduler.class);
+    when(scheduler.getClusterResource()).thenReturn(Resource.newInstance(0, 0));
+    when(scheduler.getResourceCalculator())
+        .thenReturn(new DefaultResourceCalculator());
+
+    ApplicationAttemptId appAttId = createAppAttemptId(0, 0);
+    RMContext rmContext = mock(RMContext.class);
+    when(rmContext.getEpoch()).thenReturn(3L);
+    when(rmContext.getScheduler()).thenReturn(scheduler);
+
+    final String user = "user1";
+    Queue queue = createQueue("test", null);
+    SchedulerApplicationAttempt app = new SchedulerApplicationAttempt(appAttId,
+        user, queue, queue.getActiveUsersManager(), rmContext);
+
+    // Resource request
+    Resource requestedResource = Resource.newInstance(1536, 2);
+    app.attemptResourceUsage.incUsed(requestedResource);
+
+    assertEquals(0.0f, app.getResourceUsageReport().getQueueUsagePercentage(),
+        0.0f);
+    assertEquals(0.0f, app.getResourceUsageReport().getClusterUsagePercentage(),
+        0.0f);
+  }
 }


Mime
View raw message