Skip to content

Commit 5bedcb8

Browse files
committed
Remove assert in SparkContext.killExecutors
1 parent a858fb5 commit 5bedcb8

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

core/src/main/scala/org/apache/spark/HeartbeatReceiver.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private[spark] class HeartbeatReceiver(sc: SparkContext, scheduler: TaskSchedule
6161
import context.dispatcher
6262
timeoutCheckingTask = context.system.scheduler.schedule(0.seconds,
6363
checkTimeoutInterval.milliseconds, self, ExpireDeadHosts)
64-
super.preStart
64+
super.preStart()
6565
}
6666

6767
override def receiveWithLogging = {
@@ -80,8 +80,8 @@ private[spark] class HeartbeatReceiver(sc: SparkContext, scheduler: TaskSchedule
8080
val minSeenTime = now - executorTimeout
8181
for ((executorId, lastSeenMs) <- executorLastSeen) {
8282
if (lastSeenMs < minSeenTime) {
83-
logWarning("Removing Executor " + executorId + " with no recent heartbeats: "
84-
+ (now - lastSeenMs) + " ms exceeds " + executorTimeout + "ms")
83+
logWarning(s"Removing executor $executorId with no recent heartbeats: " +
84+
s"${now - lastSeenMs} ms exceeds timeout $executorTimeout ms")
8585
scheduler.executorLost(executorId, SlaveLost())
8686
sc.killExecutor(executorId)
8787
executorLastSeen.remove(executorId)

core/src/main/scala/org/apache/spark/SparkContext.scala

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,14 +1069,17 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli
10691069
*/
10701070
@DeveloperApi
10711071
override def killExecutors(executorIds: Seq[String]): Boolean = {
1072-
assert(master.contains("yarn") || dynamicAllocationTesting,
1073-
"Killing executors is currently only supported in YARN mode")
1074-
schedulerBackend match {
1075-
case b: CoarseGrainedSchedulerBackend =>
1076-
b.killExecutors(executorIds)
1077-
case _ =>
1078-
logWarning("Killing executors is only supported in coarse-grained mode")
1079-
false
1072+
if (master.contains("yarn") || dynamicAllocationTesting) {
1073+
schedulerBackend match {
1074+
case b: CoarseGrainedSchedulerBackend =>
1075+
b.killExecutors(executorIds)
1076+
case _ =>
1077+
logWarning("Killing executors is only supported in coarse-grained mode")
1078+
false
1079+
}
1080+
} else {
1081+
logWarning("Killing executors is currently only supported in YARN mode")
1082+
false
10801083
}
10811084
}
10821085

0 commit comments

Comments
 (0)