HDFS-16324. Fix error log in BlockManagerSafeMode (#3661)

Reviewed-by: tomscut <litao@bigo.sg>
Reviewed-by: Ayush Saxena <ayushsaxena@apache.org>
Signed-off-by: Akira Ajisaka <aajisaka@apache.org>
This commit is contained in:
GuoPhilipse 2021-12-08 20:21:48 +08:00 committed by GitHub
parent 7ba91c1235
commit 00d483d6de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -649,7 +649,7 @@ class BlockManagerSafeMode {
DFSConfigKeys.DFS_NAMENODE_SAFEMODE_RECHECK_INTERVAL_DEFAULT);
if (recheckInterval < 1) {
LOG.warn("Invalid value for " +
DFSConfigKeys.DFS_NAMENODE_SAFEMODE_RECHECK_INTERVAL_DEFAULT +
DFSConfigKeys.DFS_NAMENODE_SAFEMODE_RECHECK_INTERVAL_KEY +
". Should be greater than 0, but is {}", recheckInterval);
recheckInterval = DFSConfigKeys.DFS_NAMENODE_SAFEMODE_RECHECK_INTERVAL_DEFAULT;
}

View File

@ -30,6 +30,7 @@ import org.apache.hadoop.hdfs.server.namenode.NameNode;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.test.Whitebox;
import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
@ -242,6 +243,20 @@ public class TestBlockManagerSafeMode {
assertTrue(content.contains("Using 3000 as SafeModeMonitor Interval"));
}
@Test(timeout = 20000)
public void testCheckSafeMode10(){
Configuration conf = new HdfsConfiguration();
conf.setLong(DFSConfigKeys.DFS_NAMENODE_SAFEMODE_RECHECK_INTERVAL_KEY, -1);
GenericTestUtils.LogCapturer logs =
GenericTestUtils.LogCapturer.captureLogs(BlockManagerSafeMode.LOG);
BlockManagerSafeMode blockManagerSafeMode = new BlockManagerSafeMode(bm,
fsn, true, conf);
String content = logs.getOutput();
Assertions.assertThat(content).contains("Invalid value for " +
DFSConfigKeys.DFS_NAMENODE_SAFEMODE_RECHECK_INTERVAL_KEY +
". Should be greater than 0, but is -1");
}
/**
* Test that the block safe increases up to block threshold.
*