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.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.validation.annotation.Validated;
|
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 org.thingsboard.rule.engine.api.AiRequestsExecutor;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@ -56,9 +57,6 @@ class DefaultAiRequestsExecutor implements AiRequestsExecutor {
|
|||||||
@Min(value = 1, message = "Pool size must be at least 1")
|
@Min(value = 1, message = "Pool size must be at least 1")
|
||||||
private int poolSize = 50;
|
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")
|
@Min(value = 1, message = "Termination timeout must be at least 1 second")
|
||||||
private int terminationTimeoutSeconds = 60;
|
private int terminationTimeoutSeconds = 60;
|
||||||
|
|
||||||
@ -69,7 +67,7 @@ class DefaultAiRequestsExecutor implements AiRequestsExecutor {
|
|||||||
@PostConstruct
|
@PostConstruct
|
||||||
private void init() {
|
private void init() {
|
||||||
executorService = MoreExecutors.listeningDecorator(
|
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}"
|
pool-name: "${ACTORS_RULE_AI_REQUESTS_THREAD_POOL_NAME:ai-requests}"
|
||||||
# The maximum number of concurrent HTTP requests
|
# The maximum number of concurrent HTTP requests
|
||||||
pool-size: "${ACTORS_RULE_AI_REQUESTS_THREAD_POOL_SIZE:50}"
|
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
|
# 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}"
|
termination-timeout-seconds: "${ACTORS_RULE_AI_REQUESTS_THREAD_POOL_TERMINATION_TIMEOUT_SECONDS:60}"
|
||||||
chain:
|
chain:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user