Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/5116#discussion_r27709010
--- Diff:
core/src/main/scala/org/apache/spark/deploy/rest/StandaloneRestClient.scala ---
@@ -62,45 +67,94 @@ private[deploy] class StandaloneRestClient extends
Logging {
* it to the user. Otherwise, report the error message provided by the
server.
*/
private[rest] def createSubmission(
- master: String,
request: CreateSubmissionRequest): SubmitRestProtocolResponse = {
logInfo(s"Submitting a request to launch an application in $master.")
- validateMaster(master)
- val url = getSubmitUrl(master)
- val response = postJson(url, request.toJson)
- response match {
- case s: CreateSubmissionResponse =>
- reportSubmissionStatus(master, s)
- handleRestResponse(s)
- case unexpected =>
- handleUnexpectedRestResponse(unexpected)
+ var suc: Boolean = false
+ var response: SubmitRestProtocolResponse = null
+ for (m <- masters if !suc) {
+ validateMaster(m)
+ val url = getSubmitUrl(m)
+ try {
+ response = postJson(url, request.toJson)
+ response match {
+ case s: CreateSubmissionResponse =>
+ if (s.success) {
+ reportSubmissionStatus(s)
+ handleRestResponse(s)
+ suc = true
+ }
+ case unexpected =>
+ handleUnexpectedRestResponse(unexpected)
+ }
+ } catch {
+ case e @ (_: SubmitRestConnectionException | _: ConnectException)
=>
+ if(handleSubmitRestConnectionException(m)) {
+ throw new SubmitRestConnectionException(
+ "No master is available for createSubmission.", new
Throwable(""))
+ }
+ }
}
response
}
/** Request that the server kill the specified submission. */
- def killSubmission(master: String, submissionId: String):
SubmitRestProtocolResponse = {
+ def killSubmission(submissionId: String): SubmitRestProtocolResponse = {
logInfo(s"Submitting a request to kill submission $submissionId in
$master.")
- validateMaster(master)
- val response = post(getKillUrl(master, submissionId))
- response match {
- case k: KillSubmissionResponse => handleRestResponse(k)
- case unexpected => handleUnexpectedRestResponse(unexpected)
+ var suc: Boolean = false
+ var response: SubmitRestProtocolResponse = null
+ for (m <- masters if !suc) {
+ validateMaster(m)
+ val url = getKillUrl(m, submissionId)
+ try {
+ response = post(url)
+ response match {
+ case k: KillSubmissionResponse =>
+ if (!k.message.contains("Can only")) {
+ handleRestResponse(k)
+ suc = true
+ }
+ case unexpected =>
+ handleUnexpectedRestResponse(unexpected)
+ }
+ } catch {
+ case e @ (_: SubmitRestConnectionException | _: ConnectException)
=>
+ if(handleSubmitRestConnectionException(m)) {
--- End diff --
space after `if`
---
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]