YARN-11368. [Federation] Improve Yarn Router's Federation Page style. (#5105)
This commit is contained in:
parent
44b8bb7224
commit
845cf8bc28
@ -28,7 +28,7 @@ $(document).ready(function() {
|
|||||||
var capabilityArr = scTableData.filter(item => (item.subcluster === row.id()));
|
var capabilityArr = scTableData.filter(item => (item.subcluster === row.id()));
|
||||||
var capabilityObj = JSON.parse(capabilityArr[0].capability).clusterMetrics;
|
var capabilityObj = JSON.parse(capabilityArr[0].capability).clusterMetrics;
|
||||||
row.child(
|
row.child(
|
||||||
'<table>' +
|
'<table style="line-height:25px;" >' +
|
||||||
' <tr>' +
|
' <tr>' +
|
||||||
' <td>' +
|
' <td>' +
|
||||||
' <h3>Application Metrics</h3>' +
|
' <h3>Application Metrics</h3>' +
|
||||||
@ -42,11 +42,12 @@ $(document).ready(function() {
|
|||||||
' <td>' +
|
' <td>' +
|
||||||
' <h3>Resource Metrics</h3>' +
|
' <h3>Resource Metrics</h3>' +
|
||||||
' <h4>Memory</h4>' +
|
' <h4>Memory</h4>' +
|
||||||
' TotalMB : ' + capabilityObj.totalMB + ' </p>' +
|
' Total Memory : ' + capabilityArr[0].totalmemory + ' </p>' +
|
||||||
' ReservedMB : ' + capabilityObj.reservedMB + ' </p>' +
|
' Reserved Memory : ' + capabilityArr[0].reservedmemory + ' </p>' +
|
||||||
' AvailableMB : ' + capabilityObj.availableMB + ' </p>' +
|
' Available Memory : ' + capabilityArr[0].availablememory + ' </p>' +
|
||||||
' AllocatedMB : ' + capabilityObj.allocatedMB + ' </p>' +
|
' Allocated Memory : ' + capabilityArr[0].allocatedmemory + ' </p>' +
|
||||||
' PendingMB : ' + capabilityObj.pendingMB + ' </p>' +
|
' Pending Memory : ' + capabilityArr[0].pendingmemory + ' </p>' +
|
||||||
|
' <hr />' +
|
||||||
' <h4>VirtualCores</h4>' +
|
' <h4>VirtualCores</h4>' +
|
||||||
' TotalVirtualCores : ' + capabilityObj.totalVirtualCores + ' </p>' +
|
' TotalVirtualCores : ' + capabilityObj.totalVirtualCores + ' </p>' +
|
||||||
' ReservedVirtualCores : ' + capabilityObj.reservedVirtualCores + ' </p>' +
|
' ReservedVirtualCores : ' + capabilityObj.reservedVirtualCores + ' </p>' +
|
||||||
|
@ -23,12 +23,13 @@
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import org.apache.hadoop.util.StringUtils;
|
import org.apache.hadoop.util.StringUtils;
|
||||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
||||||
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.store.records.SubClusterState;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ClusterMetricsInfo;
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ClusterMetricsInfo;
|
||||||
import org.apache.hadoop.yarn.server.router.Router;
|
import org.apache.hadoop.yarn.server.router.Router;
|
||||||
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
|
import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
|
||||||
@ -149,32 +150,51 @@ private void initHtmlPageFederation(Block html, boolean isEnabled) {
|
|||||||
ClusterMetricsInfo subClusterInfo = getClusterMetricsInfo(capability);
|
ClusterMetricsInfo subClusterInfo = getClusterMetricsInfo(capability);
|
||||||
|
|
||||||
// Prepare LastStartTime & LastHeartBeat
|
// Prepare LastStartTime & LastHeartBeat
|
||||||
String lastStartTime =
|
Date lastStartTime = new Date(subcluster.getLastStartTime());
|
||||||
DateFormatUtils.format(subcluster.getLastStartTime(), DATE_PATTERN);
|
Date lastHeartBeat = new Date(subcluster.getLastHeartBeat());
|
||||||
String lastHeartBeat =
|
|
||||||
DateFormatUtils.format(subcluster.getLastHeartBeat(), DATE_PATTERN);
|
|
||||||
|
|
||||||
// Prepare Resource
|
// Prepare Resource
|
||||||
long totalMB = subClusterInfo.getTotalMB();
|
long totalMB = subClusterInfo.getTotalMB();
|
||||||
String totalMBDesc = StringUtils.byteDesc(totalMB * BYTES_IN_MB);
|
String totalMBDesc = StringUtils.byteDesc(totalMB * BYTES_IN_MB);
|
||||||
long totalVirtualCores = subClusterInfo.getTotalVirtualCores();
|
long totalVirtualCores = subClusterInfo.getTotalVirtualCores();
|
||||||
String resources = String.format("<Memory:%s, VCore:%s>", totalMBDesc, totalVirtualCores);
|
String resources = String.format("<memory:%s, vCores:%s>", totalMBDesc, totalVirtualCores);
|
||||||
|
|
||||||
// Prepare Node
|
// Prepare Node
|
||||||
long totalNodes = subClusterInfo.getTotalNodes();
|
long totalNodes = subClusterInfo.getTotalNodes();
|
||||||
long activeNodes = subClusterInfo.getActiveNodes();
|
long activeNodes = subClusterInfo.getActiveNodes();
|
||||||
String nodes = String.format("<Total Nodes:%s, Active Nodes:%s>", totalNodes, activeNodes);
|
String nodes = String.format("<totalNodes:%s, activeNodes:%s>", totalNodes, activeNodes);
|
||||||
|
|
||||||
// Prepare HTML Table
|
// Prepare HTML Table
|
||||||
|
String stateStyle = "color:#dc3545;font-weight:bolder";
|
||||||
|
SubClusterState state = subcluster.getState();
|
||||||
|
if (SubClusterState.SC_RUNNING == state) {
|
||||||
|
stateStyle = "color:#28a745;font-weight:bolder";
|
||||||
|
}
|
||||||
|
|
||||||
tbody.tr().$id(subClusterIdText)
|
tbody.tr().$id(subClusterIdText)
|
||||||
.td().$class("details-control").a(herfWebAppAddress, subClusterIdText).__()
|
.td().$class("details-control").a(herfWebAppAddress, subClusterIdText).__()
|
||||||
.td(subcluster.getState().name())
|
.td().$style(stateStyle).__(state.name()).__()
|
||||||
.td(lastStartTime)
|
.td().__(lastStartTime).__()
|
||||||
.td(lastHeartBeat)
|
.td().__(lastHeartBeat).__()
|
||||||
.td(resources)
|
.td(resources)
|
||||||
.td(nodes)
|
.td(nodes)
|
||||||
.__();
|
.__();
|
||||||
|
|
||||||
|
// Formatted memory information
|
||||||
|
long allocatedMB = subClusterInfo.getAllocatedMB();
|
||||||
|
String allocatedMBDesc = StringUtils.byteDesc(allocatedMB * BYTES_IN_MB);
|
||||||
|
long availableMB = subClusterInfo.getAvailableMB();
|
||||||
|
String availableMBDesc = StringUtils.byteDesc(availableMB * BYTES_IN_MB);
|
||||||
|
long pendingMB = subClusterInfo.getPendingMB();
|
||||||
|
String pendingMBDesc = StringUtils.byteDesc(pendingMB * BYTES_IN_MB);
|
||||||
|
long reservedMB = subClusterInfo.getReservedMB();
|
||||||
|
String reservedMBDesc = StringUtils.byteDesc(reservedMB * BYTES_IN_MB);
|
||||||
|
|
||||||
|
subclusterMap.put("totalmemory", totalMBDesc);
|
||||||
|
subclusterMap.put("allocatedmemory", allocatedMBDesc);
|
||||||
|
subclusterMap.put("availablememory", availableMBDesc);
|
||||||
|
subclusterMap.put("pendingmemory", pendingMBDesc);
|
||||||
|
subclusterMap.put("reservedmemory", reservedMBDesc);
|
||||||
subclusterMap.put("subcluster", subClusterId.getId());
|
subclusterMap.put("subcluster", subClusterId.getId());
|
||||||
subclusterMap.put("capability", capability);
|
subclusterMap.put("capability", capability);
|
||||||
lists.add(subclusterMap);
|
lists.add(subclusterMap);
|
||||||
|
@ -23,14 +23,20 @@
|
|||||||
import org.apache.hadoop.yarn.server.router.Router;
|
import org.apache.hadoop.yarn.server.router.Router;
|
||||||
import org.apache.hadoop.yarn.webapp.test.WebAppTests;
|
import org.apache.hadoop.yarn.webapp.test.WebAppTests;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class TestFederationWebApp extends TestRouterWebServicesREST {
|
public class TestFederationWebApp extends TestRouterWebServicesREST {
|
||||||
|
|
||||||
|
private static final Logger LOG =
|
||||||
|
LoggerFactory.getLogger(TestFederationWebApp.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFederationWebViewNotEnable()
|
public void testFederationWebViewNotEnable()
|
||||||
throws InterruptedException, YarnException, IOException {
|
throws InterruptedException, YarnException, IOException {
|
||||||
|
LOG.info("testFederationWebView - NotEnable Federation.");
|
||||||
// Test Federation is not Enabled
|
// Test Federation is not Enabled
|
||||||
Configuration config = new YarnConfiguration();
|
Configuration config = new YarnConfiguration();
|
||||||
config.setBoolean(YarnConfiguration.FEDERATION_ENABLED, false);
|
config.setBoolean(YarnConfiguration.FEDERATION_ENABLED, false);
|
||||||
@ -40,6 +46,7 @@ public void testFederationWebViewNotEnable()
|
|||||||
@Test
|
@Test
|
||||||
public void testFederationWebViewEnable()
|
public void testFederationWebViewEnable()
|
||||||
throws InterruptedException, YarnException, IOException {
|
throws InterruptedException, YarnException, IOException {
|
||||||
|
LOG.info("testFederationWebView - Enable Federation.");
|
||||||
// Test Federation Enabled
|
// Test Federation Enabled
|
||||||
Configuration config = new YarnConfiguration();
|
Configuration config = new YarnConfiguration();
|
||||||
config.setBoolean(YarnConfiguration.FEDERATION_ENABLED, true);
|
config.setBoolean(YarnConfiguration.FEDERATION_ENABLED, true);
|
||||||
@ -49,6 +56,7 @@ public void testFederationWebViewEnable()
|
|||||||
@Test
|
@Test
|
||||||
public void testFederationAboutViewEnable()
|
public void testFederationAboutViewEnable()
|
||||||
throws InterruptedException, YarnException, IOException {
|
throws InterruptedException, YarnException, IOException {
|
||||||
|
LOG.info("testFederationAboutViewEnable - Enable Federation.");
|
||||||
// Test Federation Enabled
|
// Test Federation Enabled
|
||||||
Configuration config = new YarnConfiguration();
|
Configuration config = new YarnConfiguration();
|
||||||
config.setBoolean(YarnConfiguration.FEDERATION_ENABLED, true);
|
config.setBoolean(YarnConfiguration.FEDERATION_ENABLED, true);
|
||||||
@ -58,6 +66,7 @@ public void testFederationAboutViewEnable()
|
|||||||
@Test
|
@Test
|
||||||
public void testFederationAboutViewNotEnable()
|
public void testFederationAboutViewNotEnable()
|
||||||
throws InterruptedException, YarnException, IOException {
|
throws InterruptedException, YarnException, IOException {
|
||||||
|
LOG.info("testFederationAboutViewNotEnable - NotEnable Federation.");
|
||||||
// Test Federation Not Enabled
|
// Test Federation Not Enabled
|
||||||
Configuration config = new YarnConfiguration();
|
Configuration config = new YarnConfiguration();
|
||||||
config.setBoolean(YarnConfiguration.FEDERATION_ENABLED, false);
|
config.setBoolean(YarnConfiguration.FEDERATION_ENABLED, false);
|
||||||
@ -67,6 +76,7 @@ public void testFederationAboutViewNotEnable()
|
|||||||
@Test
|
@Test
|
||||||
public void testFederationNodeViewEnable()
|
public void testFederationNodeViewEnable()
|
||||||
throws InterruptedException, YarnException, IOException {
|
throws InterruptedException, YarnException, IOException {
|
||||||
|
LOG.info("testFederationNodeViewEnable - Enable Federation.");
|
||||||
// Test Federation Enabled
|
// Test Federation Enabled
|
||||||
Configuration config = new YarnConfiguration();
|
Configuration config = new YarnConfiguration();
|
||||||
config.setBoolean(YarnConfiguration.FEDERATION_ENABLED, true);
|
config.setBoolean(YarnConfiguration.FEDERATION_ENABLED, true);
|
||||||
@ -76,6 +86,7 @@ public void testFederationNodeViewEnable()
|
|||||||
@Test
|
@Test
|
||||||
public void testFederationNodeViewNotEnable()
|
public void testFederationNodeViewNotEnable()
|
||||||
throws InterruptedException, YarnException, IOException {
|
throws InterruptedException, YarnException, IOException {
|
||||||
|
LOG.info("testFederationNodeViewNotEnable - NotEnable Federation.");
|
||||||
// Test Federation Not Enabled
|
// Test Federation Not Enabled
|
||||||
Configuration config = new YarnConfiguration();
|
Configuration config = new YarnConfiguration();
|
||||||
config.setBoolean(YarnConfiguration.FEDERATION_ENABLED, false);
|
config.setBoolean(YarnConfiguration.FEDERATION_ENABLED, false);
|
||||||
@ -85,6 +96,7 @@ public void testFederationNodeViewNotEnable()
|
|||||||
@Test
|
@Test
|
||||||
public void testFederationAppViewEnable()
|
public void testFederationAppViewEnable()
|
||||||
throws InterruptedException, YarnException, IOException {
|
throws InterruptedException, YarnException, IOException {
|
||||||
|
LOG.info("testFederationAppViewEnable - Enable Federation.");
|
||||||
// Test Federation Enabled
|
// Test Federation Enabled
|
||||||
Configuration config = new YarnConfiguration();
|
Configuration config = new YarnConfiguration();
|
||||||
config.setBoolean(YarnConfiguration.FEDERATION_ENABLED, true);
|
config.setBoolean(YarnConfiguration.FEDERATION_ENABLED, true);
|
||||||
@ -94,6 +106,7 @@ public void testFederationAppViewEnable()
|
|||||||
@Test
|
@Test
|
||||||
public void testFederationAppViewNotEnable()
|
public void testFederationAppViewNotEnable()
|
||||||
throws InterruptedException, YarnException, IOException {
|
throws InterruptedException, YarnException, IOException {
|
||||||
|
LOG.info("testFederationAppViewNotEnable - NotEnable Federation.");
|
||||||
// Test Federation Not Enabled
|
// Test Federation Not Enabled
|
||||||
Configuration config = new YarnConfiguration();
|
Configuration config = new YarnConfiguration();
|
||||||
config.setBoolean(YarnConfiguration.FEDERATION_ENABLED, false);
|
config.setBoolean(YarnConfiguration.FEDERATION_ENABLED, false);
|
||||||
|
Loading…
Reference in New Issue
Block a user