This commit is contained in:
akulikov 2024-08-06 19:25:36 +03:00
parent a99104d8dd
commit 6e7fce1fe2

View file

@ -14,6 +14,26 @@ import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
@Configuration
public class ClearingImdgConfig {
private static ThreadPoolTaskExecutor createThreadPoolTaskExecutor(int maxPoolSz, boolean waitForCompletion) {
ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
if (maxPoolSz > 2) {
pool.setKeepAliveSeconds(60);
pool.setAllowCoreThreadTimeOut(true);
}
pool.setCorePoolSize(maxPoolSz);
pool.setWaitForTasksToCompleteOnShutdown(waitForCompletion);
pool.initialize();
return pool;
}
public ThreadPoolTaskExecutor taskExecutorHazelcastClientInitializer() {
return createThreadPoolTaskExecutor(1, true);
}
public ThreadPoolTaskExecutor taskExecutorIdGeneratorAwaiter() {
return createThreadPoolTaskExecutor(1, false);
}
@Bean
public ImdgProvider imdgProvider(ReportsServiceSettings settings, Environment env) throws PropertyVetoException {
String[] activeProfiles = env.getActiveProfiles();
@ -25,12 +45,8 @@ public class ClearingImdgConfig {
}
}
if (!isDevProfile) {
ThreadPoolTaskExecutor hazelcastClientInitializerPool = new ThreadPoolTaskExecutor();
hazelcastClientInitializerPool.setCorePoolSize(1);
hazelcastClientInitializerPool.setWaitForTasksToCompleteOnShutdown(true);
ThreadPoolTaskExecutor idGeneratorAwaiterPool = new ThreadPoolTaskExecutor();
idGeneratorAwaiterPool.setCorePoolSize(1);
idGeneratorAwaiterPool.setWaitForTasksToCompleteOnShutdown(false);
ThreadPoolTaskExecutor hazelcastClientInitializerPool = taskExecutorHazelcastClientInitializer();
ThreadPoolTaskExecutor idGeneratorAwaiterPool = taskExecutorIdGeneratorAwaiter();
return new HazelcastService(hazelcastClientInitializerPool, idGeneratorAwaiterPool, settings.getHazelcast());
} else {
ComboPooledDataSource dataSource = new ComboPooledDataSource();