HDFS-14952. Skip safemode if blockTotal is 0 in new NN. Contributed by Xiaoqiao He.
Signed-off-by: Wei-Chiu Chuang <weichiu@apache.org> Reviewed-by: Mukul Kumar Singh <msingh@apache.org>
This commit is contained in:
parent
dfdc6d6dd9
commit
0b50aa29fd
@ -210,7 +210,7 @@ void checkSafeMode() {
|
||||
switch (status) {
|
||||
case PENDING_THRESHOLD:
|
||||
if (areThresholdsMet()) {
|
||||
if (extension > 0) {
|
||||
if (blockTotal > 0 && extension > 0) {
|
||||
// PENDING_THRESHOLD -> EXTENSION
|
||||
status = BMSafeModeStatus.EXTENSION;
|
||||
reachedTime.set(monotonicNow());
|
||||
@ -532,11 +532,13 @@ void close() {
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -221,6 +221,15 @@ public Boolean get() {
|
||||
}, 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.
|
||||
*
|
||||
|
@ -497,7 +497,15 @@ public void testBlocksDeletedInEditLog() throws Exception {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user