Skip to content

Commit

Permalink
fix checkstyles, update the documents
Browse files Browse the repository at this point in the history
  • Loading branch information
tomscut committed Oct 28, 2022
1 parent 5ad100b commit 97d06e7
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ private boolean checkSupportObserver(HAServiceTarget target) {
}

private int transitionToObserver(final CommandLine cmd)
throws IOException, ServiceFailedException {
throws IOException {
String[] argv = cmd.getArgs();
if (argv.length != 1) {
errOut.println("transitionToObserver: incorrect number of arguments");
Expand All @@ -265,8 +265,8 @@ private int transitionToObserver(final CommandLine cmd)
try {
HAServiceProtocol proto = target.getProxy(getConf(), 0);
HAServiceProtocolHelper.transitionToObserver(proto, createReqInfo());
} catch (IOException e) {
errOut.println("TransitionToObserver failed! " + e.getMessage());
} catch (ServiceFailedException e) {
errOut.println("transitionToObserver failed! " + e.getLocalizedMessage());
return -1;
}
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3749,7 +3749,7 @@
<name>dfs.ha.nn.not-become-active-in-safemode</name>
<value>false</value>
<description>
This will prevent safe mode namenodes to become active while other standby
This will prevent safe mode namenodes to become active or observer while other standby
namenodes might be ready to serve requests when it is set to true.
</description>
</property>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,14 @@ The order in which you set these configurations is unimportant, but the values y
<value>hdfs://mycluster</value>
</property>

* **dfs.ha.nn.not-become-active-in-safemode** - if prevent safe mode namenodes to become active

Whether allow namenode to become active when it is in safemode, when it is
set to true, namenode in safemode will report SERVICE_UNHEALTHY to ZKFC if
auto failover is on, or will throw exception to fail the transition to
active if auto failover is off. For example:
* **dfs.ha.nn.not-become-active-in-safemode** - if prevent safe mode namenodes to become active or observer

Whether allow namenode to become active when it is in safemode, when it is
set to true, namenode in safemode will report SERVICE_UNHEALTHY to ZKFC if
auto failover is on, or will throw exception to fail the transition to
active if auto failover is off. If you transition namenode to observer state
when it is in safemode, when this configuration is set to true, namenode will throw exception
to fail the transition to observer. For example:

<property>
<name>dfs.ha.nn.not-become-active-in-safemode</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,14 @@ The order in which you set these configurations is unimportant, but the values y
<value>/path/to/journal/node/local/data</value>
</property>

* **dfs.ha.nn.not-become-active-in-safemode** - if prevent safe mode namenodes to become active
* **dfs.ha.nn.not-become-active-in-safemode** - if prevent safe mode namenodes to become active or observer

Whether allow namenode to become active when it is in safemode, when it is
set to true, namenode in safemode will report SERVICE_UNHEALTHY to ZKFC if
auto failover is on, or will throw exception to fail the transition to
active if auto failover is off. For example:
active if auto failover is off. If you transition namenode to observer state
when it is in safemode, when this configuration is set to true, namenode will throw exception
to fail the transition to observer. For example:

<property>
<name>dfs.ha.nn.not-become-active-in-safemode</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -978,20 +978,15 @@ public void testTransitionToActiveWhenSafeMode() throws Exception {
}
}

/**
* Test transition to observer when namenode in safemode.
*
* @throws IOException
*/
@Test
public void testTransitionToObserverWhenSafeMode() throws Exception {
Configuration config = new Configuration();
config.setBoolean(DFS_HA_NN_NOT_BECOME_ACTIVE_IN_SAFEMODE, true);
try (MiniDFSCluster miniCluster = new MiniDFSCluster.Builder(config,
new File(GenericTestUtils.getRandomizedTempPath()))
.nnTopology(MiniDFSNNTopology.simpleHATopology())
.numDataNodes(1)
.build()) {
new File(GenericTestUtils.getRandomizedTempPath()))
.nnTopology(MiniDFSNNTopology.simpleHATopology())
.numDataNodes(1)
.build()) {
miniCluster.waitActive();
miniCluster.transitionToStandby(0);
miniCluster.transitionToStandby(1);
Expand All @@ -1000,8 +995,8 @@ public void testTransitionToObserverWhenSafeMode() throws Exception {
NameNodeAdapter.enterSafeMode(namenode0, false);
NameNodeAdapter.enterSafeMode(namenode1, false);
LambdaTestUtils.intercept(ServiceFailedException.class,
"NameNode still not leave safemode",
() -> miniCluster.transitionToObserver(0));
"NameNode still not leave safemode",
() -> miniCluster.transitionToObserver(0));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,17 @@ public void testObserverIllegalTransition() throws Exception {
@Test
public void testObserverTransitionInSafeMode() throws Exception {
NameNodeAdapter.enterSafeMode(cluster.getNameNode(0), false);
DFSHAAdmin tool = new DFSHAAdmin();
tool.setConf(conf);
DFSHAAdmin admin = new DFSHAAdmin();
admin.setConf(conf);
System.setIn(new ByteArrayInputStream("yes\n".getBytes()));
int result = tool.run(
new String[]{"-transitionToObserver", "-forcemanual", "nn1"});
int result = admin.run(
new String[]{"-transitionToObserver", "-forcemanual", "nn1"});
assertEquals("State transition returned: " + result, -1, result);

NameNodeAdapter.leaveSafeMode(cluster.getNameNode(0));
System.setIn(new ByteArrayInputStream("yes\n".getBytes()));
int result1 = tool.run(
new String[]{"-transitionToObserver", "-forcemanual", "nn1"});
int result1 = admin.run(
new String[]{"-transitionToObserver", "-forcemanual", "nn1"});
assertEquals("State transition returned: " + result1, 0, result1);
assertFalse(cluster.getNameNode(0).isInSafeMode());
}
Expand Down

0 comments on commit 97d06e7

Please sign in to comment.