diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt
index cd702b76318..bbf10ad741d 100644
--- a/hadoop-yarn-project/CHANGES.txt
+++ b/hadoop-yarn-project/CHANGES.txt
@@ -343,6 +343,8 @@ Release 2.6.0 - UNRELEASED
YARN-2760. Remove 'experimental' from FairScheduler docs. (Harsh J via kasha)
+ YARN-2503. Added node lablels in web UI. (Wangda Tan via jianhe)
+
OPTIMIZATIONS
BUG FIXES
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/CapacitySchedulerPage.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/CapacitySchedulerPage.java
index a53ad9847e8..d289f66d1a8 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/CapacitySchedulerPage.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/CapacitySchedulerPage.java
@@ -120,7 +120,8 @@ class CapacitySchedulerPage extends RmView {
_("Configured Max Capacity:", percent(lqinfo.getMaxCapacity() / 100)).
_("Configured Minimum User Limit Percent:", Integer.toString(lqinfo.getUserLimit()) + "%").
_("Configured User Limit Factor:", String.format("%.1f", lqinfo.getUserLimitFactor())).
- _r("Active users: ", activeUserList.toString());
+ _("Active Users: ", activeUserList.toString()).
+ _r("Accessible Node Labels:", StringUtils.join(",", lqinfo.getNodeLabels()));
html._(InfoBlock.class);
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/NodesPage.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/NodesPage.java
index f10e255938a..270d91544d5 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/NodesPage.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/NodesPage.java
@@ -66,6 +66,7 @@ class NodesPage extends RmView {
TBODY
> tbody = html.table("#nodes").
thead().
tr().
+ th(".nodelabels", "Node Labels").
th(".rack", "Rack").
th(".state", "Node State").
th(".nodeaddress", "Node Address").
@@ -113,6 +114,7 @@ class NodesPage extends RmView {
int usedMemory = (int)info.getUsedMemory();
int availableMemory = (int)info.getAvailableMemory();
TR>> row = tbody.tr().
+ td(StringUtils.join(",", info.getNodeLabels())).
td(info.getRack()).
td(info.getState()).
td(info.getNodeId());
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/CapacitySchedulerQueueInfo.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/CapacitySchedulerQueueInfo.java
index d5c84d8dbc4..40dddea2b9f 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/CapacitySchedulerQueueInfo.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/CapacitySchedulerQueueInfo.java
@@ -17,6 +17,10 @@
*/
package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Set;
+
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
@@ -50,6 +54,7 @@ public class CapacitySchedulerQueueInfo {
protected CapacitySchedulerQueueInfoList queues;
protected ResourceInfo resourcesUsed;
private boolean hideReservationQueues = false;
+ protected ArrayList nodeLabels = new ArrayList();
CapacitySchedulerQueueInfo() {
};
@@ -75,6 +80,13 @@ public class CapacitySchedulerQueueInfo {
!((PlanQueue)q).showReservationsAsQueues()) {
hideReservationQueues = true;
}
+
+ // add labels
+ Set labelSet = q.getAccessibleNodeLabels();
+ if (labelSet != null) {
+ nodeLabels.addAll(labelSet);
+ Collections.sort(nodeLabels);
+ }
}
public float getCapacity() {
@@ -138,4 +150,8 @@ public class CapacitySchedulerQueueInfo {
static float cap(float val, float low, float hi) {
return Math.min(Math.max(val, low), hi);
}
+
+ public ArrayList getNodeLabels() {
+ return this.nodeLabels;
+ }
}
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/NodeInfo.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/NodeInfo.java
index 73a2db17242..3104117b0c2 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/NodeInfo.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/NodeInfo.java
@@ -18,6 +18,10 @@
package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Set;
+
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
@@ -45,6 +49,7 @@ public class NodeInfo {
protected long availMemoryMB;
protected long usedVirtualCores;
protected long availableVirtualCores;
+ protected ArrayList nodeLabels = new ArrayList();
public NodeInfo() {
} // JAXB needs this
@@ -70,6 +75,13 @@ public class NodeInfo {
this.lastHealthUpdate = ni.getLastHealthReportTime();
this.healthReport = String.valueOf(ni.getHealthReport());
this.version = ni.getNodeManagerVersion();
+
+ // add labels
+ Set labelSet = ni.getNodeLabels();
+ if (labelSet != null) {
+ nodeLabels.addAll(labelSet);
+ Collections.sort(nodeLabels);
+ }
}
public String getRack() {
@@ -124,4 +136,7 @@ public class NodeInfo {
return this.availableVirtualCores;
}
+ public ArrayList getNodeLabels() {
+ return this.nodeLabels;
+ }
}
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/TestNodesPage.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestNodesPage.java
index 09743114a9d..bb38079ccea 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestNodesPage.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestNodesPage.java
@@ -49,7 +49,7 @@ public class TestNodesPage {
// Number of Actual Table Headers for NodesPage.NodesBlock might change in
// future. In that case this value should be adjusted to the new value.
final int numberOfThInMetricsTable = 16;
- final int numberOfActualTableHeaders = 12;
+ final int numberOfActualTableHeaders = 13;
private Injector injector;
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 e58c30fb122..3e62c3cb126 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
@@ -357,10 +357,10 @@ public class TestRMWebServicesCapacitySched extends JerseyTest {
private void verifySubQueue(JSONObject info, String q,
float parentAbsCapacity, float parentAbsMaxCapacity)
throws JSONException, Exception {
- int numExpectedElements = 12;
+ int numExpectedElements = 13;
boolean isParentQueue = true;
if (!info.has("queues")) {
- numExpectedElements = 22;
+ numExpectedElements = 23;
isParentQueue = false;
}
assertEquals("incorrect number of elements", numExpectedElements, info.length());