YARN-11583. Improve Node Link for YARN Federation Web Page. (#6145) Contributed by Shilun Fan.
Reviewed-by: Inigo Goiri <inigoiri@apache.org> Signed-off-by: Shilun Fan <slfan1989@apache.org>
This commit is contained in:
parent
ee1ebbe5f9
commit
42b32fbbdc
@ -160,13 +160,19 @@ private void initFederationClusterNodesMetrics(Hamlet.DIV<Hamlet> div,
|
|||||||
// Initialize table data information
|
// Initialize table data information
|
||||||
tbody().$class("ui-widget-content").
|
tbody().$class("ui-widget-content").
|
||||||
tr().
|
tr().
|
||||||
td(String.valueOf(metrics.getActiveNodes())).
|
td().a(url("nodes"), String.valueOf(metrics.getActiveNodes())).__().
|
||||||
td(String.valueOf(metrics.getDecommissioningNodes())).
|
td().a(url("nodes/router/?node.state=decommissioning"),
|
||||||
td(String.valueOf(metrics.getDecommissionedNodes())).
|
String.valueOf(metrics.getDecommissioningNodes())).__().
|
||||||
td(String.valueOf(metrics.getLostNodes())).
|
td().a(url("nodes/router/?node.state=decommissioned"),
|
||||||
td(String.valueOf(metrics.getUnhealthyNodes())).
|
String.valueOf(metrics.getDecommissionedNodes())).__().
|
||||||
td(String.valueOf(metrics.getRebootedNodes())).
|
td().a(url("nodes/router/?node.state=lost"),
|
||||||
td(String.valueOf(metrics.getShutdownNodes())).
|
String.valueOf(metrics.getLostNodes())).__().
|
||||||
|
td().a(url("nodes/router/?node.state=unhealthy"),
|
||||||
|
String.valueOf(metrics.getUnhealthyNodes())).__().
|
||||||
|
td().a(url("nodes/router/?node.state=rebooted"),
|
||||||
|
String.valueOf(metrics.getRebootedNodes())).__().
|
||||||
|
td().a(url("nodes/router/?node.state=shutdown"),
|
||||||
|
String.valueOf(metrics.getShutdownNodes())).__().
|
||||||
__().
|
__().
|
||||||
__().__();
|
__().__();
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.PartitionInfo;
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.PartitionInfo;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceInfo;
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceInfo;
|
||||||
import org.apache.hadoop.yarn.server.router.Router;
|
import org.apache.hadoop.yarn.server.router.Router;
|
||||||
|
import org.apache.hadoop.yarn.webapp.YarnWebParams;
|
||||||
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
|
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
|
||||||
import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
|
import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
|
||||||
|
|
||||||
@ -158,6 +159,14 @@ private void initYarnFederationNodeLabelsOfCluster(NodeLabelsInfo nodeLabelsInfo
|
|||||||
String type = (info.getExclusivity()) ? "Exclusive Partition" : "Non Exclusive Partition";
|
String type = (info.getExclusivity()) ? "Exclusive Partition" : "Non Exclusive Partition";
|
||||||
row = row.td(type);
|
row = row.td(type);
|
||||||
int nActiveNMs = info.getActiveNMs();
|
int nActiveNMs = info.getActiveNMs();
|
||||||
|
if (nActiveNMs > 0) {
|
||||||
|
row = row.td().a(url("nodes",
|
||||||
|
"?" + YarnWebParams.NODE_LABEL + "=" + info.getName()), String.valueOf(nActiveNMs))
|
||||||
|
.__();
|
||||||
|
} else {
|
||||||
|
row = row.td(String.valueOf(nActiveNMs));
|
||||||
|
}
|
||||||
|
|
||||||
row = row.td(String.valueOf(nActiveNMs));
|
row = row.td(String.valueOf(nActiveNMs));
|
||||||
PartitionInfo partitionInfo = info.getPartitionInfo();
|
PartitionInfo partitionInfo = info.getPartitionInfo();
|
||||||
ResourceInfo available = partitionInfo.getResourceAvailable();
|
ResourceInfo available = partitionInfo.getResourceAvailable();
|
||||||
|
@ -21,7 +21,9 @@
|
|||||||
import org.apache.hadoop.yarn.webapp.SubView;
|
import org.apache.hadoop.yarn.webapp.SubView;
|
||||||
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
|
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
|
||||||
|
|
||||||
|
import static org.apache.hadoop.yarn.server.router.webapp.RouterWebServiceUtil.generateWebTitle;
|
||||||
import static org.apache.hadoop.yarn.webapp.YarnWebParams.NODE_SC;
|
import static org.apache.hadoop.yarn.webapp.YarnWebParams.NODE_SC;
|
||||||
|
import static org.apache.hadoop.yarn.webapp.YarnWebParams.NODE_LABEL;
|
||||||
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES_ID;
|
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES_ID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,10 +35,15 @@ public class NodeLabelsPage extends RouterView {
|
|||||||
protected void preHead(Hamlet.HTML<__> html) {
|
protected void preHead(Hamlet.HTML<__> html) {
|
||||||
commonPreHead(html);
|
commonPreHead(html);
|
||||||
String type = $(NODE_SC);
|
String type = $(NODE_SC);
|
||||||
|
String nodeLabel = $(NODE_LABEL);
|
||||||
String title = "Node labels of the cluster";
|
String title = "Node labels of the cluster";
|
||||||
if (type != null && !type.isEmpty()) {
|
|
||||||
title = title + " (" + type + ")";
|
if (nodeLabel != null && !nodeLabel.isEmpty()) {
|
||||||
|
title = generateWebTitle(title, nodeLabel);
|
||||||
|
} else if (type != null && !type.isEmpty()) {
|
||||||
|
title = generateWebTitle(title, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
setTitle(title);
|
setTitle(title);
|
||||||
set(DATATABLES_ID, "nodelabels");
|
set(DATATABLES_ID, "nodelabels");
|
||||||
setTableStyles(html, "nodelabels", ".healthStatus {width:10em}", ".healthReport {width:10em}");
|
setTableStyles(html, "nodelabels", ".healthStatus {width:10em}", ".healthReport {width:10em}");
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterId;
|
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterId;
|
||||||
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterInfo;
|
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterInfo;
|
||||||
import org.apache.hadoop.yarn.server.federation.utils.FederationStateStoreFacade;
|
import org.apache.hadoop.yarn.server.federation.utils.FederationStateStoreFacade;
|
||||||
|
import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts;
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeInfo;
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeInfo;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodesInfo;
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodesInfo;
|
||||||
@ -40,6 +41,8 @@
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import static org.apache.hadoop.yarn.webapp.YarnWebParams.NODE_SC;
|
import static org.apache.hadoop.yarn.webapp.YarnWebParams.NODE_SC;
|
||||||
|
import static org.apache.hadoop.yarn.webapp.YarnWebParams.NODE_LABEL;
|
||||||
|
import static org.apache.hadoop.yarn.webapp.YarnWebParams.NODE_STATE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nodes block for the Router Web UI.
|
* Nodes block for the Router Web UI.
|
||||||
@ -61,12 +64,15 @@ protected void render(Block html) {
|
|||||||
|
|
||||||
// Get subClusterName
|
// Get subClusterName
|
||||||
String subClusterName = $(NODE_SC);
|
String subClusterName = $(NODE_SC);
|
||||||
|
String state = $(NODE_STATE);
|
||||||
|
String nodeLabel = $(NODE_LABEL);
|
||||||
|
|
||||||
// We will try to get the subClusterName.
|
// We will try to get the subClusterName.
|
||||||
// If the subClusterName is not empty,
|
// If the subClusterName is not empty,
|
||||||
// it means that we need to get the Node list of a subCluster.
|
// it means that we need to get the Node list of a subCluster.
|
||||||
NodesInfo nodesInfo;
|
NodesInfo nodesInfo;
|
||||||
if (subClusterName != null && !subClusterName.isEmpty()) {
|
if (subClusterName != null && !subClusterName.isEmpty() &&
|
||||||
|
!ROUTER.equalsIgnoreCase(subClusterName)) {
|
||||||
initSubClusterMetricsOverviewTable(html, subClusterName);
|
initSubClusterMetricsOverviewTable(html, subClusterName);
|
||||||
nodesInfo = getSubClusterNodesInfo(subClusterName);
|
nodesInfo = getSubClusterNodesInfo(subClusterName);
|
||||||
} else {
|
} else {
|
||||||
@ -76,7 +82,7 @@ protected void render(Block html) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize NodeInfo List
|
// Initialize NodeInfo List
|
||||||
initYarnFederationNodesOfCluster(nodesInfo, html);
|
initYarnFederationNodesOfCluster(nodesInfo, html, state, nodeLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private NodesInfo getYarnFederationNodesInfo(boolean isEnabled) {
|
private NodesInfo getYarnFederationNodesInfo(boolean isEnabled) {
|
||||||
@ -100,7 +106,7 @@ private NodesInfo getSubClusterNodesInfo(String subCluster) {
|
|||||||
if (subClusterInfo != null) {
|
if (subClusterInfo != null) {
|
||||||
// Prepare webAddress
|
// Prepare webAddress
|
||||||
String webAddress = subClusterInfo.getRMWebServiceAddress();
|
String webAddress = subClusterInfo.getRMWebServiceAddress();
|
||||||
String herfWebAppAddress = "";
|
String herfWebAppAddress;
|
||||||
if (webAddress != null && !webAddress.isEmpty()) {
|
if (webAddress != null && !webAddress.isEmpty()) {
|
||||||
herfWebAppAddress =
|
herfWebAppAddress =
|
||||||
WebAppUtils.getHttpSchemePrefix(this.router.getConfig()) + webAddress;
|
WebAppUtils.getHttpSchemePrefix(this.router.getConfig()) + webAddress;
|
||||||
@ -124,7 +130,8 @@ private NodesInfo getSubClusterNodesInfoByWebAddress(String webAddress) {
|
|||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initYarnFederationNodesOfCluster(NodesInfo nodesInfo, Block html) {
|
private void initYarnFederationNodesOfCluster(NodesInfo nodesInfo, Block html,
|
||||||
|
String filterState, String filterLabel) {
|
||||||
TBODY<TABLE<Hamlet>> tbody = html.table("#nodes").thead().tr()
|
TBODY<TABLE<Hamlet>> tbody = html.table("#nodes").thead().tr()
|
||||||
.th(".nodelabels", "Node Labels")
|
.th(".nodelabels", "Node Labels")
|
||||||
.th(".rack", "Rack")
|
.th(".rack", "Rack")
|
||||||
@ -143,6 +150,23 @@ private void initYarnFederationNodesOfCluster(NodesInfo nodesInfo, Block html) {
|
|||||||
|
|
||||||
if (nodesInfo != null && CollectionUtils.isNotEmpty(nodesInfo.getNodes())) {
|
if (nodesInfo != null && CollectionUtils.isNotEmpty(nodesInfo.getNodes())) {
|
||||||
for (NodeInfo info : nodesInfo.getNodes()) {
|
for (NodeInfo info : nodesInfo.getNodes()) {
|
||||||
|
if (filterState != null && !filterState.isEmpty() && !filterState.equals(info.getState())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Besides state, we need to filter label as well.
|
||||||
|
if (!filterLabel.equals(RMNodeLabelsManager.ANY)) {
|
||||||
|
if (filterLabel.isEmpty()) {
|
||||||
|
// Empty label filter means only shows nodes without label
|
||||||
|
if (!info.getNodeLabels().isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else if (!info.getNodeLabels().contains(filterLabel)) {
|
||||||
|
// Only nodes have given label can show on web page.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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();
|
||||||
|
@ -18,7 +18,9 @@
|
|||||||
|
|
||||||
package org.apache.hadoop.yarn.server.router.webapp;
|
package org.apache.hadoop.yarn.server.router.webapp;
|
||||||
|
|
||||||
|
import static org.apache.hadoop.yarn.server.router.webapp.RouterWebServiceUtil.generateWebTitle;
|
||||||
import static org.apache.hadoop.yarn.webapp.YarnWebParams.NODE_SC;
|
import static org.apache.hadoop.yarn.webapp.YarnWebParams.NODE_SC;
|
||||||
|
import static org.apache.hadoop.yarn.webapp.YarnWebParams.NODE_STATE;
|
||||||
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES;
|
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES;
|
||||||
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES_ID;
|
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES_ID;
|
||||||
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.initID;
|
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.initID;
|
||||||
@ -32,9 +34,12 @@ class NodesPage extends RouterView {
|
|||||||
protected void preHead(Page.HTML<__> html) {
|
protected void preHead(Page.HTML<__> html) {
|
||||||
commonPreHead(html);
|
commonPreHead(html);
|
||||||
String type = $(NODE_SC);
|
String type = $(NODE_SC);
|
||||||
|
String state = $(NODE_STATE);
|
||||||
String title = "Nodes of the cluster";
|
String title = "Nodes of the cluster";
|
||||||
if (type != null && !type.isEmpty()) {
|
if (state != null && !state.isEmpty()) {
|
||||||
title = title + " (" + type + ")";
|
title = generateWebTitle(title, state);
|
||||||
|
} else if (type != null && !type.isEmpty()) {
|
||||||
|
title = generateWebTitle(title, type);
|
||||||
}
|
}
|
||||||
setTitle(title);
|
setTitle(title);
|
||||||
set(DATATABLES_ID, "nodes");
|
set(DATATABLES_ID, "nodes");
|
||||||
|
@ -55,6 +55,8 @@ public abstract class RouterBlock extends HtmlBlock {
|
|||||||
private final FederationStateStoreFacade facade;
|
private final FederationStateStoreFacade facade;
|
||||||
private final Configuration conf;
|
private final Configuration conf;
|
||||||
|
|
||||||
|
public static final String ROUTER = "router";
|
||||||
|
|
||||||
public RouterBlock(Router router, ViewContext ctx) {
|
public RouterBlock(Router router, ViewContext ctx) {
|
||||||
super(ctx);
|
super(ctx);
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
|
@ -764,4 +764,13 @@ public static UserGroupInformation getKerberosUserGroupInformation(Configuration
|
|||||||
// return caller UGI
|
// return caller UGI
|
||||||
return callerUGI;
|
return callerUGI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String generateWebTitle(String title, String msg) {
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
stringBuilder.append(title);
|
||||||
|
stringBuilder.append(" (");
|
||||||
|
stringBuilder.append(msg);
|
||||||
|
stringBuilder.append(")");
|
||||||
|
return stringBuilder.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -334,7 +334,7 @@ public RESTRequestInterceptor run() throws Exception {
|
|||||||
|
|
||||||
Assert.assertNotNull(client1.interceptor);
|
Assert.assertNotNull(client1.interceptor);
|
||||||
Assert.assertNotNull(client2.interceptor);
|
Assert.assertNotNull(client2.interceptor);
|
||||||
Assert.assertTrue(client1.interceptor == client2.interceptor);
|
Assert.assertSame(client1.interceptor, client2.interceptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user