Github user zsxwing commented on a diff in the pull request:
https://github.com/apache/spark/pull/8946#discussion_r40806449
--- Diff: core/src/main/scala/org/apache/spark/HeartbeatReceiver.scala ---
@@ -148,10 +154,30 @@ private[spark] class HeartbeatReceiver(sc:
SparkContext, clock: Clock)
}
/**
+ * Send ExecutorRegistered to the event loop to add a new executor. Only
for test.
+ *
+ * @return if HeartbeatReceiver is stopped, return None. Otherwise,
return a Some(Future) that
+ * indicate if this operation is successful.
+ */
+ def addExecutor(executorId: String): Option[Future[Boolean]] = {
+ Option(self).map(_.ask[Boolean](ExecutorRegistered(executorId)))
+ }
+
+ /**
* If the heartbeat receiver is not stopped, notify it of executor
registrations.
*/
override def onExecutorAdded(executorAdded: SparkListenerExecutorAdded):
Unit = {
-
Option(self).foreach(_.ask[Boolean](ExecutorRegistered(executorAdded.executorId)))
+ addExecutor(executorAdded.executorId)
+ }
+
+ /**
+ * Send ExecutorRemoved to the event loop to remove a executor. Only for
test.
+ *
+ * @return if HeartbeatReceiver is stopped, return None. Otherwise,
return a Some(Future) that
+ * indicate if this operation is successful.
+ */
+ def removeExecutor(executorId: String): Option[Future[Boolean]] = {
--- End diff --
I need to use the `Future` result in the tests. However, because
`onExecutorAdded` and `onExecutorRemoved` are defined by the parent class, I
cannot make them return the `Future`. So I added these internal methods.
---
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]