smengcl commented on code in PR #8937:
URL: https://github.com/apache/ozone/pull/8937#discussion_r2279643148


##########
hadoop-ozone/mini-cluster/src/main/java/org/apache/hadoop/ozone/MiniOzoneClusterImpl.java:
##########
@@ -702,14 +710,65 @@ protected void configureSCM() {
       conf.setInt(ScmConfigKeys.OZONE_SCM_RATIS_PORT_KEY, getFreePort());
       conf.setInt(ScmConfigKeys.OZONE_SCM_GRPC_PORT_KEY, getFreePort());
       
conf.setIfUnset(ScmConfigKeys.OZONE_SCM_HA_RATIS_SERVER_RPC_FIRST_ELECTION_TIMEOUT,
 "1s");
+
+      Path scmMetaDir = Paths.get(path, SCM_SUBDIR_NAME);
+      Files.createDirectories(scmMetaDir.resolve(DATA_SUBDIR_NAME));
+
+      // Extra configs for non-HA SCM
+      if (!isHA) {
+        // e.g. when path is /var/lib/hadoop-ozone
+        // ozone.scm.ha.ratis.storage.dir = /var/lib/hadoop-ozone/scm/ratis
+        conf.setIfUnset(ScmConfigKeys.OZONE_SCM_HA_RATIS_STORAGE_DIR,
+            scmMetaDir.resolve(RATIS_SUBDIR_NAME).toString());
+
+        // ozone.scm.ha.ratis.snapshot.dir = 
/var/lib/hadoop-ozone/scm/ozone-metadata/snapshot
+        conf.setIfUnset(ScmConfigKeys.OZONE_SCM_HA_RATIS_SNAPSHOT_DIR,
+            
scmMetaDir.resolve(OZONE_METADATA_SUBDIR_NAME).resolve(OZONE_RATIS_SNAPSHOT_DIR).toString());
+
+        // ozone.scm.db.dirs = /var/lib/hadoop-ozone/scm/data
+        conf.setIfUnset(ScmConfigKeys.OZONE_SCM_DB_DIRS,
+            scmMetaDir.resolve(DATA_SUBDIR_NAME).toString());
+
+        // ozone.http.basedir = 
/var/lib/hadoop-ozone/scm/ozone-metadata/webserver
+        conf.setIfUnset(OzoneConfigKeys.OZONE_HTTP_BASEDIR,
+            scmMetaDir.resolve(OZONE_METADATA_SUBDIR_NAME) + SERVER_DIR);
+      }
     }
 
-    private void configureOM() {
+    private void configureOM(boolean isHA) throws IOException {
       conf.set(OMConfigKeys.OZONE_OM_ADDRESS_KEY, localhostWithFreePort());
       conf.set(OMConfigKeys.OZONE_OM_HTTP_ADDRESS_KEY, 
localhostWithFreePort());
       conf.set(OMConfigKeys.OZONE_OM_HTTPS_ADDRESS_KEY,
           localhostWithFreePort());
       conf.setInt(OMConfigKeys.OZONE_OM_RATIS_PORT_KEY, getFreePort());
+
+      Path omMetaDir = Paths.get(path, OM_SUBDIR_NAME);
+      Files.createDirectories(omMetaDir.resolve(DATA_SUBDIR_NAME));
+
+      // Extra configs for non-HA OM
+      if (!isHA) {
+        // e.g. when path is /var/lib/hadoop-ozone
+        // ozone.om.ratis.storage.dir = /var/lib/hadoop-ozone/om/ratis
+        conf.setIfUnset(OMConfigKeys.OZONE_OM_RATIS_STORAGE_DIR,
+            omMetaDir.resolve(RATIS_SUBDIR_NAME).toString());
+
+        // ozone.om.ratis.snapshot.dir = 
/var/lib/hadoop-ozone/om/ozone-metadata/snapshot
+        conf.setIfUnset(OMConfigKeys.OZONE_OM_RATIS_SNAPSHOT_DIR,
+            
omMetaDir.resolve(OZONE_METADATA_SUBDIR_NAME).resolve(OZONE_RATIS_SNAPSHOT_DIR).toString());
+
+        // ozone.om.db.dirs = /var/lib/hadoop-ozone/om/data
+        conf.setIfUnset(OMConfigKeys.OZONE_OM_DB_DIRS,
+            omMetaDir.resolve(DATA_SUBDIR_NAME).toString());
+
+        // ozone.om.snapshot.diff.db.dir = 
/var/lib/hadoop-ozone/om/ozone-metadata
+        // actual dir would be 
/var/lib/hadoop-ozone/om/ozone-metadata/db.snapdiff
+        conf.setIfUnset(OMConfigKeys.OZONE_OM_SNAPSHOT_DIFF_DB_DIR,
+            omMetaDir.resolve(OZONE_METADATA_SUBDIR_NAME).toString());
+
+        // ozone.http.basedir = 
/var/lib/hadoop-ozone/om/ozone-metadata/webserver
+        conf.setIfUnset(OzoneConfigKeys.OZONE_HTTP_BASEDIR,
+            omMetaDir.resolve(OZONE_METADATA_SUBDIR_NAME) + SERVER_DIR);

Review Comment:
   Note `SERVER_DIR` includes `/` at the beginning so what copilot suggested 
won't work. I learnt that because I was using the exact same approach at the 
beginning and it broke the tests.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to