Github user vanzin commented on a diff in the pull request:
https://github.com/apache/spark/pull/5311#discussion_r27591780
--- Diff:
core/src/main/scala/org/apache/spark/ExecutorAllocationManager.scala ---
@@ -173,32 +179,24 @@ private[spark] class ExecutorAllocationManager(
}
/**
- * Register for scheduler callbacks to decide when to add and remove
executors.
+ * Register for scheduler callbacks to decide when to add and remove
executors, and start
+ * the scheduling task.
*/
def start(): Unit = {
listenerBus.addListener(listener)
- startPolling()
+
+ val scheduleTask = new Runnable() {
+ override def run(): Unit = Utils.logUncaughtExceptions(schedule())
+ }
+ executor.scheduleAtFixedRate(scheduleTask, 0, intervalMillis,
TimeUnit.MILLISECONDS)
}
/**
- * Start the main polling thread that keeps track of when to add and
remove executors.
+ * Stop the allocation manager.
*/
- private def startPolling(): Unit = {
- val t = new Thread {
- override def run(): Unit = {
- while (true) {
- try {
- schedule()
- } catch {
- case e: Exception => logError("Exception in dynamic executor
allocation thread!", e)
- }
- Thread.sleep(intervalMillis)
- }
- }
- }
- t.setName("spark-dynamic-executor-allocation")
- t.setDaemon(true)
- t.start()
+ def stop(): Unit = {
+ executor.shutdown()
+ executor.awaitTermination(10, TimeUnit.SECONDS)
--- End diff --
I tried to follow the order of initialization during shutdown (the alloc
manager is started after the event logger so should be stopped right before it
- yeah, I know my code doesn't do exactly that).
But we could move the stop before the scheduler's stop.
---
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]