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

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

View File

@ -379,6 +379,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

View File

@ -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);

View File

@ -66,6 +66,7 @@ class NodesPage extends RmView {
TBODY<TABLE<Hamlet>> 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<TBODY<TABLE<Hamlet>>> row = tbody.tr().
td(StringUtils.join(",", info.getNodeLabels())).
td(info.getRack()).
td(info.getState()).
td(info.getNodeId());

View File

@ -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<String> nodeLabels = new ArrayList<String>();
CapacitySchedulerQueueInfo() {
};
@ -75,6 +80,13 @@ public class CapacitySchedulerQueueInfo {
!((PlanQueue)q).showReservationsAsQueues()) {
hideReservationQueues = true;
}
// add labels
Set<String> 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<String> getNodeLabels() {
return this.nodeLabels;
}
}

View File

@ -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<String> nodeLabels = new ArrayList<String>();
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<String> 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<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
// 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;

View File

@ -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());