Skip to content

Commit 405e7f3

Browse files
committed
Fix testAllDatanodesReconfig UT failed
1 parent a3007b0 commit 405e7f3

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private static INodeDirectory createRoot(FSNamesystem namesystem) {
159159
private final FSNamesystem namesystem;
160160
private volatile boolean skipQuotaCheck = false; //skip while consuming edits
161161
private final int maxComponentLength;
162-
private int maxDirItems;
162+
private volatile int maxDirItems;
163163
private final int lsLimit; // max list limit
164164
private final int contentCountLimit; // max content summary counts per run
165165
private final long contentSleepMicroSec;
@@ -217,7 +217,7 @@ private static INodeDirectory createRoot(FSNamesystem namesystem) {
217217
// authorizeWithContext() API or not.
218218
private boolean useAuthorizationWithContextAPI = false;
219219

220-
private final int MAX_DIR_ITEMS = 64 * 100 * 1000;
220+
private static final int maxDirItemsLimit = 64 * 100 * 1000;
221221

222222
public void setINodeAttributeProvider(
223223
@Nullable INodeAttributeProvider provider) {
@@ -401,9 +401,9 @@ public enum DirOp {
401401
// to 64MB. This means we can only store approximately 6.7 million entries
402402
// per directory, but let's use 6.4 million for some safety.
403403
Preconditions.checkArgument(
404-
maxDirItems > 0 && maxDirItems <= MAX_DIR_ITEMS, "Cannot set "
404+
maxDirItems > 0 && maxDirItems <= maxDirItemsLimit, "Cannot set "
405405
+ DFSConfigKeys.DFS_NAMENODE_MAX_DIRECTORY_ITEMS_KEY
406-
+ " to a value less than 1 or greater than " + MAX_DIR_ITEMS);
406+
+ " to a value less than 1 or greater than " + maxDirItemsLimit);
407407

408408
int threshold = conf.getInt(
409409
DFSConfigKeys.DFS_NAMENODE_NAME_CACHE_THRESHOLD_KEY,
@@ -583,9 +583,9 @@ String setProtectedDirectories(String protectedDirsString) {
583583

584584
public void setMaxDirItems(int newVal) {
585585
com.google.common.base.Preconditions.checkArgument(
586-
newVal > 0 && newVal <= MAX_DIR_ITEMS, "Cannot set "
586+
newVal > 0 && newVal <= maxDirItemsLimit, "Cannot set "
587587
+ DFSConfigKeys.DFS_NAMENODE_MAX_DIRECTORY_ITEMS_KEY
588-
+ " to a value less than 1 or greater than " + MAX_DIR_ITEMS);
588+
+ " to a value less than 1 or greater than " + maxDirItemsLimit);
589589
maxDirItems = newVal;
590590
}
591591

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSAdmin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,7 @@ public void testAllDatanodesReconfig()
12521252
any(Configuration.class))).thenReturn(changes);
12531253

12541254
int result = admin.startReconfiguration("datanode", "livenodes");
1255+
Thread.sleep(1000);
12551256
assertThat(result).isEqualTo(0);
12561257
final List<String> outsForStartReconf = new ArrayList<>();
12571258
final List<String> errsForStartReconf = new ArrayList<>();

0 commit comments

Comments
 (0)