This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-doris-spark-connector.git
commit 040b959c482ff99920043cd9190d1c2a12445e68 Author: jiafeng.zhang <zhang...@gmail.com> AuthorDate: Sun Jan 9 16:54:55 2022 +0800 [improvement](spark-connector) Stream load http exception handling (#7514) Stream load http exception handling --- src/main/java/org/apache/doris/spark/DorisStreamLoad.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/doris/spark/DorisStreamLoad.java b/src/main/java/org/apache/doris/spark/DorisStreamLoad.java index 4411fbc..dd7e48c 100644 --- a/src/main/java/org/apache/doris/spark/DorisStreamLoad.java +++ b/src/main/java/org/apache/doris/spark/DorisStreamLoad.java @@ -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(); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org