Skip to content

Commit

Permalink
Add checks for enabling REST when using kill/status
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Or committed Jan 30, 2015
1 parent 7ee6737 commit bf696ff
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ private[spark] class SparkSubmitArguments(args: Seq[String], env: Map[String, St
var driverToKill: String = null
var driverToRequestStatusFor: String = null

private val restEnabledKey = "spark.submit.rest.enabled"

def action: SparkSubmitAction = {
(driverToKill, driverToRequestStatusFor) match {
case (null, null) => SparkSubmitAction.SUBMIT
Expand Down Expand Up @@ -237,6 +239,10 @@ private[spark] class SparkSubmitArguments(args: Seq[String], env: Map[String, St
if (!isStandaloneCluster) {
SparkSubmit.printErrorAndExit("Killing drivers is only supported in standalone cluster mode")
}
if (!isRestEnabled) {
SparkSubmit.printErrorAndExit("Killing drivers is currently only supported " +
s"through the REST interface. Please set $restEnabledKey to true.")
}
if (driverToKill == null) {
SparkSubmit.printErrorAndExit("Please specify a driver to kill")
}
Expand All @@ -247,6 +253,10 @@ private[spark] class SparkSubmitArguments(args: Seq[String], env: Map[String, St
SparkSubmit.printErrorAndExit(
"Requesting driver statuses is only supported in standalone cluster mode")
}
if (!isRestEnabled) {
SparkSubmit.printErrorAndExit("Requesting driver statuses is currently only " +
s"supported through the REST interface. Please set $restEnabledKey to true.")
}
if (driverToRequestStatusFor == null) {
SparkSubmit.printErrorAndExit("Please specify a driver to request status for")
}
Expand All @@ -258,7 +268,7 @@ private[spark] class SparkSubmitArguments(args: Seq[String], env: Map[String, St

/** Return whether the REST application submission protocol is enabled. */
def isRestEnabled: Boolean = {
sparkProperties.get("spark.submit.rest.enabled").getOrElse("false").toBoolean
sparkProperties.get(restEnabledKey).getOrElse("false").toBoolean
}

override def toString = {
Expand Down

0 comments on commit bf696ff

Please sign in to comment.