@@ -33,12 +33,18 @@ import org.apache.spark.deploy.SparkSubmitArguments
3333 * currently used for cluster mode only.
3434 *
3535 * The specific request sent to the server depends on the action as follows:
36- * (1) submit - POST to http://... /submissions/create
37- * (2) kill - POST http://... /submissions/kill/[submissionId]
38- * (3) status - GET http://... /submissions/status/[submissionId]
36+ * (1) submit - POST to /submissions/create
37+ * (2) kill - POST /submissions/kill/[submissionId]
38+ * (3) status - GET /submissions/status/[submissionId]
3939 *
4040 * In the case of (1), parameters are posted in the HTTP body in the form of JSON fields.
4141 * Otherwise, the URL fully specifies the intended action of the client.
42+ *
43+ * Additionally, the base URL includes the version of the protocol. For instance:
44+ * http://1.2.3.4:6066/v1/submissions/create. Since the protocol is expected to be stable
45+ * across Spark versions, existing fields cannot be added or removed. In the rare event that
46+ * backward compatibility is broken, Spark must introduce a new protocol version (e.g. v2).
47+ * The client and the server must communicate on the same version of the protocol.
4248 */
4349private [spark] class StandaloneRestClient extends Logging {
4450 import StandaloneRestClient ._
@@ -147,20 +153,25 @@ private[spark] class StandaloneRestClient extends Logging {
147153
148154 /** Return the REST URL for creating a new submission. */
149155 private def getSubmitUrl (master : String ): URL = {
150- val baseUrl = master.stripPrefix( " spark:// " )
151- new URL (s " http:// $baseUrl/submissions/create " )
156+ val baseUrl = getBaseUrl(master )
157+ new URL (s " $baseUrl/submissions/create " )
152158 }
153159
154160 /** Return the REST URL for killing an existing submission. */
155161 private def getKillUrl (master : String , submissionId : String ): URL = {
156- val baseUrl = master.stripPrefix( " spark:// " )
157- new URL (s " http:// $baseUrl/submissions/kill/ $submissionId" )
162+ val baseUrl = getBaseUrl(master )
163+ new URL (s " $baseUrl/submissions/kill/ $submissionId" )
158164 }
159165
160166 /** Return the REST URL for requesting the status of an existing submission. */
161167 private def getStatusUrl (master : String , submissionId : String ): URL = {
162- val baseUrl = master.stripPrefix(" spark://" )
163- new URL (s " http:// $baseUrl/submissions/status/ $submissionId" )
168+ val baseUrl = getBaseUrl(master)
169+ new URL (s " $baseUrl/submissions/status/ $submissionId" )
170+ }
171+
172+ /** Return the base URL for communicating with the server, including the protocol version. */
173+ private def getBaseUrl (master : String ): String = {
174+ " http://" + master.stripPrefix(" spark://" ).stripSuffix(" /" ) + " /" + PROTOCOL_VERSION
164175 }
165176
166177 /** Throw an exception if this is not standalone mode. */
@@ -261,4 +272,5 @@ private[spark] class StandaloneRestClient extends Logging {
261272private object StandaloneRestClient {
262273 val REPORT_DRIVER_STATUS_INTERVAL = 1000
263274 val REPORT_DRIVER_STATUS_MAX_TRIES = 10
275+ val PROTOCOL_VERSION = " v1"
264276}
0 commit comments