Skip to content

Commit b832e17

Browse files
vivekratnavelHanisha Koneru
authored andcommitted
HDDS-1474. "ozone.scm.datanode.id" config should take path for a dir and not a file (#809)
1 parent 1b48100 commit b832e17

File tree

24 files changed

+56
-45
lines changed

24 files changed

+56
-45
lines changed

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

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

297297
public static final int OZONE_SCM_DEFAULT_PORT =
298298
OZONE_SCM_DATANODE_PORT_DEFAULT;
299-
// File Name and path where datanode ID is to written to.
299+
// The path where datanode ID is to be written to.
300300
// if this value is not set then container startup will fail.
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";
301+
public static final String OZONE_SCM_DATANODE_ID_DIR =
302+
"ozone.scm.datanode.id.dir";
304303

305304
public static final String OZONE_SCM_DB_CACHE_SIZE_MB =
306305
"ozone.scm.db.cache.size.mb";

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ 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+
198203
// The ServiceListJSONServlet context attribute where OzoneManager
199204
// instance gets stored.
200205
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</name>
886+
<name>ozone.scm.datanode.id.dir</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: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
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;
2627
import org.slf4j.Logger;
2728
import org.slf4j.LoggerFactory;
2829

@@ -380,18 +381,20 @@ public static String getDefaultRatisDirectory(Configuration conf) {
380381
* @return the path of datanode id as string
381382
*/
382383
public static String getDatanodeIdFilePath(Configuration conf) {
383-
String dataNodeIDPath = conf.get(ScmConfigKeys.OZONE_SCM_DATANODE_ID);
384-
if (dataNodeIDPath == null) {
384+
String dataNodeIDDirPath =
385+
conf.get(ScmConfigKeys.OZONE_SCM_DATANODE_ID_DIR);
386+
if (dataNodeIDDirPath == null) {
385387
File metaDirPath = ServerUtils.getOzoneMetaDirPath(conf);
386388
if (metaDirPath == null) {
387389
// this means meta data is not found, in theory should not happen at
388390
// this point because should've failed earlier.
389391
throw new IllegalArgumentException("Unable to locate meta data" +
390392
"directory when getting datanode id path");
391393
}
392-
dataNodeIDPath = new File(metaDirPath,
393-
ScmConfigKeys.OZONE_SCM_DATANODE_ID_PATH_DEFAULT).toString();
394+
dataNodeIDDirPath = metaDirPath.toString();
394395
}
395-
return dataNodeIDPath;
396+
// Use default datanode id file name for file path
397+
return new File(dataNodeIDDirPath,
398+
OzoneConsts.OZONE_SCM_DATANODE_ID_FILE_DEFAULT).toString();
396399
}
397400
}

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,10 @@ private DatanodeDetails initializeDatanodeDetails()
320320
throws IOException {
321321
String idFilePath = HddsServerUtil.getDatanodeIdFilePath(conf);
322322
if (idFilePath == null || idFilePath.isEmpty()) {
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 +
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 +
326327
" must be defined. See" +
327328
" https://wiki.apache.org/hadoop/Ozone#Configuration" +
328329
" for details on configuring Ozone.");
@@ -350,9 +351,10 @@ private void persistDatanodeDetails(DatanodeDetails dnDetails)
350351
throws IOException {
351352
String idFilePath = HddsServerUtil.getDatanodeIdFilePath(conf);
352353
if (idFilePath == null || idFilePath.isEmpty()) {
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 +
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 +
356358
" must be defined. See" +
357359
" https://wiki.apache.org/hadoop/Ozone#Configuration" +
358360
" 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 file path is needed for config setting {}",
123-
ScmConfigKeys.OZONE_SCM_DATANODE_ID);
122+
LOG.error("A valid path is needed for config setting {}",
123+
ScmConfigKeys.OZONE_SCM_DATANODE_ID_DIR);
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: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
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;
2829
import org.apache.hadoop.ozone.container.common.helpers.ContainerUtils;
2930
import org.apache.hadoop.ozone.container.common.statemachine
3031
.DatanodeStateMachine;
@@ -49,7 +50,6 @@
4950
import java.io.File;
5051
import java.io.IOException;
5152
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,9 +117,8 @@ public void setUp() throws Exception {
117117
}
118118
conf.set(HddsConfigKeys.OZONE_METADATA_DIRS,
119119
new File(testRoot, "scm").getAbsolutePath());
120-
path = Paths.get(path.toString(),
121-
TestDatanodeStateMachine.class.getSimpleName() + ".id").toString();
122-
conf.set(ScmConfigKeys.OZONE_SCM_DATANODE_ID, path);
120+
path = new File(testRoot, "datanodeID").getAbsolutePath();
121+
conf.set(ScmConfigKeys.OZONE_SCM_DATANODE_ID_DIR, path);
123122
executorService = HadoopExecutors.newCachedThreadPool(
124123
new ThreadFactoryBuilder().setDaemon(true)
125124
.setNameFormat("Test Data Node State Machine Thread - %d").build());
@@ -212,7 +211,8 @@ public void testDatanodeStateContext() throws IOException,
212211
// There is no mini cluster started in this test,
213212
// create a ID file so that state machine could load a fake datanode ID.
214213
File idPath = new File(
215-
conf.get(ScmConfigKeys.OZONE_SCM_DATANODE_ID));
214+
conf.get(ScmConfigKeys.OZONE_SCM_DATANODE_ID_DIR),
215+
OzoneConsts.OZONE_SCM_DATANODE_ID_FILE_DEFAULT);
216216
idPath.delete();
217217
DatanodeDetails datanodeDetails = getNewDatanodeDetails();
218218
DatanodeDetails.Port port = DatanodeDetails.newPort(
@@ -334,7 +334,8 @@ 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));
337+
conf.get(ScmConfigKeys.OZONE_SCM_DATANODE_ID_DIR),
338+
OzoneConsts.OZONE_SCM_DATANODE_ID_FILE_DEFAULT);
338339
idPath.delete();
339340
DatanodeDetails datanodeDetails = getNewDatanodeDetails();
340341
DatanodeDetails.Port port = DatanodeDetails.newPort(
@@ -396,10 +397,10 @@ public void testDatanodeStateMachineWithInvalidConfiguration()
396397
/** Port out of range **/
397398
confList.add(Maps.immutableEntry(
398399
ScmConfigKeys.OZONE_SCM_NAMES, "scm:123456"));
399-
// Invalid ozone.scm.datanode.id
400+
// Invalid ozone.scm.datanode.id.dir
400401
/** Empty **/
401402
confList.add(Maps.immutableEntry(
402-
ScmConfigKeys.OZONE_SCM_DATANODE_ID, ""));
403+
ScmConfigKeys.OZONE_SCM_DATANODE_ID_DIR, ""));
403404

404405
confList.forEach((entry) -> {
405406
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** Data nodes generate a Unique ID called Datanode
109-
ID. This identity is written to the file specified by this path. *Data nodes
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
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</name>
115+
<name>ozone.scm.datanode.id.dir</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=/data/datanode.id
21+
OZONE-SITE.XML_ozone.scm.datanode.id.dir=/data
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=/data/datanode.id
24+
OZONE-SITE.XML_ozone.scm.datanode.id.dir=/data
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)