kfaraz commented on code in PR #16334:
URL: https://github.com/apache/druid/pull/16334#discussion_r1581995450
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScaler.java:
##########
@@ -154,8 +156,17 @@ private Runnable computeAndCollectLag()
LOCK.lock();
try {
if (!spec.isSuspended()) {
- long lag = supervisor.computeLagForAutoScaler();
- lagMetricsQueue.offer(lag > 0 ? lag : 0L);
+ LagStats lagStats = supervisor.computeLagStats();
+
+ if (lagStats != null) {
+ AggregateFunction aggregate =
lagBasedAutoScalerConfig.getLagAggregate() == null ?
Review Comment:
Looking at the constructor of `LagBasedAutoScalerConfig`, it seems that
`getLagAggregate()` will never return null. So, we will never use
lagStats.getAggregateForScaling().
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -186,6 +190,12 @@ public long getMinTriggerScaleActionFrequencyMillis()
return minTriggerScaleActionFrequencyMillis;
}
+ @JsonProperty
+ public AggregateFunction getLagAggregate()
Review Comment:
This should be `@Nullable`.
##########
indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/SeekableStreamSupervisorSpecTest.java:
##########
@@ -1336,6 +1336,7 @@ private static Map<String, Object>
getScaleOutProperties(int maxTaskCount)
autoScalerConfig.put("scaleInStep", 1);
autoScalerConfig.put("scaleOutStep", 2);
autoScalerConfig.put("minTriggerScaleActionFrequencyMillis", 1200000);
+ autoScalerConfig.put("lagStatsType", "MAX");
Review Comment:
Parameter name needs to be fixed. Also, are we just putting this value or
also verifying its effect somewhere?
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -73,6 +76,7 @@ public LagBasedAutoScalerConfig(
this.scaleInThreshold = scaleInThreshold != null ? scaleInThreshold :
1000000;
this.triggerScaleOutFractionThreshold = triggerScaleOutFractionThreshold
!= null ? triggerScaleOutFractionThreshold : 0.3;
this.triggerScaleInFractionThreshold = triggerScaleInFractionThreshold !=
null ? triggerScaleInFractionThreshold : 0.9;
+ this.lagAggregate = lagAggregate != null ? lagAggregate :
AggregateFunction.SUM;
Review Comment:
We should probably not assign a default value here. Otherwise, we will never
get to use the `LagStats.getAggregateForScaling()` as specified by each
individual supervisor.
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -204,6 +214,7 @@ public String toString()
", scaleActionPeriodMillis=" + scaleActionPeriodMillis +
", scaleInStep=" + scaleInStep +
", scaleOutStep=" + scaleOutStep +
+ ", lagAggregate=" + lagAggregate +
Review Comment:
indentation seems a little off.
##########
server/src/main/java/org/apache/druid/indexing/overlord/supervisor/autoscaler/AggregateFunction.java:
##########
@@ -0,0 +1,27 @@
+/*
+ * 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.supervisor.autoscaler;
+
+public enum AggregateFunction
+{
+ MAX,
+ SUM,
+ AVG
Review Comment:
Using the same name as mentioned in the docs:
```suggestion
AVERAGE
```
--
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]