Skip to content

Commit 97d06e7

Browse files
committed
fix checkstyles, update the documents
1 parent 5ad100b commit 97d06e7

File tree

6 files changed

+28
-29
lines changed

6 files changed

+28
-29
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSHAAdmin.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ private boolean checkSupportObserver(HAServiceTarget target) {
247247
}
248248

249249
private int transitionToObserver(final CommandLine cmd)
250-
throws IOException, ServiceFailedException {
250+
throws IOException {
251251
String[] argv = cmd.getArgs();
252252
if (argv.length != 1) {
253253
errOut.println("transitionToObserver: incorrect number of arguments");
@@ -265,8 +265,8 @@ private int transitionToObserver(final CommandLine cmd)
265265
try {
266266
HAServiceProtocol proto = target.getProxy(getConf(), 0);
267267
HAServiceProtocolHelper.transitionToObserver(proto, createReqInfo());
268-
} catch (IOException e) {
269-
errOut.println("TransitionToObserver failed! " + e.getMessage());
268+
} catch (ServiceFailedException e) {
269+
errOut.println("transitionToObserver failed! " + e.getLocalizedMessage());
270270
return -1;
271271
}
272272
return 0;

hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3749,7 +3749,7 @@
37493749
<name>dfs.ha.nn.not-become-active-in-safemode</name>
37503750
<value>false</value>
37513751
<description>
3752-
This will prevent safe mode namenodes to become active while other standby
3752+
This will prevent safe mode namenodes to become active or observer while other standby
37533753
namenodes might be ready to serve requests when it is set to true.
37543754
</description>
37553755
</property>

hadoop-hdfs-project/hadoop-hdfs/src/site/markdown/HDFSHighAvailabilityWithNFS.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,14 @@ The order in which you set these configurations is unimportant, but the values y
316316
<value>hdfs://mycluster</value>
317317
</property>
318318

319-
* **dfs.ha.nn.not-become-active-in-safemode** - if prevent safe mode namenodes to become active
320-
321-
Whether allow namenode to become active when it is in safemode, when it is
322-
set to true, namenode in safemode will report SERVICE_UNHEALTHY to ZKFC if
323-
auto failover is on, or will throw exception to fail the transition to
324-
active if auto failover is off. For example:
319+
* **dfs.ha.nn.not-become-active-in-safemode** - if prevent safe mode namenodes to become active or observer
320+
321+
Whether allow namenode to become active when it is in safemode, when it is
322+
set to true, namenode in safemode will report SERVICE_UNHEALTHY to ZKFC if
323+
auto failover is on, or will throw exception to fail the transition to
324+
active if auto failover is off. If you transition namenode to observer state
325+
when it is in safemode, when this configuration is set to true, namenode will throw exception
326+
to fail the transition to observer. For example:
325327

326328
<property>
327329
<name>dfs.ha.nn.not-become-active-in-safemode</name>

hadoop-hdfs-project/hadoop-hdfs/src/site/markdown/HDFSHighAvailabilityWithQJM.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,14 @@ The order in which you set these configurations is unimportant, but the values y
376376
<value>/path/to/journal/node/local/data</value>
377377
</property>
378378

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

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

386388
<property>
387389
<name>dfs.ha.nn.not-become-active-in-safemode</name>

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHASafeMode.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -978,20 +978,15 @@ public void testTransitionToActiveWhenSafeMode() throws Exception {
978978
}
979979
}
980980

981-
/**
982-
* Test transition to observer when namenode in safemode.
983-
*
984-
* @throws IOException
985-
*/
986981
@Test
987982
public void testTransitionToObserverWhenSafeMode() throws Exception {
988983
Configuration config = new Configuration();
989984
config.setBoolean(DFS_HA_NN_NOT_BECOME_ACTIVE_IN_SAFEMODE, true);
990985
try (MiniDFSCluster miniCluster = new MiniDFSCluster.Builder(config,
991-
new File(GenericTestUtils.getRandomizedTempPath()))
992-
.nnTopology(MiniDFSNNTopology.simpleHATopology())
993-
.numDataNodes(1)
994-
.build()) {
986+
new File(GenericTestUtils.getRandomizedTempPath()))
987+
.nnTopology(MiniDFSNNTopology.simpleHATopology())
988+
.numDataNodes(1)
989+
.build()) {
995990
miniCluster.waitActive();
996991
miniCluster.transitionToStandby(0);
997992
miniCluster.transitionToStandby(1);
@@ -1000,8 +995,8 @@ public void testTransitionToObserverWhenSafeMode() throws Exception {
1000995
NameNodeAdapter.enterSafeMode(namenode0, false);
1001996
NameNodeAdapter.enterSafeMode(namenode1, false);
1002997
LambdaTestUtils.intercept(ServiceFailedException.class,
1003-
"NameNode still not leave safemode",
1004-
() -> miniCluster.transitionToObserver(0));
998+
"NameNode still not leave safemode",
999+
() -> miniCluster.transitionToObserver(0));
10051000
}
10061001
}
10071002
}

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSHAAdminMiniCluster.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,17 +171,17 @@ public void testObserverIllegalTransition() throws Exception {
171171
@Test
172172
public void testObserverTransitionInSafeMode() throws Exception {
173173
NameNodeAdapter.enterSafeMode(cluster.getNameNode(0), false);
174-
DFSHAAdmin tool = new DFSHAAdmin();
175-
tool.setConf(conf);
174+
DFSHAAdmin admin = new DFSHAAdmin();
175+
admin.setConf(conf);
176176
System.setIn(new ByteArrayInputStream("yes\n".getBytes()));
177-
int result = tool.run(
178-
new String[]{"-transitionToObserver", "-forcemanual", "nn1"});
177+
int result = admin.run(
178+
new String[]{"-transitionToObserver", "-forcemanual", "nn1"});
179179
assertEquals("State transition returned: " + result, -1, result);
180180

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

0 commit comments

Comments
 (0)