@@ -90,10 +90,9 @@ private[deploy] class StandaloneRestClient(master: String) extends Logging {
90
90
handleUnexpectedRestResponse(unexpected)
91
91
}
92
92
} catch {
93
- case unreachable @ ( _ : FileNotFoundException | _ : SocketException | _ : ConnectException ) =>
93
+ case e : SubmitRestConnectionException =>
94
94
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)
97
96
}
98
97
}
99
98
}
@@ -120,10 +119,9 @@ private[deploy] class StandaloneRestClient(master: String) extends Logging {
120
119
handleUnexpectedRestResponse(unexpected)
121
120
}
122
121
} catch {
123
- case unreachable @ ( _ : FileNotFoundException | _ : SocketException | _ : ConnectException ) =>
122
+ case e : SubmitRestConnectionException =>
124
123
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)
127
125
}
128
126
}
129
127
}
@@ -135,6 +133,7 @@ private[deploy] class StandaloneRestClient(master: String) extends Logging {
135
133
submissionId : String ,
136
134
quiet : Boolean = false ): SubmitRestProtocolResponse = {
137
135
logInfo(s " Submitting a request for the status of submission $submissionId in $master. " )
136
+
138
137
var handled : Boolean = false
139
138
var response : SubmitRestProtocolResponse = null
140
139
for (m <- masters if ! handled) {
@@ -152,10 +151,9 @@ private[deploy] class StandaloneRestClient(master: String) extends Logging {
152
151
handleUnexpectedRestResponse(unexpected)
153
152
}
154
153
} catch {
155
- case unreachable @ ( _ : FileNotFoundException | _ : SocketException | _ : ConnectException ) =>
154
+ case e : SubmitRestConnectionException =>
156
155
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)
159
157
}
160
158
}
161
159
}
@@ -204,11 +202,16 @@ private[deploy] class StandaloneRestClient(master: String) extends Logging {
204
202
conn.setRequestProperty(" Content-Type" , " application/json" )
205
203
conn.setRequestProperty(" charset" , " utf-8" )
206
204
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)
212
215
}
213
216
readResponse(conn)
214
217
}
@@ -246,6 +249,8 @@ private[deploy] class StandaloneRestClient(master: String) extends Logging {
246
249
s " Message received from server was not a response: \n ${unexpected.toJson}" )
247
250
}
248
251
} catch {
252
+ case unreachable @ (_ : FileNotFoundException | _ : SocketException ) =>
253
+ throw new SubmitRestConnectionException (" Unable to connect to server" , unreachable)
249
254
case malformed @ (_ : JsonProcessingException | _ : SubmitRestProtocolException ) =>
250
255
throw new SubmitRestProtocolException (" Malformed response received from server" , malformed)
251
256
}
0 commit comments