From 73a72e0ef97f166a4588506cd255f37eca769def Mon Sep 17 00:00:00 2001 From: Thomas Graves Date: Fri, 10 Feb 2012 14:30:00 +0000 Subject: [PATCH] MAPREDUCE-3680. FifoScheduler web service rest API can print out invalid JSON. (B Anil Kumar via tgraves) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1242790 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-mapreduce-project/CHANGES.txt | 7 +++++-- .../resourcemanager/scheduler/fifo/FifoScheduler.java | 7 ++++++- .../resourcemanager/scheduler/fifo/TestFifoScheduler.java | 8 ++++++++ .../server/resourcemanager/webapp/TestRMWebServices.java | 2 +- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index da0e8e10337..83811654e0b 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -98,8 +98,11 @@ Release 0.23.2 - UNRELEASED OPTIMIZATIONS BUG FIXES - MAPREDUCE-3840. JobEndNotifier doesn't use the proxyToUse during connecting - (Ravi Prakash via bobby) + MAPREDUCE-3680. FifoScheduler web service rest API can print out invalid + JSON. (B Anil Kumar via tgraves) + + MAPREDUCE-3840. JobEndNotifier doesn't use the proxyToUse during connecting + (Ravi Prakash via bobby) Release 0.23.1 - 2012-02-08 diff --git a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/FifoScheduler.java b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/FifoScheduler.java index 3d904f3a8c2..6fcf1fedd9d 100644 --- a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/FifoScheduler.java +++ b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/FifoScheduler.java @@ -148,7 +148,12 @@ public class FifoScheduler implements ResourceScheduler { QueueInfo queueInfo = recordFactory.newRecordInstance(QueueInfo.class); queueInfo.setQueueName(DEFAULT_QUEUE.getQueueName()); queueInfo.setCapacity(1.0f); - queueInfo.setCurrentCapacity((float)usedResource.getMemory() / clusterResource.getMemory()); + if (clusterResource.getMemory() == 0) { + queueInfo.setCurrentCapacity(0.0f); + } else { + queueInfo.setCurrentCapacity((float) usedResource.getMemory() + / clusterResource.getMemory()); + } queueInfo.setMaximumCapacity(1.0f); queueInfo.setChildQueues(new ArrayList()); queueInfo.setQueueState(QueueState.RUNNING); diff --git a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/TestFifoScheduler.java b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/TestFifoScheduler.java index a50d4c21700..88e6e63e17b 100644 --- a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/TestFifoScheduler.java +++ b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/TestFifoScheduler.java @@ -29,6 +29,7 @@ import org.apache.hadoop.net.NetworkTopology; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.Priority; +import org.apache.hadoop.yarn.api.records.QueueInfo; import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.event.AsyncDispatcher; import org.apache.hadoop.yarn.server.resourcemanager.Application; @@ -74,6 +75,13 @@ public class TestFifoScheduler { .getRMContext()); } + @Test + public void testFifoSchedulerCapacityWhenNoNMs() { + FifoScheduler scheduler = new FifoScheduler(); + QueueInfo queueInfo = scheduler.getQueueInfo(null, false, false); + Assert.assertEquals(0.0f, queueInfo.getCurrentCapacity()); + } + @Test public void testAppAttemptMetrics() throws Exception { AsyncDispatcher dispatcher = new InlineDispatcher(); diff --git a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java index fc73c0251a4..bf0df460ac9 100644 --- a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java +++ b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java @@ -539,7 +539,7 @@ public class TestRMWebServices extends JerseyTest { assertEquals("type doesn't match", "fifoScheduler", type); assertEquals("qstate doesn't match", QueueState.RUNNING.toString(), state); assertEquals("capacity doesn't match", 1.0, capacity, 0.0); - assertEquals("usedCapacity doesn't match", Float.NaN, usedCapacity, 0.0); + assertEquals("usedCapacity doesn't match", 0.0, usedCapacity, 0.0); assertEquals("minQueueMemoryCapacity doesn't match", 1024, minQueueCapacity); assertEquals("maxQueueMemoryCapacity doesn't match", 10240, maxQueueCapacity);