[
https://issues.apache.org/jira/browse/HDFS-15920?focusedWorklogId=576491&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-576491
]
ASF GitHub Bot logged work on HDFS-15920:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 03/Apr/21 21:15
Start Date: 03/Apr/21 21:15
Worklog Time Spent: 10m
Work Description: ayushtkn commented on a change in pull request #2831:
URL: https://github.com/apache/hadoop/pull/2831#discussion_r606710952
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManagerSafeMode.java
##########
@@ -640,7 +644,18 @@ private void reportStatus(String msg, boolean rightNow) {
*/
private class SafeModeMonitor implements Runnable {
/** Interval in msec for checking safe mode. */
- private static final long RECHECK_INTERVAL = 1000;
+ private long recheckInterval;
+
+ public SafeModeMonitor(Configuration conf) {
+ recheckInterval = conf.getLong(
+ DFS_NAMENODE_SAFEMODE_RECHECK_INTERVAL_KEY,
+ DFS_NAMENODE_SAFEMODE_RECHECK_INTERVAL_DEFAULT);
+ if (recheckInterval < 1) {
+ LOG.warn("The current value of recheckInterval is {}, " +
+ "this variable should be a positive number.", recheckInterval);
Review comment:
Can you change the message as ```"Invalid value for " +
DFS_NAMENODE_SAFEMODE_RECHECK_INTERVAL_KEY + ". Should be greater than 0, but
is {}", recheckInterval```
Please correct the syntax....
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManagerSafeMode.java
##########
@@ -640,7 +644,18 @@ private void reportStatus(String msg, boolean rightNow) {
*/
private class SafeModeMonitor implements Runnable {
/** Interval in msec for checking safe mode. */
- private static final long RECHECK_INTERVAL = 1000;
+ private long recheckInterval;
+
+ public SafeModeMonitor(Configuration conf) {
+ recheckInterval = conf.getLong(
+ DFS_NAMENODE_SAFEMODE_RECHECK_INTERVAL_KEY,
+ DFS_NAMENODE_SAFEMODE_RECHECK_INTERVAL_DEFAULT);
+ if (recheckInterval < 1) {
+ LOG.warn("The current value of recheckInterval is {}, " +
+ "this variable should be a positive number.", recheckInterval);
+ recheckInterval = DFS_NAMENODE_SAFEMODE_RECHECK_INTERVAL_DEFAULT;
+ }
Review comment:
Add a Log.info("Using {} as SafeModeMonitor Interval", recheckInterval)
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockManagerSafeMode.java
##########
@@ -230,6 +232,50 @@ public void testCheckSafeMode8() throws Exception {
assertEquals(BMSafeModeStatus.OFF, getSafeModeStatus());
}
+ @Test(timeout = 20000)
+ public void testCheckSafeMode9() throws Exception {
+ Configuration conf = new HdfsConfiguration();
+ try {
+ conf.setLong(DFS_NAMENODE_SAFEMODE_RECHECK_INTERVAL_KEY, 3000);
+ bm = spy(new BlockManager(fsn, false, conf));
+ doReturn(true).when(bm).isGenStampInFuture(any(Block.class));
+ dn = spy(bm.getDatanodeManager());
+ Whitebox.setInternalState(bm, "datanodeManager", dn);
+ // the datanode threshold is always met
+ when(dn.getNumLiveDataNodes()).thenReturn(DATANODE_NUM);
+ bmSafeMode = new BlockManagerSafeMode(bm, fsn, false, conf);
+ bmSafeMode.activate(BLOCK_TOTAL);
+ Whitebox.setInternalState(bmSafeMode, "extension", Integer.MAX_VALUE);
+ setSafeModeStatus(BMSafeModeStatus.PENDING_THRESHOLD);
+ setBlockSafe(BLOCK_THRESHOLD);
+ bmSafeMode.checkSafeMode();
+
+ assertTrue(bmSafeMode.isInSafeMode());
+ assertEquals(BMSafeModeStatus.EXTENSION, getSafeModeStatus());
+
+ GenericTestUtils.waitFor(new Supplier<Boolean>() {
+ @Override
+ public Boolean get() {
+ Whitebox.setInternalState(bmSafeMode, "extension", 0);
+ return getSafeModeStatus() != BMSafeModeStatus.EXTENSION;
+ }
+ }, EXTENSION / 10, EXTENSION * 10);
+
+ assertFalse(bmSafeMode.isInSafeMode());
+ assertEquals(BMSafeModeStatus.OFF, getSafeModeStatus());
+ } finally {
+ conf.setLong(DFS_NAMENODE_SAFEMODE_RECHECK_INTERVAL_KEY,
+ DFS_NAMENODE_SAFEMODE_RECHECK_INTERVAL_DEFAULT);
+ bm = spy(new BlockManager(fsn, false, conf));
+ doReturn(true).when(bm).isGenStampInFuture(any(Block.class));
+ dn = spy(bm.getDatanodeManager());
+ Whitebox.setInternalState(bm, "datanodeManager", dn);
+ // the datanode threshold is always met
+ when(dn.getNumLiveDataNodes()).thenReturn(DATANODE_NUM);
+ bmSafeMode = new BlockManagerSafeMode(bm, fsn, false, conf);
+ }
Review comment:
The tests have too many warnings due to deprecation. See if you can get
rid of them, If not, just do a assert on the log output, That it contains
``Using <value> as SafeModeMonitor Interval``
``GenericTestUtils`` has a ``LogCapturer`` you can use that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 576491)
Time Spent: 1h 20m (was: 1h 10m)
> Solve the problem that the value of SafeModeMonitor#RECHECK_INTERVAL can be
> configured
> --------------------------------------------------------------------------------------
>
> Key: HDFS-15920
> URL: https://issues.apache.org/jira/browse/HDFS-15920
> Project: Hadoop HDFS
> Issue Type: Improvement
> Reporter: JiangHua Zhu
> Assignee: JiangHua Zhu
> Priority: Major
> Labels: pull-request-available
> Time Spent: 1h 20m
> Remaining Estimate: 0h
>
> The current SafeModeMonitor#RECHECK_INTERVAL value has a fixed value (=1000),
> and this value should be set and configurable. Because the lock is occupied
> internally, it competes with other places.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]