suneet-s commented on a change in pull request #12228:
URL: https://github.com/apache/druid/pull/12228#discussion_r799678733



##########
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:
       This assumes all nodes have the same capacity, but if you set up 
different tiers of workers this may not be the case.
   
   Do we need to look at the actual worker capacity? ~~It seems strange that 
we're making a call to the `autoScaleConfig` API when it may not be used 
because when `workers` is empty. Perhaps the order of operations needs to 
change~~
   
   EDIT: autoScaleConfig is being used. I misread.




-- 
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]

Reply via email to