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



##########
File path: 
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisor.java
##########
@@ -518,20 +684,52 @@ public SeekableStreamSupervisor(
     this.useExclusiveStartingSequence = useExclusiveStartingSequence;
     this.dataSource = spec.getDataSchema().getDataSource();
     this.ioConfig = spec.getIoConfig();
+    this.dynamicAllocationTasksProperties = 
ioConfig.getDynamicAllocationTasksProperties();
+    log.info("Get dynamicAllocationTasksProperties from IOConfig : " + 
dynamicAllocationTasksProperties);
+
+    if (dynamicAllocationTasksProperties != null && 
!dynamicAllocationTasksProperties.isEmpty() && 
Boolean.parseBoolean(String.valueOf(dynamicAllocationTasksProperties.getOrDefault("enableDynamicAllocationTasks",
 false)))) {
+      log.info("EnableDynamicAllocationTasks for datasource " + dataSource);
+      this.enableDynamicAllocationTasks = true;
+    } else {
+      log.info("Disable Dynamic Allocate Tasks");
+      this.enableDynamicAllocationTasks = false;
+    }
+    int taskCountMax = 0;
+    if (enableDynamicAllocationTasks) {
+      this.metricsCollectionIntervalMillis = 
Long.parseLong(String.valueOf(dynamicAllocationTasksProperties.getOrDefault("metricsCollectionIntervalMillis",
 10000)));
+      this.metricsCollectionRangeMillis = 
Long.parseLong(String.valueOf(dynamicAllocationTasksProperties.getOrDefault("metricsCollectionRangeMillis",
 6 * 10 * 1000)));
+      int slots = (int) (metricsCollectionRangeMillis / 
metricsCollectionIntervalMillis) + 1;
+      log.info(" The interval of metrics collection is " + 
metricsCollectionIntervalMillis + ", " + metricsCollectionRangeMillis + " 
timeRange will collect " + slots + " data points at most.");
+      this.queue = new CircularFifoQueue<>(slots);
+      taskCountMax = 
Integer.parseInt(String.valueOf(this.dynamicAllocationTasksProperties.getOrDefault("taskCountMax",
 8)));
+      this.dynamicCheckStartDelayMillis = 
Long.parseLong(String.valueOf(dynamicAllocationTasksProperties.getOrDefault("dynamicCheckStartDelayMillis",
 300000)));
+      this.dynamicCheckPeriod = 
Long.parseLong(String.valueOf(dynamicAllocationTasksProperties.getOrDefault("dynamicCheckPeriod",
 600000)));
+      this.metricsCollectionRangeMillis = 
Long.parseLong(String.valueOf(dynamicAllocationTasksProperties.getOrDefault("metricsCollectionRangeMillis",
 600000)));
+    }
+
     this.tuningConfig = spec.getTuningConfig();
     this.taskTuningConfig = this.tuningConfig.convertToTaskTuningConfig();
     this.supervisorId = supervisorId;
     this.exec = Execs.singleThreaded(supervisorId);
     this.scheduledExec = Execs.scheduledSingleThreaded(supervisorId + 
"-Scheduler-%d");
     this.reportingExec = Execs.scheduledSingleThreaded(supervisorId + 
"-Reporting-%d");
+    this.allocationExec = Execs.scheduledSingleThreaded(supervisorId + 
"-Allocation-%d");
+    this.lagComputationExec = Execs.scheduledSingleThreaded(supervisorId + 
"-Computation-%d");
     this.stateManager = new SeekableStreamSupervisorStateManager(
         spec.getSupervisorStateManagerConfig(),
         spec.isSuspended()
     );
 
-    int workerThreads = (this.tuningConfig.getWorkerThreads() != null
-                         ? this.tuningConfig.getWorkerThreads()
-                         : Math.min(10, this.ioConfig.getTaskCount()));
+    int workerThreads;
+    if (enableDynamicAllocationTasks) {
+      workerThreads = (this.tuningConfig.getWorkerThreads() != null
+              ? this.tuningConfig.getWorkerThreads()
+              : Math.min(10, taskCountMax));
+    } else {
+      workerThreads = (this.tuningConfig.getWorkerThreads() != null
+              ? this.tuningConfig.getWorkerThreads()
+              : Math.min(10, this.ioConfig.getTaskCount()));
+    }
 
     this.workerExec = 
MoreExecutors.listeningDecorator(Execs.multiThreaded(workerThreads, 
supervisorId + "-Worker-%d"));
     log.info("Created worker pool with [%d] threads for dataSource [%s]", 
workerThreads, this.dataSource);

Review comment:
       Done.




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