Skip to content

Commit 4c4f4b2

Browse files
committed
fix checkstyles, update the documents
1 parent 5ad100b commit 4c4f4b2

File tree

6 files changed

+34
-35
lines changed

6 files changed

+34
-35
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: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ To configure HA NameNodes, you must add several configuration options to your **
8383

8484
The order in which you set these configurations is unimportant, but the values you choose for **dfs.nameservices** and **dfs.ha.namenodes.[nameservice ID]** will determine the keys of those that follow. Thus, you should decide on these values before setting the rest of the configuration options.
8585

86-
* **dfs.nameservices** - the logical name for this new nameservice
86+
* **dfs.nameservices** - the logical name for this new nameservice
8787

8888
Choose a logical name for this nameservice, for example "mycluster", and use
8989
this logical name for the value of this config option. The name you choose is
@@ -97,7 +97,7 @@ The order in which you set these configurations is unimportant, but the values y
9797
<value>mycluster</value>
9898
</property>
9999

100-
* **dfs.ha.namenodes.[nameservice ID]** - unique identifiers for each NameNode in the nameservice
100+
* **dfs.ha.namenodes.[nameservice ID]** - unique identifiers for each NameNode in the nameservice
101101

102102
Configure with a list of comma-separated NameNode IDs. This will be used by
103103
DataNodes to determine all the NameNodes in the cluster. For example, if you
@@ -111,7 +111,7 @@ The order in which you set these configurations is unimportant, but the values y
111111

112112
**Note:** The minimum number of NameNodes for HA is two, but you can configure more. Its suggested to not exceed 5 - with a recommended 3 NameNodes - due to communication overheads.
113113

114-
* **dfs.namenode.rpc-address.[nameservice ID].[name node ID]** - the fully-qualified RPC address for each NameNode to listen on
114+
* **dfs.namenode.rpc-address.[nameservice ID].[name node ID]** - the fully-qualified RPC address for each NameNode to listen on
115115

116116
For both of the previously-configured NameNode IDs, set the full address and
117117
IPC port of the NameNode process. Note that this results in two separate
@@ -133,7 +133,7 @@ The order in which you set these configurations is unimportant, but the values y
133133
**Note:** You may similarly configure the "**servicerpc-address**" setting if
134134
you so desire.
135135

136-
* **dfs.namenode.http-address.[nameservice ID].[name node ID]** - the fully-qualified HTTP address for each NameNode to listen on
136+
* **dfs.namenode.http-address.[nameservice ID].[name node ID]** - the fully-qualified HTTP address for each NameNode to listen on
137137

138138
Similarly to *rpc-address* above, set the addresses for both NameNodes' HTTP
139139
servers to listen on. For example:
@@ -154,7 +154,7 @@ The order in which you set these configurations is unimportant, but the values y
154154
**Note:** If you have Hadoop's security features enabled, you should also set
155155
the *https-address* similarly for each NameNode.
156156

157-
* **dfs.namenode.shared.edits.dir** - the location of the shared storage directory
157+
* **dfs.namenode.shared.edits.dir** - the location of the shared storage directory
158158

159159
This is where one configures the path to the remote shared edits directory
160160
which the Standby NameNodes use to stay up-to-date with all the file system
@@ -168,7 +168,7 @@ The order in which you set these configurations is unimportant, but the values y
168168
<value>file:///mnt/filer1/dfs/ha-name-dir-shared</value>
169169
</property>
170170

171-
* **dfs.client.failover.proxy.provider.[nameservice ID]** - the Java class that HDFS clients use to contact the Active NameNode
171+
* **dfs.client.failover.proxy.provider.[nameservice ID]** - the Java class that HDFS clients use to contact the Active NameNode
172172

173173
Configure the name of the Java class which will be used by the DFS Client to
174174
determine which NameNode is the current Active, and therefore which NameNode is
@@ -184,7 +184,7 @@ The order in which you set these configurations is unimportant, but the values y
184184
<value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
185185
</property>
186186

187-
* **dfs.ha.fencing.methods** - a list of scripts or Java classes which will be used to fence the Active NameNode during a failover
187+
* **dfs.ha.fencing.methods** - a list of scripts or Java classes which will be used to fence the Active NameNode during a failover
188188

189189
It is critical for correctness of the system that only one NameNode be in the
190190
Active state at any given time. Thus, during a failover, we first ensure that
@@ -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
319+
* **dfs.ha.nn.not-become-active-in-safemode** - if prevent safe mode namenodes to become active or observer
320320

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:
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)