|
23 | 23 | import org.apache.hadoop.yarn.api.records.Resource; |
24 | 24 | import org.apache.hadoop.yarn.api.records.ResourceOption; |
25 | 25 | import org.apache.hadoop.yarn.exceptions.YarnException; |
26 | | -import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.*; |
| 26 | +import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ClusterInfo; |
| 27 | +import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ClusterUserInfo; |
| 28 | +import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ClusterMetricsInfo; |
| 29 | +import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.SchedulerTypeInfo; |
| 30 | +import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.FairSchedulerInfo; |
| 31 | +import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.FairSchedulerQueueInfo; |
| 32 | +import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodesInfo; |
| 33 | +import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeInfo; |
| 34 | +import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceOptionInfo; |
27 | 35 | import org.apache.hadoop.yarn.server.router.subcluster.TestFederationSubCluster; |
28 | 36 | import org.apache.hadoop.yarn.server.router.webapp.dao.FederationClusterInfo; |
29 | 37 | import org.apache.hadoop.yarn.server.router.webapp.dao.FederationClusterUserInfo; |
|
39 | 47 | import java.util.Set; |
40 | 48 | import java.util.concurrent.TimeoutException; |
41 | 49 |
|
42 | | -import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.*; |
| 50 | +import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.RM_WEB_SERVICE_PATH; |
| 51 | +import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.INFO; |
| 52 | +import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.CLUSTER_USER_INFO; |
| 53 | +import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.METRICS; |
| 54 | +import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.SCHEDULER; |
| 55 | +import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.NODES; |
| 56 | +import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.STATES; |
| 57 | +import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.NODES_NODEID; |
| 58 | +import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.NODE_RESOURCE; |
43 | 59 | import static org.apache.hadoop.yarn.server.router.subcluster.TestFederationSubCluster.format; |
44 | 60 | import static org.apache.hadoop.yarn.server.router.subcluster.TestFederationSubCluster.getNodeId; |
45 | 61 | import static org.apache.hadoop.yarn.server.router.webapp.HTTPMethods.POST; |
46 | | -import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode; |
47 | 62 | import static org.junit.Assert.assertNotNull; |
48 | 63 | import static org.junit.Assert.assertEquals; |
49 | 64 | import static org.junit.Assert.assertTrue; |
@@ -118,7 +133,8 @@ public void testClusterUserInfo() throws Exception { |
118 | 133 |
|
119 | 134 | @Test |
120 | 135 | public void testMetricsInfo() throws Exception { |
121 | | - // It takes time to start the sub-cluster. We need to wait for the sub-cluster to be completely started, |
| 136 | + // It takes time to start the sub-cluster. |
| 137 | + // We need to wait for the sub-cluster to be completely started, |
122 | 138 | // so we need to set the waiting time. |
123 | 139 | // The resources of the two sub-clusters we registered are 24C and 12G, |
124 | 140 | // so the resources that the Router should collect are 48C and 24G. |
@@ -220,5 +236,24 @@ public void testUpdateNodeResource() throws Exception { |
220 | 236 | NodeInfo.class, null, null); |
221 | 237 | assertEquals(4096, nodeInfo.getTotalResource().getMemorySize()); |
222 | 238 | assertEquals(8, nodeInfo.getTotalResource().getvCores()); |
| 239 | + |
| 240 | + Resource resource = Resource.newInstance(4096, 5); |
| 241 | + ResourceOptionInfo resourceOption = new ResourceOptionInfo( |
| 242 | + ResourceOption.newInstance(resource, 1000)); |
| 243 | + ClientResponse routerResponse = TestFederationSubCluster.performCall(ROUTER_WEB_ADDRESS, |
| 244 | + RM_WEB_SERVICE_PATH + format(NODE_RESOURCE, rm1NodeId), |
| 245 | + null, null, resourceOption, POST); |
| 246 | + JSONObject json = routerResponse.getEntity(JSONObject.class); |
| 247 | + JSONObject totalResource = json.getJSONObject("resourceInfo"); |
| 248 | + assertEquals(resource.getMemorySize(), totalResource.getLong("memory")); |
| 249 | + assertEquals(resource.getVirtualCores(), totalResource.getLong("vCores")); |
| 250 | + |
| 251 | + |
| 252 | + // assert updated memory and cores |
| 253 | + NodeInfo nodeInfo1 = TestFederationSubCluster.performGetCalls(ROUTER_WEB_ADDRESS, |
| 254 | + RM_WEB_SERVICE_PATH + format(NODES_NODEID, rm1NodeId), |
| 255 | + NodeInfo.class, null, null); |
| 256 | + assertEquals(4096, nodeInfo1.getTotalResource().getMemorySize()); |
| 257 | + assertEquals(5, nodeInfo1.getTotalResource().getvCores()); |
223 | 258 | } |
224 | 259 | } |
0 commit comments