HDFS-14067. [SBN read] Allow manual failover between standby and observer. Contributed by Chao Sun.
This commit is contained in:
parent
f5c923be3f
commit
c4d944aeb3
|
@ -476,6 +476,7 @@ public abstract class HAAdmin extends Configured implements Tool {
|
||||||
// Mutative commands take FORCEMANUAL option
|
// Mutative commands take FORCEMANUAL option
|
||||||
if ("-transitionToActive".equals(cmd) ||
|
if ("-transitionToActive".equals(cmd) ||
|
||||||
"-transitionToStandby".equals(cmd) ||
|
"-transitionToStandby".equals(cmd) ||
|
||||||
|
"-transitionToObserver".equals(cmd) ||
|
||||||
"-failover".equals(cmd)) {
|
"-failover".equals(cmd)) {
|
||||||
opts.addOption(FORCEMANUAL, false,
|
opts.addOption(FORCEMANUAL, false,
|
||||||
"force manual control even if auto-failover is enabled");
|
"force manual control even if auto-failover is enabled");
|
||||||
|
|
|
@ -215,11 +215,16 @@ public class TestDFSHAAdmin {
|
||||||
assertTrue(errOutput.contains("Refusing to manually manage"));
|
assertTrue(errOutput.contains("Refusing to manually manage"));
|
||||||
assertEquals(-1, runTool("-transitionToStandby", "nn1"));
|
assertEquals(-1, runTool("-transitionToStandby", "nn1"));
|
||||||
assertTrue(errOutput.contains("Refusing to manually manage"));
|
assertTrue(errOutput.contains("Refusing to manually manage"));
|
||||||
|
assertEquals(-1, runTool("-transitionToObserver", "nn1"));
|
||||||
|
assertTrue(errOutput.contains("Refusing to manually manage"));
|
||||||
|
|
||||||
Mockito.verify(mockProtocol, Mockito.never())
|
Mockito.verify(mockProtocol, Mockito.never())
|
||||||
.transitionToActive(anyReqInfo());
|
.transitionToActive(anyReqInfo());
|
||||||
Mockito.verify(mockProtocol, Mockito.never())
|
Mockito.verify(mockProtocol, Mockito.never())
|
||||||
.transitionToStandby(anyReqInfo());
|
.transitionToStandby(anyReqInfo());
|
||||||
|
Mockito.verify(mockProtocol, Mockito.never())
|
||||||
|
.transitionToObserver(anyReqInfo());
|
||||||
|
|
||||||
|
|
||||||
// Force flag should bypass the check and change the request source
|
// Force flag should bypass the check and change the request source
|
||||||
// for the RPC
|
// for the RPC
|
||||||
|
@ -227,11 +232,15 @@ public class TestDFSHAAdmin {
|
||||||
assertEquals(0, runTool("-transitionToActive", "-forcemanual", "nn1"));
|
assertEquals(0, runTool("-transitionToActive", "-forcemanual", "nn1"));
|
||||||
setupConfirmationOnSystemIn();
|
setupConfirmationOnSystemIn();
|
||||||
assertEquals(0, runTool("-transitionToStandby", "-forcemanual", "nn1"));
|
assertEquals(0, runTool("-transitionToStandby", "-forcemanual", "nn1"));
|
||||||
|
setupConfirmationOnSystemIn();
|
||||||
|
assertEquals(0, runTool("-transitionToObserver", "-forcemanual", "nn1"));
|
||||||
|
|
||||||
Mockito.verify(mockProtocol, Mockito.times(1)).transitionToActive(
|
Mockito.verify(mockProtocol, Mockito.times(1)).transitionToActive(
|
||||||
reqInfoCaptor.capture());
|
reqInfoCaptor.capture());
|
||||||
Mockito.verify(mockProtocol, Mockito.times(1)).transitionToStandby(
|
Mockito.verify(mockProtocol, Mockito.times(1)).transitionToStandby(
|
||||||
reqInfoCaptor.capture());
|
reqInfoCaptor.capture());
|
||||||
|
Mockito.verify(mockProtocol, Mockito.times(1)).transitionToObserver(
|
||||||
|
reqInfoCaptor.capture());
|
||||||
|
|
||||||
// All of the RPCs should have had the "force" source
|
// All of the RPCs should have had the "force" source
|
||||||
for (StateChangeRequestInfo ri : reqInfoCaptor.getAllValues()) {
|
for (StateChangeRequestInfo ri : reqInfoCaptor.getAllValues()) {
|
||||||
|
|
Loading…
Reference in New Issue