Github user ueshin commented on the pull request:

    https://github.com/apache/spark/pull/322#issuecomment-39560562
  
    @manku-timma, I just wondered that we should restore the class loader in 
`registered` method like:
    
    ```scala
    val cl = Thread.currentThread.getContextClassLoader
    try {
      Thread.currentThread.setContextClassLoader(getClass.getClassLoader)
      logInfo("Registered with Mesos as executor ID " + 
executorInfo.getExecutorId.getValue)
      this.driver = driver
      val properties = Utils.deserialize[Array[(String, 
String)]](executorInfo.getData.toByteArray)
      executor = new Executor(
        executorInfo.getExecutorId.getValue,
        slaveInfo.getHostname,
        properties)
    } finally {
      Thread.currentThread.setContextClassLoader(cl)
    }
    ```
    
    I think this is better than before.
    
    The http based class loader for `TaskRunner` is correctly set at [this 
point](https://github.com/manku-timma/spark-1/blob/89109d7bf2ce35e58a252bd7144438fc720ee362/core/src/main/scala/org/apache/spark/executor/Executor.scala#L180).
    
    The flow you wrote would be:
    
    - when `registered` method is called
      - `MesosExecutorBackend` starts off
      - `MesosExecutorBackend` sets classloader
      - `MesosExecutorBackend` creates `Executor`
      - `Executor` creates `SparkEnv`
      - `MesosExecutorBackend` restore classlaoder
    - when `launchTask` method is called
      - `MesosExecutorBackend` calls `Executor.launchTask` method
      - `Executor` creates `TaskRunner`
      - `Executor` submits the task runner
    - when the task runner is run
      - `TaskRunner` sets classloader to the http based one (so that later 
classes can be downloaded from the master)



---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to