HDFS-17368. HA: Standby should exit safemode when resources are available. (#6518). Contributed by Zilong Zhu.
Signed-off-by: He Xiaoqiao <hexiaoqiao@apache.org>
This commit is contained in:
parent
8bc4939ee2
commit
37f9ccdc86
@ -1578,6 +1578,10 @@ void startStandbyServices(final Configuration conf, boolean isObserver)
|
|||||||
standbyCheckpointer = new StandbyCheckpointer(conf, this);
|
standbyCheckpointer = new StandbyCheckpointer(conf, this);
|
||||||
standbyCheckpointer.start();
|
standbyCheckpointer.start();
|
||||||
}
|
}
|
||||||
|
if (isNoManualAndResourceLowSafeMode()) {
|
||||||
|
LOG.info("Standby should not enter safe mode when resources are low, exiting safe mode.");
|
||||||
|
leaveSafeMode(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -5253,10 +5257,9 @@ String getSafeModeTip() {
|
|||||||
String cmd = "Use \"hdfs dfsadmin -safemode leave\" to turn safe mode off.";
|
String cmd = "Use \"hdfs dfsadmin -safemode leave\" to turn safe mode off.";
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (resourceLowSafeMode) {
|
if (resourceLowSafeMode) {
|
||||||
return "Resources are low on NN. Please add or free up more resources"
|
return "Resources are low on NN. Please add or free up more resources. "
|
||||||
+ "then turn off safe mode manually. NOTE: If you turn off safe "
|
+ "NOTE: If you turn off safe mode before adding resources, the "
|
||||||
+ "mode before adding resources, the NN will immediately return to "
|
+ "NN will immediately return to safe mode. ";
|
||||||
+ "safe mode. " + cmd;
|
|
||||||
} else if (manualSafeMode) {
|
} else if (manualSafeMode) {
|
||||||
return "It was turned on manually. " + cmd;
|
return "It was turned on manually. " + cmd;
|
||||||
}
|
}
|
||||||
|
@ -999,4 +999,11 @@ public void testTransitionToObserverWhenSafeMode() throws Exception {
|
|||||||
() -> miniCluster.transitionToObserver(0));
|
() -> miniCluster.transitionToObserver(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTransitionToStandbyWhenSafeModeWithResourcesLow() throws Exception {
|
||||||
|
NameNodeAdapter.enterSafeMode(nn0, true);
|
||||||
|
cluster.transitionToStandby(0);
|
||||||
|
assertFalse("SNN should not enter safe mode when resources low", nn0.isInSafeMode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user