jtuglu1 commented on code in PR #19286:
URL: https://github.com/apache/druid/pull/19286#discussion_r3061276757


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisor.java:
##########
@@ -523,25 +523,51 @@ public void handle()
               return;
             }
           }
-          if (nowTime - dynamicTriggerLastRunTime < 
autoScalerConfig.getMinTriggerScaleActionFrequencyMillis()) {
-            log.info(
-                "DynamicAllocationTasksNotice submitted again in [%d] millis, 
minTriggerDynamicFrequency is [%s] for supervisor[%s] for dataSource[%s], 
skipping it! desired task count is [%s], active task count is [%s]",
-                nowTime - dynamicTriggerLastRunTime,
-                autoScalerConfig.getMinTriggerScaleActionFrequencyMillis(),
-                supervisorId,
-                dataSource,
-                desiredTaskCount,
-                getActiveTaskGroupsCount()
-            );
+          final int currentTaskCount = getCurrentTaskCount();
+          if (desiredTaskCount >= 0) {
+            final long lastRunTime;
+            final long effectiveFreq;
+
+            if (desiredTaskCount > currentTaskCount) {
+              // Scale up: use the scale-up specific frequency, falling back 
to base.
+              Long specificFreq = 
autoScalerConfig.getMinTriggerScaleUpActionFrequencyMillis();
+              effectiveFreq = specificFreq != null
+                  ? specificFreq
+                  : autoScalerConfig.getMinTriggerScaleActionFrequencyMillis();
+              lastRunTime = dynamicTriggerLastScaleUpRunTime;
+            } else if (desiredTaskCount < currentTaskCount) {
+              // Scale down: use the scale-down specific frequency, falling 
back to base.
+              Long specificFreq = 
autoScalerConfig.getMinTriggerScaleDownActionFrequencyMillis();
+              effectiveFreq = specificFreq != null
+                  ? specificFreq
+                  : autoScalerConfig.getMinTriggerScaleActionFrequencyMillis();
+              lastRunTime = dynamicTriggerLastScaleDownRunTime;
+            } else {
+              // No change (desired == current): apply base frequency using 
the most recent scale time.
+              effectiveFreq = 
autoScalerConfig.getMinTriggerScaleActionFrequencyMillis();
+              lastRunTime = Math.max(dynamicTriggerLastScaleUpRunTime, 
dynamicTriggerLastScaleDownRunTime);
+            }
 
-            if (desiredTaskCount > 0) {
-              emitter.emit(event.setDimension(
-                                    AUTOSCALER_SKIP_REASON_DIMENSION,
-                                    "minTriggerScaleActionFrequencyMillis not 
elapsed yet"
-                                )
-                                .setMetric(AUTOSCALER_REQUIRED_TASKS_METRIC, 
desiredTaskCount));
+            if (nowTime - lastRunTime < effectiveFreq) {
+              log.info(
+                  "DynamicAllocationTasksNotice submitted again in [%d] 
millis, minTriggerDynamicFrequency is [%s] for supervisor[%s] for 
dataSource[%s], skipping it! desired task count is [%s], active task count is 
[%s]",
+                  nowTime - lastRunTime,
+                  effectiveFreq,
+                  supervisorId,
+                  dataSource,
+                  desiredTaskCount,
+                  getActiveTaskGroupsCount()
+              );
+
+              if (desiredTaskCount > 0) {
+                emitter.emit(event.setDimension(
+                                      AUTOSCALER_SKIP_REASON_DIMENSION,
+                                      "minTriggerScaleActionFrequencyMillis 
not elapsed yet"

Review Comment:
   opted not to modify the reason here



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