Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EDA4018DA3 for ; Mon, 21 Mar 2016 20:14:25 +0000 (UTC) Received: (qmail 39716 invoked by uid 500); 21 Mar 2016 20:14:17 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 38124 invoked by uid 500); 21 Mar 2016 20:14:16 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 36273 invoked by uid 99); 21 Mar 2016 20:14:15 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Mar 2016 20:14:15 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2823DDFF96; Mon, 21 Mar 2016 20:14:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: wangda@apache.org To: common-commits@hadoop.apache.org Date: Mon, 21 Mar 2016 20:14:46 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [33/50] [abbrv] hadoop git commit: YARN-4785. inconsistent value type of the type field for LeafQueueInfo in response of RM REST API. YARN-4785. inconsistent value type of the type field for LeafQueueInfo in response of RM REST API. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/ca8106d2 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/ca8106d2 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/ca8106d2 Branch: refs/heads/YARN-3368 Commit: ca8106d2dd03458944303d93679daa03b1d82ad5 Parents: f84af8b Author: Junping Du Authored: Thu Mar 17 09:04:41 2016 -0700 Committer: Junping Du Committed: Thu Mar 17 09:04:41 2016 -0700 ---------------------------------------------------------------------- .../webapp/dao/CapacitySchedulerInfo.java | 26 +++++++++++++++++--- .../webapp/TestRMWebServicesCapacitySched.java | 3 +++ 2 files changed, 25 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/ca8106d2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerInfo.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/webapp/dao/CapacitySchedulerInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerInfo.java index f6332c1..32e4ac5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerInfo.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerInfo.java @@ -28,6 +28,9 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.LeafQueue; +import java.util.ArrayList; +import java.util.List; + @XmlRootElement(name = "capacityScheduler") @XmlType(name = "capacityScheduler") @XmlAccessorType(XmlAccessType.FIELD) @@ -86,14 +89,29 @@ public class CapacitySchedulerInfo extends SchedulerInfo { } protected CapacitySchedulerQueueInfoList getQueues(CSQueue parent) { - CSQueue parentQueue = parent; CapacitySchedulerQueueInfoList queuesInfo = new CapacitySchedulerQueueInfoList(); - for (CSQueue queue : parentQueue.getChildQueues()) { + // JAXB marashalling leads to situation where the "type" field injected + // for JSON changes from string to array depending on order of printing + // Issue gets fixed if all the leaf queues are marshalled before the + // non-leaf queues. See YARN-4785 for more details. + List childQueues = new ArrayList<>(); + List childLeafQueues = new ArrayList<>(); + List childNonLeafQueues = new ArrayList<>(); + for (CSQueue queue : parent.getChildQueues()) { + if (queue instanceof LeafQueue) { + childLeafQueues.add(queue); + } else { + childNonLeafQueues.add(queue); + } + } + childQueues.addAll(childLeafQueues); + childQueues.addAll(childNonLeafQueues); + + for (CSQueue queue : childQueues) { CapacitySchedulerQueueInfo info; if (queue instanceof LeafQueue) { - info = - new CapacitySchedulerLeafQueueInfo((LeafQueue) queue); + info = new CapacitySchedulerLeafQueueInfo((LeafQueue) queue); } else { info = new CapacitySchedulerQueueInfo(queue); info.queues = getQueues(queue); http://git-wip-us.apache.org/repos/asf/hadoop/blob/ca8106d2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.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/webapp/TestRMWebServicesCapacitySched.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java index 28b1c4f..12f0c8b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java @@ -43,6 +43,7 @@ import org.apache.hadoop.yarn.webapp.WebServicesTestUtils; import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.w3c.dom.Document; @@ -379,6 +380,8 @@ public class TestRMWebServicesCapacitySched extends JerseyTestBase { verifySubQueue(obj, q2, qi.absoluteCapacity, qi.absoluteMaxCapacity); } } else { + Assert.assertEquals("\"type\" field is incorrect", + "capacitySchedulerLeafQueueInfo", info.getString("type")); LeafQueueInfo lqi = (LeafQueueInfo) qi; lqi.numActiveApplications = info.getInt("numActiveApplications"); lqi.numPendingApplications = info.getInt("numPendingApplications");