suneet-s commented on a change in pull request #12228:
URL: https://github.com/apache/druid/pull/12228#discussion_r800222806
##########
File path:
server/src/main/java/org/apache/druid/client/indexing/HttpIndexingServiceClient.java
##########
@@ -194,26 +194,39 @@ public String cancelTask(String taskId)
@Override
public int getTotalWorkerCapacity()
+ {
+ return getWorkers().stream().mapToInt(workerInfo ->
workerInfo.getWorker().getCapacity()).sum();
+ }
+
+ @Override
+ public int getTotalWorkerCapacityWithAutoScale()
{
try {
final StringFullResponseHolder response = druidLeaderClient.go(
- druidLeaderClient.makeRequest(HttpMethod.GET,
"/druid/indexer/v1/workers")
+ druidLeaderClient.makeRequest(HttpMethod.GET,
"/druid/indexer/v1/autoScaleConfig")
.setHeader("Content-Type",
MediaType.APPLICATION_JSON)
);
-
if (!response.getStatus().equals(HttpResponseStatus.OK)) {
throw new ISE(
- "Error while getting available cluster capacity. status[%s]
content[%s]",
+ "Error while getting worker info. status[%s] content[%s]",
response.getStatus(),
response.getContent()
);
}
- final Collection<IndexingWorkerInfo> workers = jsonMapper.readValue(
+ final IndexingAutoScaleConfigInfo indexingAutoScaleConfigInfo =
jsonMapper.readValue(
response.getContent(),
- new TypeReference<Collection<IndexingWorkerInfo>>() {}
+ new TypeReference<IndexingAutoScaleConfigInfo>() {}
);
-
- return workers.stream().mapToInt(workerInfo ->
workerInfo.getWorker().getCapacity()).sum();
+ Collection<IndexingWorkerInfo> workers = getWorkers();
+ int capacityPerWorker;
+ if (workers != null && !workers.isEmpty()) {
+ capacityPerWorker =
workers.stream().findFirst().get().getWorker().getCapacity();
Review comment:
Thanks for this refactor, it's a lot cleaner and easier to follow!
--
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]