optimize: 优化相关功能日志打印.

pull/161/head
chen.ma 3 years ago
parent d7fb126ea0
commit 82256ea5e7

@ -17,12 +17,14 @@ public class CommonThreadPool {
public static ThreadPoolExecutor getInstance(String threadPoolId) {
ThreadPoolExecutor poolExecutor = ThreadPoolBuilder.builder()
.isCustomPool(true)
.threadFactory(threadPoolId)
.poolThreadNum(3, 5)
.poolThreadSize(3, 5)
.keepAliveTime(1000L, TimeUnit.SECONDS)
.rejected(RejectedPolicies.runsOldestTaskPolicy())
.workQueue(QueueTypeEnum.RESIZABLE_LINKED_BLOCKING_QUEUE, 512)
.build();
return poolExecutor;
}
}

@ -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);
}
}

@ -118,7 +118,10 @@ public class ClientWorker {
List<String> changedTpIds = checkUpdateDataIds(queryCacheDataList);
if (!CollectionUtils.isEmpty(changedTpIds)) {
log.info("[dynamic threadPool] tpIds changed :: {}", changedTpIds);
/**
*
* log.info("[dynamic threadPool] tpIds changed :: {}", changedTpIds);
*/
for (String each : changedTpIds) {
String[] keys = StrUtil.split(each, Constants.GROUP_KEY_DELIMITER);
String tpId = keys[0];
@ -131,8 +134,10 @@ public class ClientWorker {
String poolContent = ContentUtil.getPoolContent(JSON.parseObject(content, PoolParameterInfo.class));
cacheData.setContent(poolContent);
cacheDataList.add(cacheData);
log.info("[data-received] namespace :: {}, itemId :: {}, tpId :: {}, md5 :: {}",
namespace, itemId, tpId, cacheData.getMd5());
/**
*
* log.info("[data-received] namespace :: {}, itemId :: {}, tpId :: {}, md5 :: {}", namespace, itemId, tpId, cacheData.getMd5());
*/
} catch (Exception ex) {
// ignore
}
@ -184,9 +189,11 @@ public class ClientWorker {
try {
long readTimeoutMs = timeout + (long) Math.round(timeout >> 1);
Result result = agent.httpPost(Constants.LISTENER_PATH, headers, params, readTimeoutMs);
if (result == null || result.isFail()) {
log.warn("[check-update] get changed dataId error, code: {}", result == null ? "error" : result.getCode());
} else {
/**
*
* log.warn("[check-update] get changed dataId error, code: {}", result == null ? "error" : result.getCode());
*/
if (result != null && result.isSuccess()) {
setHealthServer(true);
return parseUpdateDataIdResponse(result.getData().toString());
}

Loading…
Cancel
Save