|
18 | 18 | package org.apache.spark.executor |
19 | 19 |
|
20 | 20 | import java.nio.ByteBuffer |
| 21 | +import java.util.concurrent.TimeUnit |
| 22 | + |
| 23 | +import scala.concurrent.Await |
21 | 24 |
|
22 | 25 | import akka.actor._ |
23 | 26 | import akka.remote._ |
| 27 | +import akka.pattern.Patterns |
| 28 | +import akka.util.Timeout |
24 | 29 |
|
25 | 30 | import org.apache.spark.{SparkEnv, Logging, SecurityManager, SparkConf} |
26 | 31 | import org.apache.spark.TaskState.TaskState |
@@ -101,26 +106,33 @@ private[spark] object CoarseGrainedExecutorBackend { |
101 | 106 | workerUrl: Option[String]) { |
102 | 107 |
|
103 | 108 | SparkHadoopUtil.get.runAsSparkUser { () => |
104 | | - // Debug code |
105 | | - Utils.checkHost(hostname) |
106 | | - |
107 | | - val conf = new SparkConf |
108 | | - // Create a new ActorSystem to run the backend, because we can't create a |
109 | | - // SparkEnv / Executor before getting started with all our system properties, etc |
110 | | - val (actorSystem, boundPort) = AkkaUtils.createActorSystem("sparkExecutor", hostname, 0, |
111 | | - conf, new SecurityManager(conf)) |
112 | | - // set it |
113 | | - val sparkHostPort = hostname + ":" + boundPort |
114 | | - actorSystem.actorOf( |
115 | | - Props(classOf[CoarseGrainedExecutorBackend], driverUrl, executorId, |
116 | | - sparkHostPort, cores), |
117 | | - name = "Executor") |
118 | | - workerUrl.foreach { |
119 | | - url => |
120 | | - actorSystem.actorOf(Props(classOf[WorkerWatcher], url), name = "WorkerWatcher") |
121 | | - } |
122 | | - actorSystem.awaitTermination() |
123 | | - |
| 109 | + // Debug code |
| 110 | + Utils.checkHost(hostname) |
| 111 | + |
| 112 | + // Bootstrap to fetch the driver's Spark properties. |
| 113 | + val executorConf = new SparkConf |
| 114 | + val (fetcher, _) = AkkaUtils.createActorSystem( |
| 115 | + "driverConfFetcher", hostname, 0, executorConf, new SecurityManager(executorConf)) |
| 116 | + val driver = fetcher.actorSelection(driverUrl) |
| 117 | + val timeout = new Timeout(5, TimeUnit.MINUTES) |
| 118 | + val fut = Patterns.ask(driver, RetrieveSparkProps, timeout) |
| 119 | + val props = Await.result(fut, timeout.duration).asInstanceOf[Seq[(String, String)]] |
| 120 | + fetcher.shutdown() |
| 121 | + |
| 122 | + // Create a new ActorSystem to run the backend, because we can't create a |
| 123 | + // SparkEnv / Executor before getting started with all our system properties, etc |
| 124 | + val driverConf = new SparkConf().setAll(props) |
| 125 | + val (actorSystem, boundPort) = AkkaUtils.createActorSystem( |
| 126 | + "sparkExecutor", hostname, 0, driverConf, new SecurityManager(driverConf)) |
| 127 | + // set it |
| 128 | + val sparkHostPort = hostname + ":" + boundPort |
| 129 | + actorSystem.actorOf( |
| 130 | + Props(classOf[CoarseGrainedExecutorBackend], driverUrl, executorId, sparkHostPort, cores), |
| 131 | + name = "Executor") |
| 132 | + workerUrl.foreach { url => |
| 133 | + actorSystem.actorOf(Props(classOf[WorkerWatcher], url), name = "WorkerWatcher") |
| 134 | + } |
| 135 | + actorSystem.awaitTermination() |
124 | 136 | } |
125 | 137 | } |
126 | 138 |
|
|
0 commit comments