@@ -90,10 +90,9 @@ private[deploy] class StandaloneRestClient(master: String) extends Logging {
9090 handleUnexpectedRestResponse(unexpected)
9191 }
9292 } catch {
93- case unreachable @ ( _ : FileNotFoundException | _ : SocketException | _ : ConnectException ) =>
93+ case e : SubmitRestConnectionException =>
9494 if (handleConnectionException(m)) {
95- throw new SubmitRestConnectionException (
96- s " Unable to connect to server " , unreachable)
95+ throw new SubmitRestConnectionException (" Unable to connect to server" , e)
9796 }
9897 }
9998 }
@@ -120,10 +119,9 @@ private[deploy] class StandaloneRestClient(master: String) extends Logging {
120119 handleUnexpectedRestResponse(unexpected)
121120 }
122121 } catch {
123- case unreachable @ ( _ : FileNotFoundException | _ : SocketException | _ : ConnectException ) =>
122+ case e : SubmitRestConnectionException =>
124123 if (handleConnectionException(m)) {
125- throw new SubmitRestConnectionException (
126- s " Unable to connect to server " , unreachable)
124+ throw new SubmitRestConnectionException (" Unable to connect to server" , e)
127125 }
128126 }
129127 }
@@ -135,6 +133,7 @@ private[deploy] class StandaloneRestClient(master: String) extends Logging {
135133 submissionId : String ,
136134 quiet : Boolean = false ): SubmitRestProtocolResponse = {
137135 logInfo(s " Submitting a request for the status of submission $submissionId in $master. " )
136+
138137 var handled : Boolean = false
139138 var response : SubmitRestProtocolResponse = null
140139 for (m <- masters if ! handled) {
@@ -152,10 +151,9 @@ private[deploy] class StandaloneRestClient(master: String) extends Logging {
152151 handleUnexpectedRestResponse(unexpected)
153152 }
154153 } catch {
155- case unreachable @ ( _ : FileNotFoundException | _ : SocketException | _ : ConnectException ) =>
154+ case e : SubmitRestConnectionException =>
156155 if (handleConnectionException(m)) {
157- throw new SubmitRestConnectionException (
158- s " Unable to connect to server " , unreachable)
156+ throw new SubmitRestConnectionException (" Unable to connect to server" , e)
159157 }
160158 }
161159 }
@@ -204,11 +202,16 @@ private[deploy] class StandaloneRestClient(master: String) extends Logging {
204202 conn.setRequestProperty(" Content-Type" , " application/json" )
205203 conn.setRequestProperty(" charset" , " utf-8" )
206204 conn.setDoOutput(true )
207- val out = new DataOutputStream (conn.getOutputStream)
208- Utils .tryWithSafeFinally {
209- out.write(json.getBytes(Charsets .UTF_8 ))
210- } {
211- out.close()
205+ try {
206+ val out = new DataOutputStream (conn.getOutputStream)
207+ Utils .tryWithSafeFinally {
208+ out.write(json.getBytes(Charsets .UTF_8 ))
209+ } {
210+ out.close()
211+ }
212+ } catch {
213+ case e : ConnectException =>
214+ throw new SubmitRestConnectionException (" Connect Exception when connect to server" , e)
212215 }
213216 readResponse(conn)
214217 }
@@ -246,6 +249,8 @@ private[deploy] class StandaloneRestClient(master: String) extends Logging {
246249 s " Message received from server was not a response: \n ${unexpected.toJson}" )
247250 }
248251 } catch {
252+ case unreachable @ (_ : FileNotFoundException | _ : SocketException ) =>
253+ throw new SubmitRestConnectionException (" Unable to connect to server" , unreachable)
249254 case malformed @ (_ : JsonProcessingException | _ : SubmitRestProtocolException ) =>
250255 throw new SubmitRestProtocolException (" Malformed response received from server" , malformed)
251256 }
0 commit comments