|
|
@ -20,21 +20,25 @@ public class ThreadPoolDynamicRefresh {
|
|
|
|
public static void refreshDynamicPool(String content) {
|
|
|
|
public static void refreshDynamicPool(String content) {
|
|
|
|
PoolParameterInfo parameter = JSON.parseObject(content, PoolParameterInfo.class);
|
|
|
|
PoolParameterInfo parameter = JSON.parseObject(content, PoolParameterInfo.class);
|
|
|
|
String tpId = parameter.getTpId();
|
|
|
|
String tpId = parameter.getTpId();
|
|
|
|
Integer coreSize, maxSize, queueType, capacity, keepAliveTime;
|
|
|
|
Integer coreSize = parameter.getCoreSize(), maxSize = parameter.getMaxSize(),
|
|
|
|
log.info("[🔥] Start refreshing configuration. tpId :: {}, coreSize :: {}, maxSize :: {}, queueType :: {}, capacity :: {}, keepAliveTime :: {}",
|
|
|
|
queueType = parameter.getQueueType(), capacity = parameter.getCapacity(),
|
|
|
|
tpId, coreSize = parameter.getCoreSize(), maxSize = parameter.getMaxSize(),
|
|
|
|
keepAliveTime = parameter.getKeepAliveTime();
|
|
|
|
queueType = parameter.getQueueType(), capacity = parameter.getCapacity(), keepAliveTime = parameter.getKeepAliveTime());
|
|
|
|
|
|
|
|
refreshDynamicPool(tpId, coreSize, maxSize, queueType, capacity, keepAliveTime);
|
|
|
|
refreshDynamicPool(tpId, coreSize, maxSize, queueType, capacity, keepAliveTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void refreshDynamicPool(String threadPoolId, Integer coreSize, Integer maxSize, Integer queueType, Integer capacity, Integer keepAliveTime) {
|
|
|
|
public static void refreshDynamicPool(String threadPoolId, Integer coreSize, Integer maxSize, Integer queueType, Integer capacity, Integer keepAliveTime) {
|
|
|
|
ThreadPoolExecutor executor = GlobalThreadPoolManage.getExecutorService(threadPoolId).getPool();
|
|
|
|
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));
|
|
|
|
executor.getCorePoolSize(), executor.getMaximumPoolSize(), queueType, executor.getQueue().remainingCapacity(), executor.getKeepAliveTime(TimeUnit.MILLISECONDS));
|
|
|
|
|
|
|
|
|
|
|
|
ThreadPoolChangeHandler.changePool(executor, coreSize, maxSize, queueType, capacity, keepAliveTime);
|
|
|
|
ThreadPoolChangeHandler.changePool(executor, coreSize, maxSize, queueType, capacity, keepAliveTime);
|
|
|
|
ThreadPoolExecutor afterExecutor = GlobalThreadPoolManage.getExecutorService(threadPoolId).getPool();
|
|
|
|
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));
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|