This commit is contained in:
parent
416540754c
commit
44a5fb2e6d
1 changed files with 25 additions and 7 deletions
|
|
@ -248,7 +248,8 @@ public class SignalRestService {
|
||||||
|
|
||||||
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(headers);
|
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(headers);
|
||||||
|
|
||||||
ResponseEntity<String> response = restTemplate.exchange(
|
ResponseEntity<String> response = exchangeWithTiming(
|
||||||
|
"onlinereport",
|
||||||
url,
|
url,
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
requestEntity,
|
requestEntity,
|
||||||
|
|
@ -283,12 +284,12 @@ public class SignalRestService {
|
||||||
|
|
||||||
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(headers);
|
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(headers);
|
||||||
|
|
||||||
ResponseEntity<byte[]> response = restTemplate.exchange(
|
ResponseEntity<byte[]> response = exchangeWithTiming(
|
||||||
url,
|
"onlinedownload",
|
||||||
HttpMethod.GET,
|
url,
|
||||||
requestEntity,
|
HttpMethod.GET,
|
||||||
byte[].class
|
requestEntity,
|
||||||
);
|
byte[].class);
|
||||||
Path targetFilePathWithExt = null;
|
Path targetFilePathWithExt = null;
|
||||||
if (response.getHeaders().getContentType().equals(MEDIA_TYPE_GZIP)) {
|
if (response.getHeaders().getContentType().equals(MEDIA_TYPE_GZIP)) {
|
||||||
Path folder = Path.of(config.getLoadDir(),
|
Path folder = Path.of(config.getLoadDir(),
|
||||||
|
|
@ -333,4 +334,21 @@ public class SignalRestService {
|
||||||
return "unknown error";
|
return "unknown error";
|
||||||
return "%s: %s".formatted(response.getError().getName(), response.getError().getDescription());
|
return "%s: %s".formatted(response.getError().getName(), response.getError().getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private <T> ResponseEntity<T> exchangeWithTiming(
|
||||||
|
String name,
|
||||||
|
String url,
|
||||||
|
HttpMethod method,
|
||||||
|
HttpEntity<?> requestEntity,
|
||||||
|
Class<T> responseType
|
||||||
|
) {
|
||||||
|
long start = System.nanoTime();
|
||||||
|
|
||||||
|
try {
|
||||||
|
return restTemplate.exchange(url, method, requestEntity, responseType);
|
||||||
|
} finally {
|
||||||
|
long durationMs = (System.nanoTime() - start) / 1_000_000;
|
||||||
|
log.info("REST [{}] {} {} took {} ms", name, method, url, durationMs);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue