kfaraz commented on code in PR #14581:
URL: https://github.com/apache/druid/pull/14581#discussion_r1265109748
##########
indexing-service/src/main/java/org/apache/druid/indexing/worker/WorkerTaskManager.java:
##########
@@ -502,51 +501,51 @@ private void scheduleCompletedTasksCleanup()
}
ImmutableSet<String> taskIds =
ImmutableSet.copyOf(completedTasks.keySet());
- Map<String, TaskStatus> taskStatusesFromOverlord = null;
+ Either<Throwable, Map<String, TaskStatus>> apiCallResult = null;
try {
- StringFullResponseHolder fullResponseHolder = overlordClient.go(
- overlordClient.makeRequest(HttpMethod.POST,
"/druid/indexer/v1/taskStatus")
-
.setContent(jsonMapper.writeValueAsBytes(taskIds))
- .addHeader(HttpHeaders.Names.ACCEPT,
MediaType.APPLICATION_JSON)
- .addHeader(HttpHeaders.Names.CONTENT_TYPE,
MediaType.APPLICATION_JSON)
-
- );
- if (fullResponseHolder.getStatus().getCode() == 200) {
- String responseContent = fullResponseHolder.getContent();
- taskStatusesFromOverlord = jsonMapper.readValue(
- responseContent,
- new TypeReference<Map<String, TaskStatus>>()
- {
- }
- );
- log.debug("Received completed task status response [%s].",
responseContent);
- } else if (fullResponseHolder.getStatus().getCode() == 404) {
- // NOTE: this is to support backward compatibility, when
overlord doesn't have "activeTasks" endpoint.
- // this if clause should be removed in a future release.
- log.debug("Deleting all completed tasks. Overlord appears to
be running on older version.");
- taskStatusesFromOverlord = ImmutableMap.of();
+ apiCallResult =
+
Either.value(FutureUtils.get(overlordClient.taskStatuses(taskIds), true));
+ log.debug("Received completed task status response [%s].",
apiCallResult);
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ catch (ExecutionException e) {
+ if (e.getCause() instanceof HttpResponseException) {
+ final HttpResponseStatus status = ((HttpResponseException)
e.getCause()).getResponse().getStatus();
+ if (status.getCode() == 404) {
+ // NOTE: this is to support backward compatibility, when
overlord doesn't have "activeTasks" endpoint.
+ // this if clause should be removed in a future release.
+ log.debug("Deleting all completed tasks. Overlord appears to
be running on older version.");
+ apiCallResult = Either.value(ImmutableMap.of());
+ } else {
+ log.info(
+ "Got non-success code[%s] from overlord while getting
active tasks. will retry on next scheduled run.",
Review Comment:
Nit
```suggestion
"Got non-success code[%d] from overlord while getting
active tasks. Will retry on next scheduled run.",
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]