HDFS-11095. BlockManagerSafeMode should respect extension period default config value (30s). Contributed by Mingliang Liu
(cherry picked from commit 9b0c17f852
)
This commit is contained in:
parent
b818773919
commit
7a662bea89
|
@ -35,12 +35,16 @@ import org.apache.hadoop.hdfs.server.namenode.startupprogress.StepType;
|
||||||
import org.apache.hadoop.net.NetworkTopology;
|
import org.apache.hadoop.net.NetworkTopology;
|
||||||
import org.apache.hadoop.util.Daemon;
|
import org.apache.hadoop.util.Daemon;
|
||||||
|
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
|
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||||
|
|
||||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_REPL_QUEUE_THRESHOLD_PCT_KEY;
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_REPL_QUEUE_THRESHOLD_PCT_KEY;
|
||||||
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SAFEMODE_EXTENSION_DEFAULT;
|
||||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SAFEMODE_EXTENSION_KEY;
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SAFEMODE_EXTENSION_KEY;
|
||||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SAFEMODE_MIN_DATANODES_DEFAULT;
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SAFEMODE_MIN_DATANODES_DEFAULT;
|
||||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SAFEMODE_MIN_DATANODES_KEY;
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SAFEMODE_MIN_DATANODES_KEY;
|
||||||
|
@ -96,7 +100,8 @@ class BlockManagerSafeMode {
|
||||||
private long blockReplQueueThreshold;
|
private long blockReplQueueThreshold;
|
||||||
|
|
||||||
/** How long (in ms) is the extension period. */
|
/** How long (in ms) is the extension period. */
|
||||||
private final int extension;
|
@VisibleForTesting
|
||||||
|
final long extension;
|
||||||
/** Timestamp of the first time when thresholds are met. */
|
/** Timestamp of the first time when thresholds are met. */
|
||||||
private final AtomicLong reachedTime = new AtomicLong();
|
private final AtomicLong reachedTime = new AtomicLong();
|
||||||
/** Timestamp of the safe mode initialized. */
|
/** Timestamp of the safe mode initialized. */
|
||||||
|
@ -143,7 +148,9 @@ class BlockManagerSafeMode {
|
||||||
this.replQueueThreshold =
|
this.replQueueThreshold =
|
||||||
conf.getFloat(DFS_NAMENODE_REPL_QUEUE_THRESHOLD_PCT_KEY,
|
conf.getFloat(DFS_NAMENODE_REPL_QUEUE_THRESHOLD_PCT_KEY,
|
||||||
(float) threshold);
|
(float) threshold);
|
||||||
this.extension = conf.getInt(DFS_NAMENODE_SAFEMODE_EXTENSION_KEY, 0);
|
this.extension = conf.getTimeDuration(DFS_NAMENODE_SAFEMODE_EXTENSION_KEY,
|
||||||
|
DFS_NAMENODE_SAFEMODE_EXTENSION_DEFAULT,
|
||||||
|
MILLISECONDS);
|
||||||
|
|
||||||
this.inRollBack = isInRollBackMode(NameNode.getStartupOption(conf));
|
this.inRollBack = isInRollBackMode(NameNode.getStartupOption(conf));
|
||||||
|
|
||||||
|
|
|
@ -823,8 +823,9 @@
|
||||||
<name>dfs.namenode.safemode.extension</name>
|
<name>dfs.namenode.safemode.extension</name>
|
||||||
<value>30000</value>
|
<value>30000</value>
|
||||||
<description>
|
<description>
|
||||||
Determines extension of safe mode in milliseconds
|
Determines extension of safe mode in milliseconds after the threshold level
|
||||||
after the threshold level is reached.
|
is reached. Support multiple time unit suffix (case insensitive), as
|
||||||
|
described in dfs.heartbeat.interval.
|
||||||
</description>
|
</description>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ import java.io.IOException;
|
||||||
import java.io.InterruptedIOException;
|
import java.io.InterruptedIOException;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SAFEMODE_EXTENSION_DEFAULT;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
@ -386,6 +387,25 @@ public class TestBlockManagerSafeMode {
|
||||||
"are cleared.", bmSafeMode.leaveSafeMode(false));
|
"are cleared.", bmSafeMode.leaveSafeMode(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(timeout = 10000)
|
||||||
|
public void testExtensionConfig() {
|
||||||
|
final Configuration conf = new HdfsConfiguration();
|
||||||
|
bmSafeMode = new BlockManagerSafeMode(bm, fsn, false, conf);
|
||||||
|
assertEquals(DFS_NAMENODE_SAFEMODE_EXTENSION_DEFAULT, bmSafeMode.extension);
|
||||||
|
|
||||||
|
conf.set(DFSConfigKeys.DFS_NAMENODE_SAFEMODE_EXTENSION_KEY, "30000");
|
||||||
|
bmSafeMode = new BlockManagerSafeMode(bm, fsn, false, conf);
|
||||||
|
assertEquals(30000, bmSafeMode.extension);
|
||||||
|
|
||||||
|
conf.set(DFSConfigKeys.DFS_NAMENODE_SAFEMODE_EXTENSION_KEY, "20s");
|
||||||
|
bmSafeMode = new BlockManagerSafeMode(bm, fsn, false, conf);
|
||||||
|
assertEquals(20 * 1000, bmSafeMode.extension);
|
||||||
|
|
||||||
|
conf.set(DFSConfigKeys.DFS_NAMENODE_SAFEMODE_EXTENSION_KEY, "7m");
|
||||||
|
bmSafeMode = new BlockManagerSafeMode(bm, fsn, false, conf);
|
||||||
|
assertEquals(7 * 60 * 1000, bmSafeMode.extension);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test get safe mode tip.
|
* Test get safe mode tip.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue