Make the search coordinator thread pool size configurable and set a (#2457)

reasonable default value. The default was 1 and all searches were being
executed sequentially.
This commit is contained in:
Xiaocheng Luan 2021-03-10 16:56:49 -05:00 committed by GitHub
parent 9f5786ba6c
commit f752e46e84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 0 deletions

View File

@ -151,6 +151,7 @@ import org.springframework.scheduling.concurrent.ScheduledExecutorFactoryBean;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import javax.annotation.Nullable;
import javax.annotation.PostConstruct;
import java.util.Date;
/*
@ -200,6 +201,29 @@ public abstract class BaseConfig {
@Autowired
private DaoRegistry myDaoRegistry;
/**
* Subclasses may override this method to provide settings such as search coordinator pool sizes.
*/
@PostConstruct
public void initSettings() {}
private Integer searchCoordCorePoolSize = 20;
private Integer searchCoordMaxPoolSize = 100;
private Integer searchCoordQueueCapacity = 200;
public void setSearchCoordCorePoolSize(Integer searchCoordCorePoolSize) {
this.searchCoordCorePoolSize = searchCoordCorePoolSize;
}
public void setSearchCoordMaxPoolSize(Integer searchCoordMaxPoolSize) {
this.searchCoordMaxPoolSize = searchCoordMaxPoolSize;
}
public void setSearchCoordQueueCapacity(Integer searchCoordQueueCapacity) {
this.searchCoordQueueCapacity = searchCoordQueueCapacity;
}
@Bean
public BatchConfigurer batchConfigurer() {
return new NonPersistedBatchConfigurer();
@ -316,6 +340,9 @@ public abstract class BaseConfig {
public ThreadPoolTaskExecutor searchCoordinatorThreadFactory() {
final ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
threadPoolTaskExecutor.setThreadNamePrefix("search_coord_");
threadPoolTaskExecutor.setCorePoolSize(searchCoordCorePoolSize);
threadPoolTaskExecutor.setMaxPoolSize(searchCoordMaxPoolSize);
threadPoolTaskExecutor.setQueueCapacity(searchCoordQueueCapacity);
threadPoolTaskExecutor.initialize();
return threadPoolTaskExecutor;
}