turboFei commented on code in PR #3345:
URL: https://github.com/apache/celeborn/pull/3345#discussion_r2165890963


##########
worker/src/main/scala/org/apache/celeborn/service/deploy/worker/profiler/JVMProfiler.scala:
##########
@@ -77,4 +82,32 @@ class JVMProfiler(conf: CelebornConf) extends Logging {
       })
     }
   }
+
+  /** Returns the directory used for storing the extracted libraries, binaries 
and JARs. */
+  private def extractionDir: Path = {
+    val extractionDirectory = applicationsDir
+    if (extractionDirectory.toFile.exists()) {
+      extractionDirectory
+    } else {
+      Utils.createTempDir(conf.workerWorkingDir, "profiler").toPath
+    }
+  }
+
+  /**
+   * Returns directory where applications places their files. Specific to 
operating system.
+   * <p>Note: copied from {@code AsyncProfilerLoader#getApplicationsDir} of 
ap-loader.
+   *
+   * @return Directory where applications places their files.
+   */
+  private def applicationsDir: Path = {
+    if (Utils.isLinux) {
+      val xdgDataHome = System.getenv("XDG_DATA_HOME")
+      if (xdgDataHome != null && xdgDataHome.nonEmpty) { return 
Paths.get(xdgDataHome) }
+      return Paths.get(System.getProperty("user.home"), ".local", "share")
+    } else if (Utils.isMac) {
+      return Paths.get(System.getProperty("user.home"), "Library", 
"Application Support")
+    }
+    throw new UnsupportedOperationException(
+      s"Unsupported os ${System.getProperty("os.name").toLowerCase()}")

Review Comment:
   With scala style, it is
   ```
     private def applicationsDir: Path = {
       if (Utils.isLinux) {
         val xdgDataHome = System.getenv("XDG_DATA_HOME")
         if (xdgDataHome != null && xdgDataHome.nonEmpty) {
           Paths.get(xdgDataHome)
         } else {
           Paths.get(System.getProperty("user.home"), ".local", "share")
         }
       } else if (Utils.isMac) {
         Paths.get(System.getProperty("user.home"), "Library", "Application 
Support")
       } else {
         throw new UnsupportedOperationException(
           s"Unsupported os ${System.getProperty("os.name").toLowerCase()}")
       }
     }
   ```



-- 
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]

Reply via email to