in ecosystem/executor/http/src/main/java/org/apache/shardingsphere/elasticjob/http/executor/HttpJobExecutor.java [48:82]
public void process(final ElasticJob elasticJob, final JobConfiguration jobConfig, final JobRuntimeService jobRuntimeService, final ShardingContext shardingContext) {
HttpParam httpParam = new HttpParam(jobConfig.getProps());
HttpURLConnection connection = null;
try {
connection = getHttpURLConnection(httpParam, shardingContext);
connection.connect();
String data = httpParam.getData();
if (httpParam.isWriteMethod() && !Strings.isNullOrEmpty(data)) {
try (OutputStream outputStream = connection.getOutputStream()) {
outputStream.write(data.getBytes(StandardCharsets.UTF_8));
}
}
int responseCode = connection.getResponseCode();
StringBuilder result = new StringBuilder();
try (
InputStream inputStream = getConnectionInputStream(jobConfig.getJobName(), connection, responseCode);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
String line;
while (null != (line = bufferedReader.readLine())) {
result.append(line);
}
}
if (isRequestSucceed(responseCode)) {
log.debug("HTTP job execute result : {}", result);
} else {
log.warn("HTTP job {} executed with response body {}", jobConfig.getJobName(), result);
}
} catch (final IOException ex) {
throw new JobExecutionException(ex);
} finally {
if (null != connection) {
connection.disconnect();
}
}
}