[ https://issues.apache.org/jira/browse/HDFS-17292?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17798439#comment-17798439 ]
ASF GitHub Bot commented on HDFS-17292: --------------------------------------- slfan1989 commented on code in PR #6364: URL: https://github.com/apache/hadoop/pull/6364#discussion_r1430952283 ########## hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestReplicationPolicyExcludeSlowNodes.java: ########## @@ -176,4 +185,58 @@ public void testSlowPeerTrackerEnabledClearSlowNodes() throws Exception { } } + /** + * Dependent on the SlowNode related config, therefore placing + * 'testCollectSlowNodesIpAddrFrequencyMetrics' unit test in the + * TestReplicationPolicyExcludeSlowNodes class. + * <br> + * Test metrics associated with CollectSlowNodesIpAddrFrequency. + */ + @Test + public void testCollectSlowNodesIpAddrFrequencyMetrics() throws Exception { + namenode.getNamesystem().writeLock(); + try { + FSNamesystem fsNamesystem = namenode.getNamesystem(); + assertEquals("{}", fsNamesystem.getCollectSlowNodesIpAddrFrequencyMap(), "{}"); + MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); + ObjectName mxBeanName = new ObjectName("Hadoop:service=NameNode,name=FSNamesystemState"); + String ipAddrFrequency = + (String) mBeanServer.getAttribute(mxBeanName, "CollectSlowNodesIpAddrFrequencyMap"); + assertEquals("{}", ipAddrFrequency, "{}"); + + // add nodes + for (DatanodeDescriptor dataNode : dataNodes) { + dnManager.addDatanode(dataNode); + } + + // mock slow nodes + SlowPeerTracker tracker = dnManager.getSlowPeerTracker(); + Assert.assertNotNull(tracker); + OutlierMetrics outlierMetrics = new OutlierMetrics(0.0, 0.0, 0.0, 5.0); + tracker.addReport(dataNodes[0].getInfoAddr(), dataNodes[2].getInfoAddr(), outlierMetrics); + tracker.addReport(dataNodes[1].getInfoAddr(), dataNodes[2].getInfoAddr(), outlierMetrics); + + // waiting for slow nodes collector run and collect at least 2 times + Thread.sleep(3000); Review Comment: If we want to wait for a while, we use `GenericTestUtils.waitFor(..)` instead of `thread.sleep`. > Show the number of times the slowPeerCollectorDaemon thread has collected > SlowNodes. > ------------------------------------------------------------------------------------ > > Key: HDFS-17292 > URL: https://issues.apache.org/jira/browse/HDFS-17292 > Project: Hadoop HDFS > Issue Type: New Feature > Reporter: huangzhaobo99 > Assignee: huangzhaobo99 > Priority: Major > Labels: pull-request-available > -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org