You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by we...@apache.org on 2019/11/19 20:23:22 UTC
[hadoop] branch branch-2 updated: HDFS-14952. Skip safemode if
blockTotal is 0 in new NN. Contributed by Xiaoqiao He.
This is an automated email from the ASF dual-hosted git repository.
weichiu pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-2 by this push:
new ae7469c HDFS-14952. Skip safemode if blockTotal is 0 in new NN. Contributed by Xiaoqiao He.
ae7469c is described below
commit ae7469cb67bb711fd95b89cde0d8c89ed93459b9
Author: He Xiaoqiao <he...@apache.org>
AuthorDate: Tue Nov 19 12:15:39 2019 -0800
HDFS-14952. Skip safemode if blockTotal is 0 in new NN. Contributed by Xiaoqiao He.
Signed-off-by: Wei-Chiu Chuang <we...@apache.org>
Reviewed-by: Mukul Kumar Singh <ms...@apache.org>
(cherry picked from commit 0b50aa29fd5dc114b3e0fc54b5c393bbc9f3102e)
(cherry picked from commit 1d383436f09f8e490171c8f6af4605971ad2f904)
(cherry picked from commit 7909c5df572a5cbc729ebc6c7c6e59f17803d50f)
---
.../hdfs/server/blockmanagement/BlockManagerSafeMode.java | 6 ++++--
.../hdfs/server/blockmanagement/TestBlockManagerSafeMode.java | 9 +++++++++
.../apache/hadoop/hdfs/server/namenode/ha/TestHASafeMode.java | 10 +++++++++-
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManagerSafeMode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManagerSafeMode.java
index 5271004..629a28a 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManagerSafeMode.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManagerSafeMode.java
@@ -208,7 +208,7 @@ class BlockManagerSafeMode {
switch (status) {
case PENDING_THRESHOLD:
if (areThresholdsMet()) {
- if (extension > 0) {
+ if (blockTotal > 0 && extension > 0) {
// PENDING_THRESHOLD -> EXTENSION
status = BMSafeModeStatus.EXTENSION;
reachedTime.set(monotonicNow());
@@ -507,11 +507,13 @@ class BlockManagerSafeMode {
/**
* Get time (counting in milliseconds) left to leave extension period.
+ * It should leave safemode at once if blockTotal = 0 rather than wait
+ * extension time (30s by default).
*
* Negative value indicates the extension period has passed.
*/
private long timeToLeaveExtension() {
- return reachedTime.get() + extension - monotonicNow();
+ return blockTotal > 0 ? reachedTime.get() + extension - monotonicNow() : 0;
}
/**
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockManagerSafeMode.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockManagerSafeMode.java
index eb58f5c..d150277 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockManagerSafeMode.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockManagerSafeMode.java
@@ -221,6 +221,15 @@ public class TestBlockManagerSafeMode {
}, 100, 10000);
}
+ @Test
+ public void testCheckSafeMode8() throws Exception {
+ bmSafeMode.activate(0);
+ setBlockSafe(0);
+ setSafeModeStatus(BMSafeModeStatus.PENDING_THRESHOLD);
+ bmSafeMode.checkSafeMode();
+ assertEquals(BMSafeModeStatus.OFF, getSafeModeStatus());
+ }
+
/**
* Test that the block safe increases up to block threshold.
*
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHASafeMode.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHASafeMode.java
index 6e7bd15..0fc0a55 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHASafeMode.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHASafeMode.java
@@ -492,7 +492,15 @@ public class TestHASafeMode {
private static void assertSafeMode(NameNode nn, int safe, int total,
int numNodes, int nodeThresh) {
String status = nn.getNamesystem().getSafemode();
- if (safe == total) {
+ if (total == 0 && nodeThresh == 0) {
+ assertTrue("Bad safemode status: '" + status + "'",
+ status.isEmpty()
+ || status.startsWith("Safe mode is ON. The reported blocks 0 " +
+ "has reached the threshold 0.9990 of total blocks 0. The " +
+ "minimum number of live datanodes is not required. In safe " +
+ "mode extension. Safe mode will be turned off automatically " +
+ "in 0 seconds."));
+ } else if (safe == total) {
if (nodeThresh == 0) {
assertTrue("Bad safemode status: '" + status + "'",
status.startsWith("Safe mode is ON. The reported blocks " + safe
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org