[ https://issues.apache.org/jira/browse/HDFS-17546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17854576#comment-17854576 ]
ASF GitHub Bot commented on HDFS-17546: --------------------------------------- simbadzina commented on code in PR #6873: URL: https://github.com/apache/hadoop/pull/6873#discussion_r1637279944 ########## hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/util/TestCombinedHostsFileReader.java: ########## @@ -87,4 +103,51 @@ public void testEmptyCombinedHostsFileReader() throws Exception { CombinedHostsFileReader.readFile(newFile.getAbsolutePath()); assertEquals(0, all.length); } + + /* + * When timeout is enabled, test for success when reading file within timeout + * limits + */ + @Test + public void testReadFileWithTimeoutSuccess() throws Exception { + + DatanodeAdminProperties[] all = CombinedHostsFileReader.readFileWithTimeout( + jsonFile.getAbsolutePath(), 1000); + assertEquals(7, all.length); + } + + /* + * When timeout is enabled, test for IOException when reading file exceeds + * timeout limits + */ + @Test + public void testReadFileWithTimeoutTimeoutException() throws Exception { + exception.expect(IOException.class); Review Comment: You can just use `@Test(expected = IOException.class)` here since we don't check any other properties of the exception. Then you can remove the Rule declaration above and the new imports. > Implementing Timeout for HostFileReader when FS hangs > ----------------------------------------------------- > > Key: HDFS-17546 > URL: https://issues.apache.org/jira/browse/HDFS-17546 > Project: Hadoop HDFS > Issue Type: Improvement > Components: namenode > Reporter: Simbarashe Dzinamarira > Assignee: Simbarashe Dzinamarira > Priority: Minor > Labels: pull-request-available > > Certain implementations of Hadoop have the dfs.hosts file residing on NAS/NFS > and potentially with symlinks. If the FS hangs for any reason, the > refreshNodes call would infinitely hang on the HostsFileReader until the FS > returns. -- 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