goiri commented on code in PR #4946:
URL: https://github.com/apache/hadoop/pull/4946#discussion_r984943996
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java:
##########
@@ -1099,4 +1099,63 @@ private RMWebServices prepareWebServiceForValidation(
return webService;
}
+ @Test
+ public void testClusterSchedulerOverviewFifo() throws JSONException,
Exception {
+ WebResource r = resource();
+ ClientResponse response = r.path("ws").path("v1").path("cluster")
+ .path("scheduler-overview").accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+
+ assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
+ response.getType().toString());
+ JSONObject json = response.getEntity(JSONObject.class);
+ verifyClusterSchedulerFifoOverView(json);
+ System.out.println(json);
+ }
+
+ public void verifyClusterSchedulerFifoOverView(JSONObject json)
+ throws Exception {
+
+ // why json contains 8 elements because we defined 8 fields
+ assertEquals("incorrect number of elements in: " + json, 8, json.length());
+
+ // 1.Verify that the schedulerType is as expected
+ String schedulerType = json.getString("schedulerType");
+ Assert.assertEquals("Fifo Scheduler", schedulerType);
+ System.out.println(schedulerType);
+
+ // 2.Verify that schedulingResourceType is as expected
+ String schedulingResourceType = json.getString("schedulingResourceType");
+ Assert.assertEquals("memory-mb (unit=Mi),vcores", schedulingResourceType);
Review Comment:
You already have assertEquals statically, no need for Assert.
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java:
##########
@@ -1099,4 +1099,63 @@ private RMWebServices prepareWebServiceForValidation(
return webService;
}
+ @Test
+ public void testClusterSchedulerOverviewFifo() throws JSONException,
Exception {
+ WebResource r = resource();
+ ClientResponse response = r.path("ws").path("v1").path("cluster")
+ .path("scheduler-overview").accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+
+ assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
+ response.getType().toString());
+ JSONObject json = response.getEntity(JSONObject.class);
+ verifyClusterSchedulerFifoOverView(json);
+ System.out.println(json);
Review Comment:
Remove debugging
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/AboutBlock.java:
##########
@@ -18,78 +18,142 @@
package org.apache.hadoop.yarn.server.router.webapp;
-import com.sun.jersey.api.client.Client;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.util.StringUtils;
+import org.apache.hadoop.util.Time;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
-import org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts;
-import
org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ClusterMetricsInfo;
+import org.apache.hadoop.yarn.exceptions.YarnException;
+import org.apache.hadoop.yarn.server.federation.store.FederationStateStore;
+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.SubClusterRegisterRequest;
+import org.apache.hadoop.yarn.server.federation.store.records.SubClusterState;
+import
org.apache.hadoop.yarn.server.federation.utils.FederationStateStoreFacade;
import org.apache.hadoop.yarn.server.router.Router;
-import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
-import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
+import org.apache.hadoop.yarn.server.router.webapp.dao.RouterInfo;
import org.apache.hadoop.yarn.webapp.view.InfoBlock;
import com.google.inject.Inject;
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
/**
* About block for the Router Web UI.
*/
-public class AboutBlock extends HtmlBlock {
-
- private static final long BYTES_IN_MB = 1024 * 1024;
+public class AboutBlock extends RouterBlock {
private final Router router;
@Inject
AboutBlock(Router router, ViewContext ctx) {
- super(ctx);
+ super(router, ctx);
this.router = router;
}
@Override
protected void render(Block html) {
+
Configuration conf = this.router.getConfig();
- String webAppAddress = WebAppUtils.getRouterWebAppURLWithScheme(conf);
- Client client = RouterWebServiceUtil.createJerseyClient(conf);
-
- ClusterMetricsInfo metrics = RouterWebServiceUtil
- .genericForward(webAppAddress, null, ClusterMetricsInfo.class,
- HTTPMethods.GET,
- RMWSConsts.RM_WEB_SERVICE_PATH + RMWSConsts.METRICS, null, null,
- conf, client);
+ conf.setBoolean(YarnConfiguration.FEDERATION_ENABLED, true);
boolean isEnabled = conf.getBoolean(
YarnConfiguration.FEDERATION_ENABLED,
YarnConfiguration.DEFAULT_FEDERATION_ENABLED);
- info("Cluster Status").
- __("Federation Enabled", isEnabled).
- __("Applications Submitted", metrics.getAppsSubmitted()).
- __("Applications Pending", metrics.getAppsPending()).
- __("Applications Running", metrics.getAppsRunning()).
- __("Applications Failed", metrics.getAppsFailed()).
- __("Applications Killed", metrics.getAppsKilled()).
- __("Applications Completed", metrics.getAppsCompleted()).
- __("Containers Allocated", metrics.getContainersAllocated()).
- __("Containers Reserved", metrics.getReservedContainers()).
- __("Containers Pending", metrics.getPendingContainers()).
- __("Available Memory",
- StringUtils.byteDesc(metrics.getAvailableMB() * BYTES_IN_MB)).
- __("Allocated Memory",
- StringUtils.byteDesc(metrics.getAllocatedMB() * BYTES_IN_MB)).
- __("Reserved Memory",
- StringUtils.byteDesc(metrics.getReservedMB() * BYTES_IN_MB)).
- __("Total Memory",
- StringUtils.byteDesc(metrics.getTotalMB() * BYTES_IN_MB)).
- __("Available VirtualCores", metrics.getAvailableVirtualCores()).
- __("Allocated VirtualCores", metrics.getAllocatedVirtualCores()).
- __("Reserved VirtualCores", metrics.getReservedVirtualCores()).
- __("Total VirtualCores", metrics.getTotalVirtualCores()).
- __("Active Nodes", metrics.getActiveNodes()).
- __("Lost Nodes", metrics.getLostNodes()).
- __("Available Nodes", metrics.getDecommissionedNodes()).
- __("Unhealthy Nodes", metrics.getUnhealthyNodes()).
- __("Rebooted Nodes", metrics.getRebootedNodes()).
- __("Total Nodes", metrics.getTotalNodes());
+ FederationStateStoreFacade facade =
FederationStateStoreFacade.getInstance();
+ try {
+ initTestFederationSubCluster(facade);
+ } catch (IOException e) {
+ e.printStackTrace();
Review Comment:
Surface
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]