zhuxiangyi commented on a change in pull request #3086:
URL: https://github.com/apache/hadoop/pull/3086#discussion_r657765228



##########
File path: 
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/metrics/TestRBFMetrics.java
##########
@@ -382,4 +366,56 @@ private void testCapacity(FederationMBean bean) throws 
IOException {
     assertNotEquals(availableCapacity,
         BigInteger.valueOf(bean.getRemainingCapacity()));
   }
+
+  @Test
+  public void testDatanodeNumMetrics()
+      throws Exception {
+    Configuration routerConf = new RouterConfigBuilder()
+        .metrics()
+        .http()
+        .stateStore()
+        .rpc()
+        .build();
+    MiniRouterDFSCluster cluster = new MiniRouterDFSCluster(false, 1);
+    cluster.setNumDatanodesPerNameservice(0);
+    cluster.addNamenodeOverrides(routerConf);
+    cluster.startCluster();
+    routerConf.setTimeDuration(
+        RBFConfigKeys.DN_REPORT_CACHE_EXPIRE, 10000, TimeUnit.SECONDS);
+    cluster.addRouterOverrides(routerConf);
+    cluster.startRouters();
+    Router router = cluster.getRandomRouter().getRouter();
+    // Register and verify all NNs with all routers
+    cluster.registerNamenodes();
+    cluster.waitNamenodeRegistration();
+    RouterRpcServer rpcServer = router.getRpcServer();
+    RBFMetrics rbfMetrics = router.getMetrics();
+    // Create mock dn
+    DatanodeInfo[] dNInfo = new DatanodeInfo[4];
+    DatanodeInfo datanodeInfo = new DatanodeInfo.DatanodeInfoBuilder().build();
+    datanodeInfo.setDecommissioned();
+    dNInfo[0] = datanodeInfo;
+    datanodeInfo = new DatanodeInfo.DatanodeInfoBuilder().build();
+    datanodeInfo.setInMaintenance();
+    dNInfo[1] = datanodeInfo;
+    datanodeInfo = new DatanodeInfo.DatanodeInfoBuilder().build();
+    datanodeInfo.startMaintenance();
+    dNInfo[2] = datanodeInfo;
+    datanodeInfo = new DatanodeInfo.DatanodeInfoBuilder().build();
+    datanodeInfo.startDecommission();
+    dNInfo[3] = datanodeInfo;
+
+    rpcServer.getDnCache().put(HdfsConstants.DatanodeReportType.LIVE, dNInfo);

Review comment:
       Thanks for your reminder.




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to