Github user sryza commented on a diff in the pull request:
https://github.com/apache/spark/pull/3233#discussion_r23805723
--- Diff:
yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala ---
@@ -451,8 +452,20 @@ private[spark] class ApplicationMaster(
private def startUserClass(): Thread = {
logInfo("Starting the user JAR in a separate Thread")
System.setProperty("spark.executor.instances",
args.numExecutors.toString)
- val mainMethod = Class.forName(args.userClass, false,
- Thread.currentThread.getContextClassLoader).getMethod("main",
classOf[Array[String]])
+
+ val classpath = Client.getUserClasspath(null, sparkConf)
+ val urls = classpath.map { entry =>
+ new URL("file:" + new File(entry.getPath()).getAbsolutePath())
+ }
+ val userClassLoader =
+ if (Client.isUserClassPathFirst(sparkConf, true)) {
+ new ChildExecutorURLClassLoader(urls,
Utils.getContextOrSparkClassLoader)
+ } else {
+ new ExecutorURLClassLoader(urls,
Utils.getContextOrSparkClassLoader)
+ }
+
+ val mainMethod = userClassLoader.loadClass(args.userClass)
--- End diff --
What's the difference between using loader.loaderClass as we do here vs.
Class.forName elsewhere? Can we keep them consistent?
---
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]