LuciferYang commented on code in PR #36529:
URL: https://github.com/apache/spark/pull/36529#discussion_r1153917326
##########
common/network-common/src/main/java/org/apache/spark/network/util/JavaUtils.java:
##########
@@ -362,6 +364,60 @@ public static byte[] bufferToArray(ByteBuffer buffer) {
}
}
+ /**
+ * Create a temporary directory inside `java.io.tmpdir` with default
namePrefix "spark".
+ * The directory will be automatically deleted when the VM shuts down.
+ */
+ public static File createTempDir() throws IOException {
+ return createTempDir(System.getProperty("java.io.tmpdir"), "spark");
+ }
+
+ /**
+ * Create a temporary directory inside the given parent directory. The
directory will be
+ * automatically deleted when the VM shuts down.
+ */
+ public static File createTempDir(String root, String namePrefix) throws
IOException {
Review Comment:
If keep using Scala, the work may includes:
1. Move `org.apache.spark.util.ShutdownHookManager` to
`org.apache.spark.network.util.ShutdownHookManager` and refactor all other use
places.
2. Use `LoggerFactory.getLogger` instead of `extends Logging` due to
`Logging` trait in core module
https://github.com/apache/spark/blob/35503a535771d257b517e7ddf2adfaefefd97dad/core/src/main/scala/org/apache/spark/util/ShutdownHookManager.scala#L32
3. Need introduce `hadoop-client-api` module to `network-common` module due
to `org.apache.hadoop.util.ShutdownHookManager` used by
`SparkShutdownHookManager`, I haven't thought of a solution without introducing
`hadoop-client-api` module to `network-common` module
https://github.com/apache/spark/blob/35503a535771d257b517e7ddf2adfaefefd97dad/core/src/main/scala/org/apache/spark/util/ShutdownHookManager.scala#L176-L182
--
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]