Github user jerryshao commented on a diff in the pull request:
https://github.com/apache/spark/pull/19013#discussion_r134414298
--- Diff: core/src/main/scala/org/apache/spark/deploy/DependencyUtils.scala
---
@@ -96,4 +89,66 @@ private[deploy] object DependencyUtils {
}
}
}
+
+ /**
+ * Download a list of remote files to temp local files. If the file is
local, the original file
+ * will be returned.
+ * @param fileList A comma separated file list.
+ * @param targetDir A temporary directory for which downloaded files
+ * @param sparkProperties Spark properties
+ * @return A comma separated local files list.
+ */
+ def downloadFileList(
+ fileList: String,
+ targetDir: File,
+ sparkConf: SparkConf,
+ hadoopConf: Configuration,
+ secMgr: SecurityManager): String = {
+ require(fileList != null, "fileList cannot be null.")
+ fileList.split(",")
+ .map(downloadFile(_, targetDir, sparkConf, hadoopConf, secMgr))
+ .mkString(",")
+ }
+
+ /**
+ * Download a file from the remote to a local temporary directory. If
the input path points to
+ * a local path, returns it with no operation.
+ * @param path A file path from where the files will be downloaded.
+ * @param targetDir A temporary directory for which downloaded files
+ * @param sparkProperties Spark properties
+ * @return Path to the local file.
+ */
+ def downloadFile(
+ path: String,
+ targetDir: File,
+ sparkConf: SparkConf,
+ hadoopConf: Configuration,
+ secMgr: SecurityManager): String = {
+ require(path != null, "path cannot be null.")
+ val uri = Utils.resolveURI(path)
+
+ uri.getScheme match {
+ case "file" | "local" => path
+ case _ =>
+ val localFile = Utils.fetchFile(uri.toString(), targetDir,
sparkConf, secMgr, hadoopConf,
--- End diff --
I think it might be better to call `Utils.doFetchFile`, seem like check
cache and untar in `Utils.fetchFile` is not necessary.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]