zhangyue19921010 commented on a change in pull request #10524:
URL: https://github.com/apache/druid/pull/10524#discussion_r569988009



##########
File path: 
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisor.java
##########
@@ -318,6 +322,114 @@ public void handle()
     }
   }
 
+  // change taskCount without resubmitting.
+  private class DynamicAllocationTasksNotice implements Notice
+  {
+    Callable<Integer> scaleAction;
+
+    DynamicAllocationTasksNotice(Callable<Integer> scaleAction)
+    {
+      this.scaleAction = scaleAction;
+    }
+
+    /**
+     * This method will do lags points collection and check dynamic scale 
action is necessary or not.
+     */
+    @Override
+    public void handle()
+    {
+      try {
+        long nowTime = System.currentTimeMillis();
+        // Only queue is full and over minTriggerDynamicFrequency can trigger 
scale out/in
+        if (spec.isSuspended()) {
+          log.info("[%s] supervisor is suspended, skip to check dynamic 
allocate task logic", dataSource);
+          return;
+        }
+        log.debug("PendingCompletionTaskGroups is [%s] for dataSource [%s].", 
pendingCompletionTaskGroups, dataSource);
+        for (CopyOnWriteArrayList list : pendingCompletionTaskGroups.values()) 
{
+          if (!list.isEmpty()) {
+            log.info("Still hand off tasks unfinished, skip to do scale action 
[%s] for dataSource [%s].", pendingCompletionTaskGroups, dataSource);
+            return;
+          }
+        }
+        if (nowTime - dynamicTriggerLastRunTime < minTriggerDynamicFrequency) {

Review comment:
       Thanks for your attention.
   
   Actually, there are three hard conditions before do scale action:
   1. Don't scale when supervisor is suspended.
   2. Don't scale when previous task is handing off to avoid inconsistent state.
   3. Don't scale durning cool down time to avoid overly frequent scaling.
   
   And I think no matter what the task type is, no matter what the autoscaler 
impl is, it maybe better to follow these three common conditions.
   
   Also users can define their own conditions like TaskCountLimitation in 
specific impl :)
    




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

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