You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "adoroszlai (via GitHub)" <gi...@apache.org> on 2023/04/17 16:31:26 UTC

[GitHub] [ozone] adoroszlai commented on a diff in pull request #4455: HDDS-8253. Set ozone.metadata.dirs if not defined to tmp dir for s3Gateway

adoroszlai commented on code in PR #4455:
URL: https://github.com/apache/ozone/pull/4455#discussion_r1168992447


##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/Gateway.java:
##########
@@ -63,13 +69,35 @@ public static void main(String[] args) throws Exception {
     new Gateway().run(args);
   }
 
+  private void setHttpBaseDir(OzoneConfiguration ozoneConfiguration)

Review Comment:
   ```
   hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/Gateway.java
    72: 'ozoneConfiguration' hides a field.
   ```
   
   I guess the parameter is unnecessary, it can use the field directly.



##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/Gateway.java:
##########
@@ -63,13 +69,35 @@ public static void main(String[] args) throws Exception {
     new Gateway().run(args);
   }
 
+  private void setHttpBaseDir(OzoneConfiguration ozoneConfiguration)
+      throws IOException {
+    if (StringUtils.isEmpty(ozoneConfiguration.get(
+        OzoneConfigKeys.OZONE_HTTP_BASEDIR))) {
+      //Setting ozone.http.basedir if not set so that server setup doesn't
+      // fail.
+      Path tmpMetaDir = Files.createTempDirectory(Paths.get(""),
+          "ozone_s3g_tmp_base_dir");
+      ShutdownHookManager.get().addShutdownHook(() -> {
+        try {
+          FileUtils.deleteDirectory(tmpMetaDir.toFile());
+        } catch (IOException e) {
+          LOG.error("Failed to cleanup temporary S3 Gateway Metadir {}",
+              tmpMetaDir.toFile().getAbsolutePath(), e);
+        }
+      }, 0);
+      ozoneConfiguration.set(OzoneConfigKeys.OZONE_HTTP_BASEDIR,
+          tmpMetaDir.toFile().getAbsolutePath());

Review Comment:
   Nit: Please extract `tmpMetaDir.toFile()`, it's executed 3 times.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org