AI rule node: use fixed-size thread pool with unbounded queue
This commit is contained in:
parent
80ebd784d8
commit
7dc8b78202
@ -32,10 +32,11 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.thingsboard.common.util.ThingsBoardExecutors;
|
||||
import org.thingsboard.common.util.ThingsBoardThreadFactory;
|
||||
import org.thingsboard.rule.engine.api.AiRequestsExecutor;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
@Lazy
|
||||
@Component
|
||||
@ -56,9 +57,6 @@ class DefaultAiRequestsExecutor implements AiRequestsExecutor {
|
||||
@Min(value = 1, message = "Pool size must be at least 1")
|
||||
private int poolSize = 50;
|
||||
|
||||
@Min(value = 1, message = "Max queue size must be at least 1")
|
||||
private int maxQueueSize = 10000;
|
||||
|
||||
@Min(value = 1, message = "Termination timeout must be at least 1 second")
|
||||
private int terminationTimeoutSeconds = 60;
|
||||
|
||||
@ -69,7 +67,7 @@ class DefaultAiRequestsExecutor implements AiRequestsExecutor {
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
executorService = MoreExecutors.listeningDecorator(
|
||||
ThingsBoardExecutors.newLimitedTasksExecutor(properties.getPoolSize(), properties.getMaxQueueSize(), properties.getPoolName())
|
||||
Executors.newFixedThreadPool(properties.getPoolSize(), ThingsBoardThreadFactory.forName(properties.getPoolName()))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -470,8 +470,6 @@ actors:
|
||||
pool-name: "${ACTORS_RULE_AI_REQUESTS_THREAD_POOL_NAME:ai-requests}"
|
||||
# The maximum number of concurrent HTTP requests
|
||||
pool-size: "${ACTORS_RULE_AI_REQUESTS_THREAD_POOL_SIZE:50}"
|
||||
# The maximum queue size for pending AI requests
|
||||
max-queue-size: "${ACTORS_RULE_AI_REQUESTS_THREAD_POOL_QUEUE_SIZE:10000}"
|
||||
# The maximum time in seconds to wait for active tasks to complete during graceful shutdown
|
||||
termination-timeout-seconds: "${ACTORS_RULE_AI_REQUESTS_THREAD_POOL_TERMINATION_TIMEOUT_SECONDS:60}"
|
||||
chain:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user