Skip to content

Commit

Permalink
[SPARK-10986][MESOS] Set the context class loader in the Mesos execut…
Browse files Browse the repository at this point in the history
…or backend.

See [SPARK-10986](https://issues.apache.org/jira/browse/SPARK-10986) for details.

This fixes the `ClassNotFoundException` for Spark classes in the serializer.

I am not sure this is the right way to handle the class loader, but I couldn't find any documentation on how the context class loader is used and who relies on it. It seems at least the serializer uses it to instantiate classes during deserialization.

I am open to suggestions (I tried this fix on a real Mesos cluster and it *does* fix the issue).

tnachen andrewor14

Author: Iulian Dragos <[email protected]>

Closes apache#9282 from dragos/issue/mesos-classloader.
  • Loading branch information
dragos authored and srowen committed Oct 30, 2015
1 parent 14d08b9 commit 0451b00
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ private[spark] class MesosExecutorBackend

logInfo(s"Registered with Mesos as executor ID $executorId with $cpusPerTask cpus")
this.driver = driver
// Set a context class loader to be picked up by the serializer. Without this call
// the serializer would default to the null class loader, and fail to find Spark classes
// See SPARK-10986.
Thread.currentThread().setContextClassLoader(this.getClass.getClassLoader)

val properties = Utils.deserialize[Array[(String, String)]](executorInfo.getData.toByteArray) ++
Seq[(String, String)](("spark.app.id", frameworkInfo.getId.getValue))
val conf = new SparkConf(loadDefaults = true).setAll(properties)
Expand Down

0 comments on commit 0451b00

Please sign in to comment.