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



##########
File path: 
indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/OverlordResource.java
##########
@@ -422,6 +428,37 @@ public Response getWorkerConfig()
     return Response.ok(workerConfigRef.get()).build();
   }
 
+  @GET
+  @Path("/autoScaleConfig")
+  @Produces(MediaType.APPLICATION_JSON)
+  @ResourceFilters(ConfigResourceFilter.class)
+  public Response getAutoScaleConfig()

Review comment:
       nit: Add docs for this new API

##########
File path: 
server/src/main/java/org/apache/druid/client/indexing/IndexingServiceClient.java
##########
@@ -51,6 +51,8 @@ String compactSegments(
 
   int getTotalWorkerCapacity();
 
+  int getTotalWorkerCapacityWithAutoScale();

Review comment:
       javadocs please.

##########
File path: 
indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/AutoScaleConfigResponse.java
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.indexing.overlord.http;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class AutoScaleConfigResponse
+{
+  private final int minNumWorkers;
+  private final int maxNumWorkers;
+  private final int workerCapacityHint;

Review comment:
       nit: javadocs since these are returned as part of the API response. For 
example, info on whether these numbers can be negative and what that means will 
be helpful.

##########
File path: 
indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/PendingTaskBasedWorkerProvisioningStrategy.java
##########
@@ -138,6 +138,11 @@ public PendingTaskBasedWorkerProvisioningStrategy(
     this.workerConfigRef = workerConfigRef;
   }
 
+  public PendingTaskBasedWorkerProvisioningConfig getConfig()

Review comment:
       nit: instead of exposing the config, I think we could add 
`getWorkerCapacityHint` to the `ProvisioningStrategy` interface. Then other 
implementations can return -1 and the logic in 
https://github.com/apache/druid/pull/12228/files#diff-5b7be8ae52437503c4b5f68537f77c3056bc05fae53e0a66928519a3e3e1e4c1R446-R448
 can be simplified

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




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