[improvement](spark-connector) Stream load http exception handling (#7514)
Stream load http exception handling
This commit is contained in:
@ -157,10 +157,10 @@ public class DorisStreamLoad implements Serializable{
|
||||
public void load(String value) throws StreamLoadException {
|
||||
LOG.debug("Streamload Request:{} ,Body:{}", loadUrlStr, value);
|
||||
LoadResponse loadResponse = loadBatch(value);
|
||||
LOG.info("Streamload Response:{}",loadResponse);
|
||||
if(loadResponse.status != 200){
|
||||
throw new StreamLoadException("stream load error: " + loadResponse.respContent);
|
||||
}else{
|
||||
LOG.info("Streamload Response:{}",loadResponse);
|
||||
ObjectMapper obj = new ObjectMapper();
|
||||
try {
|
||||
RespContent respContent = obj.readValue(loadResponse.respContent, RespContent.class);
|
||||
@ -182,6 +182,7 @@ public class DorisStreamLoad implements Serializable{
|
||||
|
||||
HttpURLConnection feConn = null;
|
||||
HttpURLConnection beConn = null;
|
||||
int status = -1;
|
||||
try {
|
||||
// build request and send to new be location
|
||||
beConn = getConnection(loadUrlStr, label);
|
||||
@ -191,7 +192,7 @@ public class DorisStreamLoad implements Serializable{
|
||||
bos.close();
|
||||
|
||||
// get respond
|
||||
int status = beConn.getResponseCode();
|
||||
status = beConn.getResponseCode();
|
||||
String respMsg = beConn.getResponseMessage();
|
||||
InputStream stream = (InputStream) beConn.getContent();
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(stream));
|
||||
@ -204,9 +205,9 @@ public class DorisStreamLoad implements Serializable{
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
String err = "failed to execute spark streamload with label: " + label;
|
||||
String err = "http request exception,load url : "+loadUrlStr+",failed to execute spark streamload with label: " + label;
|
||||
LOG.warn(err, e);
|
||||
return new LoadResponse(-1, e.getMessage(), err);
|
||||
return new LoadResponse(status, e.getMessage(), err);
|
||||
} finally {
|
||||
if (feConn != null) {
|
||||
feConn.disconnect();
|
||||
|
||||
Reference in New Issue
Block a user