mirror of
https://gitee.com/san-bing/JChargePointProtocol
synced 2026-05-05 02:19:56 +08:00
protocolSession的缓存改为同步caffeine,因为没有IO操作
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 抖音关注:程序员三丙
|
||||
* 知识星球:https://t.zsxq.com/j9b21
|
||||
*/
|
||||
package sanbing.jcpp.infrastructure.util.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
|
||||
@Configuration
|
||||
public class ScheduledTaskConfig {
|
||||
|
||||
@Bean
|
||||
public TaskScheduler taskScheduler() {
|
||||
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
|
||||
scheduler.setPoolSize(Runtime.getRuntime().availableProcessors());
|
||||
scheduler.setThreadNamePrefix("scheduled-task-");
|
||||
scheduler.initialize();
|
||||
return scheduler;
|
||||
}
|
||||
}
|
||||
@@ -33,12 +33,12 @@ public class ShardingThreadPool {
|
||||
@Value("${thread-pool.sharding.hash_function_name:murmur3_128}")
|
||||
private String hashFunctionName;
|
||||
|
||||
@Value("${thread-pool.sharding.parallelism:128}")
|
||||
@Value("${thread-pool.sharding.parallelism:8}")
|
||||
private int parallelism;
|
||||
|
||||
private HashFunction hashFunction;
|
||||
|
||||
private final Map<Integer, ExecutorService> EXECUTOR_SERVICE_MAP = new ConcurrentHashMap<>(128);
|
||||
private final Map<Integer, ExecutorService> EXECUTOR_SERVICE_MAP = new ConcurrentHashMap<>(8);
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
@@ -59,13 +59,16 @@ public class ShardingThreadPool {
|
||||
|
||||
ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) v;
|
||||
|
||||
log.info("分区 {}/{} 的线程池中剩余 {} 条待执行任务,当前正在执行的线程数 {}, 已完成任务 {} / {}",
|
||||
k,
|
||||
EXECUTOR_SERVICE_MAP.size(),
|
||||
threadPoolExecutor.getQueue().size(),
|
||||
threadPoolExecutor.getActiveCount(),
|
||||
threadPoolExecutor.getCompletedTaskCount(),
|
||||
threadPoolExecutor.getTaskCount());
|
||||
int size = threadPoolExecutor.getQueue().size();
|
||||
|
||||
if (size > 1) {
|
||||
log.info("分区 {} 的线程池中剩余 {} 条待执行任务,当前正在执行的线程数 {}, 已完成任务 {} / {}",
|
||||
k,
|
||||
size,
|
||||
threadPoolExecutor.getActiveCount(),
|
||||
threadPoolExecutor.getCompletedTaskCount(),
|
||||
threadPoolExecutor.getTaskCount());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user