[ 
https://issues.apache.org/jira/browse/HDFS-17853?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18038973#comment-18038973
 ] 

ASF GitHub Bot commented on HDFS-17853:
---------------------------------------

ayushtkn commented on code in PR #8064:
URL: https://github.com/apache/hadoop/pull/8064#discussion_r2535427559


##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeReconfigure.java:
##########
@@ -865,6 +866,35 @@ public void testReconfigureSlowPeerCollectInterval() 
throws Exception {
     assertEquals(600000, datanodeManager.getSlowPeerCollectionInterval());
   }
 
+  @Test
+  public void testReconfigureMaxDirItems() throws ReconfigurationException {
+    final NameNode nameNode = cluster.getNameNode();
+    final FSDirectory fsd = nameNode.namesystem.getFSDirectory();
+
+    // By default, DFS_NAMENODE_MAX_DIRECTORY_ITEMS_KEY is 1024 * 1024.
+    assertEquals(1024 * 1024, fsd.getMaxDirItems());
+
+    // Reconfigure.
+    nameNode.reconfigureProperty(DFS_NAMENODE_MAX_DIRECTORY_ITEMS_KEY,
+        Integer.toString(1024 * 1024 * 2));
+
+    // Assert DFS_NAMENODE_MAX_SLOWPEER_COLLECT_NODES_KEY is 1024 * 1024 * 2.
+    assertEquals(1024 * 1024 * 2, fsd.getMaxDirItems());
+
+    try {
+      // Reconfigure to negative, and expect failed.
+      nameNode.reconfigureProperty(DFS_NAMENODE_MAX_DIRECTORY_ITEMS_KEY,
+          Integer.toString(1024 * 1024 * -1));
+    } catch (ReconfigurationException e) {
+      assertEquals("Could not change property " +
+          "dfs.namenode.fs-limits.max-directory-items from '" + 1024 * 1024 * 2
+          + "' to '" + 1024 * 1024 * -1 + "'", e.getMessage());
+    }

Review Comment:
   use LamdaTestUtils
   ```
   
       LambdaTestUtils.intercept(ReconfigurationException.class,
           "Could not change property 
dfs.namenode.fs-limits.max-directory-items from '" + 1024 * 1024 * 2 + "' to '"
               + 1024 * 1024 * -1 + "'",
           () -> 
nameNode.reconfigureProperty(DFS_NAMENODE_MAX_DIRECTORY_ITEMS_KEY, 
Integer.toString(1024 * 1024 * -1)));
   ```





> Support to make dfs.namenode.fs-limits.max-directory-items reconfigurable
> -------------------------------------------------------------------------
>
>                 Key: HDFS-17853
>                 URL: https://issues.apache.org/jira/browse/HDFS-17853
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>          Components: namenode
>    Affects Versions: 3.5.0
>            Reporter: caozhiqiang
>            Assignee: caozhiqiang
>            Priority: Major
>              Labels: pull-request-available
>
> Sometimes, certain directories—such as temporary library directories—contain 
> too many subdirectories and files, exceeding the limit defined by the 
> {{dfs.namenode.fs-limits.max-directory-items}} configuration. This causes 
> many jobs to fail.
> To quickly restore job execution, we need to temporarily adjust this 
> configuration. However, since it currently requires to restart NameNode to 
> take effect, we need to make it dynamically reconfigurable without restarting 
> the NameNode.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to