YARN-2503. Added node lablels in web UI. Contributed by Wangda Tan

(cherry picked from commit d5e0a09721)
(cherry picked from commit 720de7eb4c)
This commit is contained in:
Jian He 2014-10-28 17:57:54 -07:00
parent c0b17bf104
commit e181498a67
7 changed files with 40 additions and 4 deletions

View File

@ -343,6 +343,8 @@ Release 2.6.0 - UNRELEASED
YARN-2760. Remove 'experimental' from FairScheduler docs. (Harsh J via kasha) YARN-2760. Remove 'experimental' from FairScheduler docs. (Harsh J via kasha)
YARN-2503. Added node lablels in web UI. (Wangda Tan via jianhe)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES

View File

@ -120,7 +120,8 @@ class CapacitySchedulerPage extends RmView {
_("Configured Max Capacity:", percent(lqinfo.getMaxCapacity() / 100)). _("Configured Max Capacity:", percent(lqinfo.getMaxCapacity() / 100)).
_("Configured Minimum User Limit Percent:", Integer.toString(lqinfo.getUserLimit()) + "%"). _("Configured Minimum User Limit Percent:", Integer.toString(lqinfo.getUserLimit()) + "%").
_("Configured User Limit Factor:", String.format("%.1f", lqinfo.getUserLimitFactor())). _("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); html._(InfoBlock.class);

View File

@ -66,6 +66,7 @@ class NodesPage extends RmView {
TBODY<TABLE<Hamlet>> tbody = html.table("#nodes"). TBODY<TABLE<Hamlet>> tbody = html.table("#nodes").
thead(). thead().
tr(). tr().
th(".nodelabels", "Node Labels").
th(".rack", "Rack"). th(".rack", "Rack").
th(".state", "Node State"). th(".state", "Node State").
th(".nodeaddress", "Node Address"). th(".nodeaddress", "Node Address").
@ -113,6 +114,7 @@ class NodesPage extends RmView {
int usedMemory = (int)info.getUsedMemory(); int usedMemory = (int)info.getUsedMemory();
int availableMemory = (int)info.getAvailableMemory(); int availableMemory = (int)info.getAvailableMemory();
TR<TBODY<TABLE<Hamlet>>> row = tbody.tr(). TR<TBODY<TABLE<Hamlet>>> row = tbody.tr().
td(StringUtils.join(",", info.getNodeLabels())).
td(info.getRack()). td(info.getRack()).
td(info.getState()). td(info.getState()).
td(info.getNodeId()); td(info.getNodeId());

View File

@ -17,6 +17,10 @@
*/ */
package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao; 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.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@ -50,6 +54,7 @@ public class CapacitySchedulerQueueInfo {
protected CapacitySchedulerQueueInfoList queues; protected CapacitySchedulerQueueInfoList queues;
protected ResourceInfo resourcesUsed; protected ResourceInfo resourcesUsed;
private boolean hideReservationQueues = false; private boolean hideReservationQueues = false;
protected ArrayList<String> nodeLabels = new ArrayList<String>();
CapacitySchedulerQueueInfo() { CapacitySchedulerQueueInfo() {
}; };
@ -75,6 +80,13 @@ public class CapacitySchedulerQueueInfo {
!((PlanQueue)q).showReservationsAsQueues()) { !((PlanQueue)q).showReservationsAsQueues()) {
hideReservationQueues = true; hideReservationQueues = true;
} }
// add labels
Set<String> labelSet = q.getAccessibleNodeLabels();
if (labelSet != null) {
nodeLabels.addAll(labelSet);
Collections.sort(nodeLabels);
}
} }
public float getCapacity() { public float getCapacity() {
@ -138,4 +150,8 @@ public class CapacitySchedulerQueueInfo {
static float cap(float val, float low, float hi) { static float cap(float val, float low, float hi) {
return Math.min(Math.max(val, low), hi); return Math.min(Math.max(val, low), hi);
} }
public ArrayList<String> getNodeLabels() {
return this.nodeLabels;
}
} }

View File

@ -18,6 +18,10 @@
package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao; 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.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@ -45,6 +49,7 @@ public class NodeInfo {
protected long availMemoryMB; protected long availMemoryMB;
protected long usedVirtualCores; protected long usedVirtualCores;
protected long availableVirtualCores; protected long availableVirtualCores;
protected ArrayList<String> nodeLabels = new ArrayList<String>();
public NodeInfo() { public NodeInfo() {
} // JAXB needs this } // JAXB needs this
@ -70,6 +75,13 @@ public class NodeInfo {
this.lastHealthUpdate = ni.getLastHealthReportTime(); this.lastHealthUpdate = ni.getLastHealthReportTime();
this.healthReport = String.valueOf(ni.getHealthReport()); this.healthReport = String.valueOf(ni.getHealthReport());
this.version = ni.getNodeManagerVersion(); this.version = ni.getNodeManagerVersion();
// add labels
Set<String> labelSet = ni.getNodeLabels();
if (labelSet != null) {
nodeLabels.addAll(labelSet);
Collections.sort(nodeLabels);
}
} }
public String getRack() { public String getRack() {
@ -124,4 +136,7 @@ public class NodeInfo {
return this.availableVirtualCores; return this.availableVirtualCores;
} }
public ArrayList<String> getNodeLabels() {
return this.nodeLabels;
}
} }

View File

@ -49,7 +49,7 @@ public class TestNodesPage {
// Number of Actual Table Headers for NodesPage.NodesBlock might change in // Number of Actual Table Headers for NodesPage.NodesBlock might change in
// future. In that case this value should be adjusted to the new value. // future. In that case this value should be adjusted to the new value.
final int numberOfThInMetricsTable = 16; final int numberOfThInMetricsTable = 16;
final int numberOfActualTableHeaders = 12; final int numberOfActualTableHeaders = 13;
private Injector injector; private Injector injector;

View File

@ -357,10 +357,10 @@ public class TestRMWebServicesCapacitySched extends JerseyTest {
private void verifySubQueue(JSONObject info, String q, private void verifySubQueue(JSONObject info, String q,
float parentAbsCapacity, float parentAbsMaxCapacity) float parentAbsCapacity, float parentAbsMaxCapacity)
throws JSONException, Exception { throws JSONException, Exception {
int numExpectedElements = 12; int numExpectedElements = 13;
boolean isParentQueue = true; boolean isParentQueue = true;
if (!info.has("queues")) { if (!info.has("queues")) {
numExpectedElements = 22; numExpectedElements = 23;
isParentQueue = false; isParentQueue = false;
} }
assertEquals("incorrect number of elements", numExpectedElements, info.length()); assertEquals("incorrect number of elements", numExpectedElements, info.length());