Github user vanzin commented on a diff in the pull request:
https://github.com/apache/spark/pull/3233#discussion_r23818879
--- 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 --
`loader.loadClass(foo)` should be equivalent to `Class.forName(foo, true,
loader)` but IMO looks better. Where do you see calls to the latter?
`Class.forName(String)`, which is used elsewhere in this class, has
different semantics.
---
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]