Skip to content

Commit a16d627

Browse files
author
Hanisha Koneru
authored
Revert "HDDS-1474. ozone.scm.datanode.id config should take path for a dir (#792)"
This reverts commit 18cca58.
1 parent ec36126 commit a16d627

File tree

24 files changed

+45
-56
lines changed

24 files changed

+45
-56
lines changed

hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/ScmConfigKeys.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,11 @@ public final class ScmConfigKeys {
296296

297297
public static final int OZONE_SCM_DEFAULT_PORT =
298298
OZONE_SCM_DATANODE_PORT_DEFAULT;
299-
// The path where datanode ID is to be written to.
299+
// File Name and path where datanode ID is to written to.
300300
// if this value is not set then container startup will fail.
301-
public static final String OZONE_SCM_DATANODE_ID_DIR =
302-
"ozone.scm.datanode.id.dir";
301+
public static final String OZONE_SCM_DATANODE_ID = "ozone.scm.datanode.id";
302+
303+
public static final String OZONE_SCM_DATANODE_ID_PATH_DEFAULT = "datanode.id";
303304

304305
public static final String OZONE_SCM_DB_CACHE_SIZE_MB =
305306
"ozone.scm.db.cache.size.mb";

hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/OzoneConsts.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,6 @@ public static Versioning getVersioning(boolean versioning) {
195195
public static final int INVALID_PORT = -1;
196196

197197

198-
/**
199-
* Default SCM Datanode ID file name.
200-
*/
201-
public static final String OZONE_SCM_DATANODE_ID_FILE_DEFAULT = "datanode.id";
202-
203198
// The ServiceListJSONServlet context attribute where OzoneManager
204199
// instance gets stored.
205200
public static final String OM_CONTEXT_ATTRIBUTE = "ozone.om";

hadoop-hdds/common/src/main/resources/ozone-default.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@
883883
</description>
884884
</property>
885885
<property>
886-
<name>ozone.scm.datanode.id.dir</name>
886+
<name>ozone.scm.datanode.id</name>
887887
<value/>
888888
<tag>OZONE, MANAGEMENT</tag>
889889
<description>The path that datanodes will use to store the datanode ID.

hadoop-hdds/container-service/src/main/java/org/apache/hadoop/hdds/scm/HddsServerUtil.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.apache.hadoop.hdds.server.ServerUtils;
2424
import org.apache.hadoop.net.NetUtils;
2525
import org.apache.hadoop.ozone.OzoneConfigKeys;
26-
import org.apache.hadoop.ozone.OzoneConsts;
2726
import org.slf4j.Logger;
2827
import org.slf4j.LoggerFactory;
2928

@@ -381,20 +380,18 @@ public static String getDefaultRatisDirectory(Configuration conf) {
381380
* @return the path of datanode id as string
382381
*/
383382
public static String getDatanodeIdFilePath(Configuration conf) {
384-
String dataNodeIDDirPath =
385-
conf.get(ScmConfigKeys.OZONE_SCM_DATANODE_ID_DIR);
386-
if (dataNodeIDDirPath == null) {
383+
String dataNodeIDPath = conf.get(ScmConfigKeys.OZONE_SCM_DATANODE_ID);
384+
if (dataNodeIDPath == null) {
387385
File metaDirPath = ServerUtils.getOzoneMetaDirPath(conf);
388386
if (metaDirPath == null) {
389387
// this means meta data is not found, in theory should not happen at
390388
// this point because should've failed earlier.
391389
throw new IllegalArgumentException("Unable to locate meta data" +
392390
"directory when getting datanode id path");
393391
}
394-
dataNodeIDDirPath = metaDirPath.toString();
392+
dataNodeIDPath = new File(metaDirPath,
393+
ScmConfigKeys.OZONE_SCM_DATANODE_ID_PATH_DEFAULT).toString();
395394
}
396-
// Use default datanode id file name for file path
397-
return new File(dataNodeIDDirPath,
398-
OzoneConsts.OZONE_SCM_DATANODE_ID_FILE_DEFAULT).toString();
395+
return dataNodeIDPath;
399396
}
400397
}

hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsDatanodeService.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,9 @@ private DatanodeDetails initializeDatanodeDetails()
320320
throws IOException {
321321
String idFilePath = HddsServerUtil.getDatanodeIdFilePath(conf);
322322
if (idFilePath == null || idFilePath.isEmpty()) {
323-
LOG.error("A valid path is needed for config setting {}",
324-
ScmConfigKeys.OZONE_SCM_DATANODE_ID_DIR);
325-
throw new IllegalArgumentException(
326-
ScmConfigKeys.OZONE_SCM_DATANODE_ID_DIR +
323+
LOG.error("A valid file path is needed for config setting {}",
324+
ScmConfigKeys.OZONE_SCM_DATANODE_ID);
325+
throw new IllegalArgumentException(ScmConfigKeys.OZONE_SCM_DATANODE_ID +
327326
" must be defined. See" +
328327
" https://wiki.apache.org/hadoop/Ozone#Configuration" +
329328
" for details on configuring Ozone.");
@@ -351,10 +350,9 @@ private void persistDatanodeDetails(DatanodeDetails dnDetails)
351350
throws IOException {
352351
String idFilePath = HddsServerUtil.getDatanodeIdFilePath(conf);
353352
if (idFilePath == null || idFilePath.isEmpty()) {
354-
LOG.error("A valid path is needed for config setting {}",
355-
ScmConfigKeys.OZONE_SCM_DATANODE_ID_DIR);
356-
throw new IllegalArgumentException(
357-
ScmConfigKeys.OZONE_SCM_DATANODE_ID_DIR +
353+
LOG.error("A valid file path is needed for config setting {}",
354+
ScmConfigKeys.OZONE_SCM_DATANODE_ID);
355+
throw new IllegalArgumentException(ScmConfigKeys.OZONE_SCM_DATANODE_ID +
358356
" must be defined. See" +
359357
" https://wiki.apache.org/hadoop/Ozone#Configuration" +
360358
" for details on configuring Ozone.");

hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/datanode/InitDatanodeState.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ public DatanodeStateMachine.DatanodeStates call() throws Exception {
119119
private void persistContainerDatanodeDetails() {
120120
String dataNodeIDPath = HddsServerUtil.getDatanodeIdFilePath(conf);
121121
if (Strings.isNullOrEmpty(dataNodeIDPath)) {
122-
LOG.error("A valid path is needed for config setting {}",
123-
ScmConfigKeys.OZONE_SCM_DATANODE_ID_DIR);
122+
LOG.error("A valid file path is needed for config setting {}",
123+
ScmConfigKeys.OZONE_SCM_DATANODE_ID);
124124
this.context.setState(DatanodeStateMachine.DatanodeStates.SHUTDOWN);
125125
return;
126126
}

hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/TestDatanodeStateMachine.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
2626
import org.apache.hadoop.ipc.RPC;
2727
import org.apache.hadoop.ozone.OzoneConfigKeys;
28-
import org.apache.hadoop.ozone.OzoneConsts;
2928
import org.apache.hadoop.ozone.container.common.helpers.ContainerUtils;
3029
import org.apache.hadoop.ozone.container.common.statemachine
3130
.DatanodeStateMachine;
@@ -50,6 +49,7 @@
5049
import java.io.File;
5150
import java.io.IOException;
5251
import java.net.InetSocketAddress;
52+
import java.nio.file.Paths;
5353
import java.util.ArrayList;
5454
import java.util.List;
5555
import java.util.Map;
@@ -117,8 +117,9 @@ public void setUp() throws Exception {
117117
}
118118
conf.set(HddsConfigKeys.OZONE_METADATA_DIRS,
119119
new File(testRoot, "scm").getAbsolutePath());
120-
path = new File(testRoot, "datanodeID").getAbsolutePath();
121-
conf.set(ScmConfigKeys.OZONE_SCM_DATANODE_ID_DIR, path);
120+
path = Paths.get(path.toString(),
121+
TestDatanodeStateMachine.class.getSimpleName() + ".id").toString();
122+
conf.set(ScmConfigKeys.OZONE_SCM_DATANODE_ID, path);
122123
executorService = HadoopExecutors.newCachedThreadPool(
123124
new ThreadFactoryBuilder().setDaemon(true)
124125
.setNameFormat("Test Data Node State Machine Thread - %d").build());
@@ -211,8 +212,7 @@ public void testDatanodeStateContext() throws IOException,
211212
// There is no mini cluster started in this test,
212213
// create a ID file so that state machine could load a fake datanode ID.
213214
File idPath = new File(
214-
conf.get(ScmConfigKeys.OZONE_SCM_DATANODE_ID_DIR),
215-
OzoneConsts.OZONE_SCM_DATANODE_ID_FILE_DEFAULT);
215+
conf.get(ScmConfigKeys.OZONE_SCM_DATANODE_ID));
216216
idPath.delete();
217217
DatanodeDetails datanodeDetails = getNewDatanodeDetails();
218218
DatanodeDetails.Port port = DatanodeDetails.newPort(
@@ -334,8 +334,7 @@ public void testDatanodeStateContext() throws IOException,
334334
public void testDatanodeStateMachineWithIdWriteFail() throws Exception {
335335

336336
File idPath = new File(
337-
conf.get(ScmConfigKeys.OZONE_SCM_DATANODE_ID_DIR),
338-
OzoneConsts.OZONE_SCM_DATANODE_ID_FILE_DEFAULT);
337+
conf.get(ScmConfigKeys.OZONE_SCM_DATANODE_ID));
339338
idPath.delete();
340339
DatanodeDetails datanodeDetails = getNewDatanodeDetails();
341340
DatanodeDetails.Port port = DatanodeDetails.newPort(
@@ -397,10 +396,10 @@ public void testDatanodeStateMachineWithInvalidConfiguration()
397396
/** Port out of range **/
398397
confList.add(Maps.immutableEntry(
399398
ScmConfigKeys.OZONE_SCM_NAMES, "scm:123456"));
400-
// Invalid ozone.scm.datanode.id.dir
399+
// Invalid ozone.scm.datanode.id
401400
/** Empty **/
402401
confList.add(Maps.immutableEntry(
403-
ScmConfigKeys.OZONE_SCM_DATANODE_ID_DIR, ""));
402+
ScmConfigKeys.OZONE_SCM_DATANODE_ID, ""));
404403

405404
confList.forEach((entry) -> {
406405
Configuration perTestConf = new Configuration(conf);

hadoop-hdds/docs/content/Settings.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ Here is an example,
105105
</property>
106106
{{< /highlight >}}
107107

108-
* **ozone.scm.datanode.id.dir** Data nodes generate a Unique ID called Datanode
109-
ID. This identity is written to the file datanode.id in a directory specified by this path. *Data nodes
108+
* **ozone.scm.datanode.id** Data nodes generate a Unique ID called Datanode
109+
ID. This identity is written to the file specified by this path. *Data nodes
110110
will create this path if it doesn't exist already.*
111111

112112
Here is an example,
113113
{{< highlight xml >}}
114114
<property>
115-
<name>ozone.scm.datanode.id.dir</name>
115+
<name>ozone.scm.datanode.id</name>
116116
<value>/data/disk1/meta/node/datanode.id</value>
117117
</property>
118118
{{< /highlight >}}

hadoop-ozone/dist/src/main/compose/ozone-hdfs/docker-config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ OZONE-SITE.XML_ozone.om.address=om
1818
OZONE-SITE.XML_ozone.om.http-address=om:9874
1919
OZONE-SITE.XML_ozone.scm.names=scm
2020
OZONE-SITE.XML_ozone.enabled=true
21-
OZONE-SITE.XML_ozone.scm.datanode.id.dir=/data
21+
OZONE-SITE.XML_ozone.scm.datanode.id=/data/datanode.id
2222
OZONE-SITE.XML_ozone.scm.block.client.address=scm
2323
OZONE-SITE.XML_ozone.metadata.dirs=/data/metadata
2424
OZONE-SITE.XML_ozone.scm.client.address=scm

hadoop-ozone/dist/src/main/compose/ozone-om-ha/docker-config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ OZONE-SITE.XML_ozone.om.address.om3=om3
2121
OZONE-SITE.XML_ozone.om.ratis.enable=true
2222
OZONE-SITE.XML_ozone.scm.names=scm
2323
OZONE-SITE.XML_ozone.enabled=True
24-
OZONE-SITE.XML_ozone.scm.datanode.id.dir=/data
24+
OZONE-SITE.XML_ozone.scm.datanode.id=/data/datanode.id
2525
OZONE-SITE.XML_ozone.scm.block.client.address=scm
2626
OZONE-SITE.XML_ozone.metadata.dirs=/data/metadata
2727
OZONE-SITE.XML_ozone.handler.type=distributed

0 commit comments

Comments
 (0)