|
|
|
@ -20,21 +20,25 @@ public class ThreadPoolDynamicRefresh {
|
|
|
|
|
public static void refreshDynamicPool(String content) {
|
|
|
|
|
PoolParameterInfo parameter = JSON.parseObject(content, PoolParameterInfo.class);
|
|
|
|
|
String tpId = parameter.getTpId();
|
|
|
|
|
Integer coreSize, maxSize, queueType, capacity, keepAliveTime;
|
|
|
|
|
log.info("[🔥] Start refreshing configuration. tpId :: {}, coreSize :: {}, maxSize :: {}, queueType :: {}, capacity :: {}, keepAliveTime :: {}",
|
|
|
|
|
tpId, coreSize = parameter.getCoreSize(), maxSize = parameter.getMaxSize(),
|
|
|
|
|
queueType = parameter.getQueueType(), capacity = parameter.getCapacity(), keepAliveTime = parameter.getKeepAliveTime());
|
|
|
|
|
Integer coreSize = parameter.getCoreSize(), maxSize = parameter.getMaxSize(),
|
|
|
|
|
queueType = parameter.getQueueType(), capacity = parameter.getCapacity(),
|
|
|
|
|
keepAliveTime = parameter.getKeepAliveTime();
|
|
|
|
|
refreshDynamicPool(tpId, coreSize, maxSize, queueType, capacity, keepAliveTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void refreshDynamicPool(String threadPoolId, Integer coreSize, Integer maxSize, Integer queueType, Integer capacity, Integer keepAliveTime) {
|
|
|
|
|
ThreadPoolExecutor executor = GlobalThreadPoolManage.getExecutorService(threadPoolId).getPool();
|
|
|
|
|
log.info("[✈️] Original thread pool. coreSize :: {}, maxSize :: {}, queueType :: {}, capacity :: {}, keepAliveTime :: {}",
|
|
|
|
|
printLog("[🔥] Original thread pool. ",
|
|
|
|
|
executor.getCorePoolSize(), executor.getMaximumPoolSize(), queueType, executor.getQueue().remainingCapacity(), executor.getKeepAliveTime(TimeUnit.MILLISECONDS));
|
|
|
|
|
|
|
|
|
|
ThreadPoolChangeHandler.changePool(executor, coreSize, maxSize, queueType, capacity, keepAliveTime);
|
|
|
|
|
ThreadPoolExecutor afterExecutor = GlobalThreadPoolManage.getExecutorService(threadPoolId).getPool();
|
|
|
|
|
log.info("[🚀] Changed thread pool. coreSize :: {}, maxSize :: {}, queueType :: {}, capacity :: {}, keepAliveTime :: {}",
|
|
|
|
|
|
|
|
|
|
printLog("[🚀] Changed thread pool. ",
|
|
|
|
|
afterExecutor.getCorePoolSize(), afterExecutor.getMaximumPoolSize(), queueType, afterExecutor.getQueue().remainingCapacity(), afterExecutor.getKeepAliveTime(TimeUnit.MILLISECONDS));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void printLog(String prefixMsg, Integer coreSize, Integer maxSize, Integer queueType, Integer capacity, Long keepAliveTime) {
|
|
|
|
|
log.info("{} coreSize :: {}, maxSize :: {}, queueType :: {}, capacity :: {}, keepAliveTime :: {}", prefixMsg, coreSize, maxSize, queueType, capacity, keepAliveTime);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|