From b9e3d726ec8fcb5a784232ba515ea42ec8bd3753 Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Sun, 7 Aug 2022 00:20:16 +0800 Subject: [PATCH] Log print content optimization --- .../adapter/web/TomcatWebThreadPoolHandler.java | 4 ++-- .../web/UndertowWebThreadPoolHandler.java | 2 +- .../constant/ChangeThreadPoolConstants.java | 16 ++++++++-------- .../design/observer/AbstractSubjectCenter.java | 2 +- .../hippo4j/config/notify/DefaultPublisher.java | 6 +++--- .../cn/hippo4j/config/notify/NotifyCenter.java | 4 ++-- .../config/service/ConfigCacheService.java | 6 +++--- .../config/service/LongPollingService.java | 2 +- .../service/biz/impl/ConfigServiceImpl.java | 4 ++-- .../ClientCloseHookRemoveConfigCache.java | 2 +- .../handler/RemoveThreadPoolAdapterCache.java | 2 +- .../support/AbstractBuildThreadPoolTemplate.java | 2 +- .../controller/ApplicationController.java | 2 +- .../discovery/core/BaseInstanceRegistry.java | 8 ++++---- .../example/core/inittest/TaskDecoratorTest.java | 2 +- .../service/Hippo4jBaseSendMessageService.java | 10 +++++----- .../refresher/event/ExecutorsListener.java | 2 +- .../core/ServerThreadPoolDynamicRefresh.java | 2 +- .../starter/toolkit/HttpClientUtil.java | 2 +- 19 files changed, 40 insertions(+), 40 deletions(-) diff --git a/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/TomcatWebThreadPoolHandler.java b/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/TomcatWebThreadPoolHandler.java index ccb29103..6df99c55 100644 --- a/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/TomcatWebThreadPoolHandler.java +++ b/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/TomcatWebThreadPoolHandler.java @@ -53,7 +53,7 @@ public class TomcatWebThreadPoolHandler extends AbstractWebThreadPoolService { @Override protected Executor getWebThreadPoolByServer(WebServer webServer) { if (cacheFlag.get()) { - log.warn("Exception getting Tomcat thread pool. Exception message :: {}", EXCEPTION_MESSAGE); + log.warn("Exception getting Tomcat thread pool. Exception message: {}", EXCEPTION_MESSAGE); return null; } Executor tomcatExecutor = null; @@ -168,7 +168,7 @@ public class TomcatWebThreadPoolHandler extends AbstractWebThreadPoolService { tomcatThreadPoolExecutor.setCorePoolSize(threadPoolParameterInfo.corePoolSizeAdapt()); tomcatThreadPoolExecutor.setMaximumPoolSize(threadPoolParameterInfo.maximumPoolSizeAdapt()); tomcatThreadPoolExecutor.setKeepAliveTime(threadPoolParameterInfo.getKeepAliveTime(), TimeUnit.SECONDS); - log.info("[Tomcat] Changed web thread pool. corePoolSize: [{}], maximumPoolSize: [{}], keepAliveTime :: [{}]", + log.info("[Tomcat] Changed web thread pool. corePoolSize: [{}], maximumPoolSize: [{}], keepAliveTime: [{}]", String.format(ChangeThreadPoolConstants.CHANGE_DELIMITER, originalCoreSize, threadPoolParameterInfo.corePoolSizeAdapt()), String.format(ChangeThreadPoolConstants.CHANGE_DELIMITER, originalMaximumPoolSize, threadPoolParameterInfo.maximumPoolSizeAdapt()), String.format(ChangeThreadPoolConstants.CHANGE_DELIMITER, originalKeepAliveTime, threadPoolParameterInfo.getKeepAliveTime())); diff --git a/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/UndertowWebThreadPoolHandler.java b/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/UndertowWebThreadPoolHandler.java index 9304d8d2..bfdc5b7d 100644 --- a/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/UndertowWebThreadPoolHandler.java +++ b/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/UndertowWebThreadPoolHandler.java @@ -152,7 +152,7 @@ public class UndertowWebThreadPoolHandler extends AbstractWebThreadPoolService { xnioWorker.setOption(Options.WORKER_TASK_CORE_THREADS, coreSize); xnioWorker.setOption(Options.WORKER_TASK_MAX_THREADS, maxSize); xnioWorker.setOption(Options.WORKER_TASK_KEEPALIVE, keepAliveTime); - log.info("[Undertow] Changed web thread pool. corePoolSize: [{}], maximumPoolSize: [{}], keepAliveTime :: [{}]", + log.info("[Undertow] Changed web thread pool. corePoolSize: [{}], maximumPoolSize: [{}], keepAliveTime: [{}]", String.format(ChangeThreadPoolConstants.CHANGE_DELIMITER, originalCoreSize, coreSize), String.format(ChangeThreadPoolConstants.CHANGE_DELIMITER, originalMaximumPoolSize, maxSize), String.format(ChangeThreadPoolConstants.CHANGE_DELIMITER, originalKeepAliveTime, keepAliveTime)); diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/constant/ChangeThreadPoolConstants.java b/hippo4j-common/src/main/java/cn/hippo4j/common/constant/ChangeThreadPoolConstants.java index c01b9e6c..27f79460 100644 --- a/hippo4j-common/src/main/java/cn/hippo4j/common/constant/ChangeThreadPoolConstants.java +++ b/hippo4j-common/src/main/java/cn/hippo4j/common/constant/ChangeThreadPoolConstants.java @@ -23,14 +23,14 @@ package cn.hippo4j.common.constant; public class ChangeThreadPoolConstants { public static final String CHANGE_THREAD_POOL_TEXT = "[{}] Changing thread pool parameters. " + - "\n coreSize :: [{}]" + - "\n maximumSize :: [{}]" + - "\n queueType :: [{}]" + - "\n capacity :: [{}]" + - "\n keepAliveTime :: [{}]" + - "\n executeTimeOut :: [{}]" + - "\n rejectedType :: [{}]" + - "\n allowCoreThreadTimeOut :: [{}]"; + "\n coreSize: [{}]" + + "\n maximumSize: [{}]" + + "\n queueType: [{}]" + + "\n capacity: [{}]" + + "\n keepAliveTime: [{}]" + + "\n executeTimeOut: [{}]" + + "\n rejectedType: [{}]" + + "\n allowCoreThreadTimeOut: [{}]"; public static final String CHANGE_DELIMITER = "%s => %s"; } diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/design/observer/AbstractSubjectCenter.java b/hippo4j-common/src/main/java/cn/hippo4j/common/design/observer/AbstractSubjectCenter.java index ffbb01b8..530f33df 100644 --- a/hippo4j-common/src/main/java/cn/hippo4j/common/design/observer/AbstractSubjectCenter.java +++ b/hippo4j-common/src/main/java/cn/hippo4j/common/design/observer/AbstractSubjectCenter.java @@ -126,7 +126,7 @@ public class AbstractSubjectCenter { try { each.accept(observerMessage); } catch (Exception ex) { - log.error("Notification subject :: {} observer exception", subject); + log.error("Notification subject: {} observer exception", subject); } }); } diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/notify/DefaultPublisher.java b/hippo4j-config/src/main/java/cn/hippo4j/config/notify/DefaultPublisher.java index 1e74304e..9b372288 100644 --- a/hippo4j-config/src/main/java/cn/hippo4j/config/notify/DefaultPublisher.java +++ b/hippo4j-config/src/main/java/cn/hippo4j/config/notify/DefaultPublisher.java @@ -98,7 +98,7 @@ public class DefaultPublisher extends Thread implements EventPublisher { UPDATER.compareAndSet(this, lastEventSequence, Math.max(lastEventSequence, event.sequence())); } } catch (Throwable ex) { - log.error("Event listener exception :: {}", ex); + log.error("Event listener exception: {}", ex); } } @@ -111,7 +111,7 @@ public class DefaultPublisher extends Thread implements EventPublisher { public boolean publish(AbstractEvent event) { boolean success = this.queue.offer(event); if (!success) { - log.warn("Unable to plug in due to interruption, synchronize sending time, event :: {}", event); + log.warn("Unable to plug in due to interruption, synchronize sending time, event : {}", event); receiveEvent(event); return true; } @@ -130,7 +130,7 @@ public class DefaultPublisher extends Thread implements EventPublisher { try { job.run(); } catch (Throwable e) { - log.error("Event callback exception :: {}", e); + log.error("Event callback exception : {}", e); } } } diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/notify/NotifyCenter.java b/hippo4j-config/src/main/java/cn/hippo4j/config/notify/NotifyCenter.java index 6c460526..a0c30918 100644 --- a/hippo4j-config/src/main/java/cn/hippo4j/config/notify/NotifyCenter.java +++ b/hippo4j-config/src/main/java/cn/hippo4j/config/notify/NotifyCenter.java @@ -58,7 +58,7 @@ public class NotifyCenter { publisher.init(cls, buffer); return publisher; } catch (Throwable ex) { - log.error("Service class newInstance has error :: {}", ex); + log.error("Service class newInstance has error : {}", ex); throw new RuntimeException(ex); } }; @@ -98,7 +98,7 @@ public class NotifyCenter { try { return publishEvent(event.getClass(), event); } catch (Throwable ex) { - log.error("There was an exception to the message publishing :: {}", ex); + log.error("There was an exception to the message publishing : {}", ex); return false; } } diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/service/ConfigCacheService.java b/hippo4j-config/src/main/java/cn/hippo4j/config/service/ConfigCacheService.java index c1b93c65..b0385991 100644 --- a/hippo4j-config/src/main/java/cn/hippo4j/config/service/ConfigCacheService.java +++ b/hippo4j-config/src/main/java/cn/hippo4j/config/service/ConfigCacheService.java @@ -104,7 +104,7 @@ public class ConfigCacheService { String[] params = groupKey.split(GROUP_KEY_DELIMITER_TRANSLATION); ConfigAllInfo config = CONFIG_SERVICE.findConfigRecentInfo(params); if (config == null || StringUtils.isEmpty(config.getTpId())) { - String errorMessage = String.format("config is null. tpId :: %s, itemId :: %s, tenantId :: %s", params[0], params[1], params[2]); + String errorMessage = String.format("config is null. tpId: %s, itemId: %s, tenantId: %s", params[0], params[1], params[2]); throw new RuntimeException(errorMessage); } return Md5Util.getTpContentMd5(config); @@ -178,7 +178,7 @@ public class ConfigCacheService { List identificationList = MapUtil.parseMapForFilter(CLIENT_CONFIG_CACHE, coarse); for (String cacheMapKey : identificationList) { Map removeCacheItem = CLIENT_CONFIG_CACHE.remove(cacheMapKey); - log.info("Remove invalidated config cache. config info :: {}", JSONUtil.toJSONString(removeCacheItem)); + log.info("Remove invalidated config cache. config info : {}", JSONUtil.toJSONString(removeCacheItem)); } } @@ -189,7 +189,7 @@ public class ConfigCacheService { @Override public void accept(ObserverMessage observerMessage) { - log.info("Clean up the configuration cache. Key :: {}", observerMessage.message()); + log.info("Clean up the configuration cache. Key : {}", observerMessage.message()); coarseRemove(observerMessage.message()); } } diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/service/LongPollingService.java b/hippo4j-config/src/main/java/cn/hippo4j/config/service/LongPollingService.java index 671de168..918e6a3c 100644 --- a/hippo4j-config/src/main/java/cn/hippo4j/config/service/LongPollingService.java +++ b/hippo4j-config/src/main/java/cn/hippo4j/config/service/LongPollingService.java @@ -94,7 +94,7 @@ public class LongPollingService { @Override public void run() { - log.info("Dynamic Thread Pool Long pulling client count :: {}", allSubs.size()); + log.info("Dynamic Thread Pool Long pulling client count: {}", allSubs.size()); } } diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/ConfigServiceImpl.java b/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/ConfigServiceImpl.java index 3ab08f63..1fda0ac4 100644 --- a/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/ConfigServiceImpl.java +++ b/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/ConfigServiceImpl.java @@ -156,7 +156,7 @@ public class ConfigServiceImpl implements ConfigService { } } } catch (Exception ex) { - log.error("[db-error] message :: {}", ex.getMessage(), ex); + log.error("[db-error] message : {}", ex.getMessage(), ex); throw ex; } return null; @@ -192,7 +192,7 @@ public class ConfigServiceImpl implements ConfigService { } configInfoMapper.update(config, wrapper); } catch (Exception ex) { - log.error("[db-error] message :: {}", ex.getMessage(), ex); + log.error("[db-error] message : {}", ex.getMessage(), ex); throw ex; } } diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/service/handler/ClientCloseHookRemoveConfigCache.java b/hippo4j-config/src/main/java/cn/hippo4j/config/service/handler/ClientCloseHookRemoveConfigCache.java index 293ab32d..34e81cc7 100644 --- a/hippo4j-config/src/main/java/cn/hippo4j/config/service/handler/ClientCloseHookRemoveConfigCache.java +++ b/hippo4j-config/src/main/java/cn/hippo4j/config/service/handler/ClientCloseHookRemoveConfigCache.java @@ -33,7 +33,7 @@ public class ClientCloseHookRemoveConfigCache implements ClientCloseHookExecute @Override public void closeHook(ClientCloseHookReq requestParam) { - log.info("Remove Config Cache, Execute client hook function. Request :: {}", JSONUtil.toJSONString(requestParam)); + log.info("Remove Config Cache, Execute client hook function. Request : {}", JSONUtil.toJSONString(requestParam)); try { String groupKey = requestParam.getGroupKey(); if (StrUtil.isNotBlank(groupKey)) { diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/service/handler/RemoveThreadPoolAdapterCache.java b/hippo4j-config/src/main/java/cn/hippo4j/config/service/handler/RemoveThreadPoolAdapterCache.java index fb2bfb60..7b01d631 100644 --- a/hippo4j-config/src/main/java/cn/hippo4j/config/service/handler/RemoveThreadPoolAdapterCache.java +++ b/hippo4j-config/src/main/java/cn/hippo4j/config/service/handler/RemoveThreadPoolAdapterCache.java @@ -32,7 +32,7 @@ public class RemoveThreadPoolAdapterCache implements ClientCloseHookExecute { @Override public void closeHook(ClientCloseHookReq requestParam) { - log.info("Remove thread-pool adapter cache, Execute client hook function. Req :: {}", JSONUtil.toJSONString(requestParam)); + log.info("Remove thread-pool adapter cache, Execute client hook function. Req : {}", JSONUtil.toJSONString(requestParam)); ThreadPoolAdapterService.remove(requestParam.getInstanceId()); } } diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/AbstractBuildThreadPoolTemplate.java b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/AbstractBuildThreadPoolTemplate.java index 241179ac..61f34eec 100644 --- a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/AbstractBuildThreadPoolTemplate.java +++ b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/AbstractBuildThreadPoolTemplate.java @@ -105,7 +105,7 @@ public class AbstractBuildThreadPoolTemplate { initParam.getThreadFactory(), initParam.getRejectedExecutionHandler()); } catch (IllegalArgumentException ex) { - throw new IllegalArgumentException(String.format("Error creating thread pool parameter. threadPool id :: %s", initParam.getThreadPoolId()), ex); + throw new IllegalArgumentException(String.format("Error creating thread pool parameter. threadPool id: %s", initParam.getThreadPoolId()), ex); } dynamicThreadPoolExecutor.setTaskDecorator(initParam.getTaskDecorator()); dynamicThreadPoolExecutor.allowCoreThreadTimeOut(initParam.allowCoreThreadTimeOut); diff --git a/hippo4j-discovery/src/main/java/cn/hippo4j/discovery/controller/ApplicationController.java b/hippo4j-discovery/src/main/java/cn/hippo4j/discovery/controller/ApplicationController.java index 680f1f78..ebad6e7c 100644 --- a/hippo4j-discovery/src/main/java/cn/hippo4j/discovery/controller/ApplicationController.java +++ b/hippo4j-discovery/src/main/java/cn/hippo4j/discovery/controller/ApplicationController.java @@ -58,7 +58,7 @@ public class ApplicationController { public Result renew(@RequestBody InstanceInfo.InstanceRenew instanceRenew) { boolean isSuccess = instanceRegistry.renew(instanceRenew); if (!isSuccess) { - log.warn("Not Found (Renew) :: {} - {}", instanceRenew.getAppName(), instanceRenew.getInstanceId()); + log.warn("Not Found (Renew) : {} - {}", instanceRenew.getAppName(), instanceRenew.getInstanceId()); return Results.failure(ErrorCodeEnum.NOT_FOUND); } return Results.success(); diff --git a/hippo4j-discovery/src/main/java/cn/hippo4j/discovery/core/BaseInstanceRegistry.java b/hippo4j-discovery/src/main/java/cn/hippo4j/discovery/core/BaseInstanceRegistry.java index aa5563d5..1160f476 100644 --- a/hippo4j-discovery/src/main/java/cn/hippo4j/discovery/core/BaseInstanceRegistry.java +++ b/hippo4j-discovery/src/main/java/cn/hippo4j/discovery/core/BaseInstanceRegistry.java @@ -113,15 +113,15 @@ public class BaseInstanceRegistry implements InstanceRegistry { String instanceId = info.getInstanceId(); Map> leaseMap = registry.get(appName); if (CollectionUtils.isEmpty(leaseMap)) { - log.warn("Failed to remove unhealthy node, no application found :: {}", appName); + log.warn("Failed to remove unhealthy node, no application found : {}", appName); return; } Lease remove = leaseMap.remove(instanceId); if (remove == null) { - log.warn("Failed to remove unhealthy node, no instance found :: {}", instanceId); + log.warn("Failed to remove unhealthy node, no instance found : {}", instanceId); return; } - log.info("Remove unhealthy node, node ID :: {}", instanceId); + log.info("Remove unhealthy node, node ID : {}", instanceId); } public void evict(long additionalLeaseMs) { @@ -150,7 +150,7 @@ public class BaseInstanceRegistry implements InstanceRegistry { if (!CollectionUtils.isEmpty(registerMap)) { registerMap.remove(id); AbstractSubjectCenter.notify(AbstractSubjectCenter.SubjectType.CLEAR_CONFIG_CACHE, () -> identify); - log.info("Clean up unhealthy nodes. Node id :: {}", id); + log.info("Clean up unhealthy nodes. Node id : {}", id); } return true; } diff --git a/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/inittest/TaskDecoratorTest.java b/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/inittest/TaskDecoratorTest.java index 05739ab9..efdad813 100644 --- a/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/inittest/TaskDecoratorTest.java +++ b/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/inittest/TaskDecoratorTest.java @@ -71,7 +71,7 @@ public class TaskDecoratorTest { * 此处打印不为空, taskDecorator 即为生效. * taskDecorator 配置查看 {@link ThreadPoolConfig#messageConsumeDynamicThreadPool()} */ - log.info("通过 taskDecorator MDC 传递上下文 :: {}", MDC.get(PLACEHOLDER)); + log.info("通过 taskDecorator MDC 传递上下文 : {}", MDC.get(PLACEHOLDER)); }); }); } diff --git a/hippo4j-message/src/main/java/cn/hippo4j/message/service/Hippo4jBaseSendMessageService.java b/hippo4j-message/src/main/java/cn/hippo4j/message/service/Hippo4jBaseSendMessageService.java index 93ffc794..f73de9c8 100644 --- a/hippo4j-message/src/main/java/cn/hippo4j/message/service/Hippo4jBaseSendMessageService.java +++ b/hippo4j-message/src/main/java/cn/hippo4j/message/service/Hippo4jBaseSendMessageService.java @@ -63,7 +63,7 @@ public class Hippo4jBaseSendMessageService implements Hippo4jSendMessageService, try { SendMessageHandler messageHandler = sendMessageHandlers.get(each.getPlatform()); if (messageHandler == null) { - log.warn("Please configure alarm notification on the server. key :: [{}]", threadPoolId); + log.warn("Please configure alarm notification on the server. key: [{}]", threadPoolId); return; } if (isSendAlarm(each.getTpId(), each.getPlatform(), typeEnum)) { @@ -71,7 +71,7 @@ public class Hippo4jBaseSendMessageService implements Hippo4jSendMessageService, messageHandler.sendAlarmMessage(each, alarmNotifyRequest); } } catch (Exception ex) { - log.warn("Failed to send thread pool alarm notification. key :: [{}]", threadPoolId, ex); + log.warn("Failed to send thread pool alarm notification. key: [{}]", threadPoolId, ex); } }); } @@ -82,19 +82,19 @@ public class Hippo4jBaseSendMessageService implements Hippo4jSendMessageService, String buildKey = StrUtil.builder(threadPoolId, "+", "CONFIG").toString(); List notifyList = notifyConfigs.get(buildKey); if (CollUtil.isEmpty(notifyList)) { - log.warn("Please configure alarm notification on the server. key :: [{}]", threadPoolId); + log.warn("Please configure alarm notification on the server. key: [{}]", threadPoolId); return; } notifyList.forEach(each -> { try { SendMessageHandler messageHandler = sendMessageHandlers.get(each.getPlatform()); if (messageHandler == null) { - log.warn("Please configure alarm notification on the server. key :: [{}]", threadPoolId); + log.warn("Please configure alarm notification on the server. key: [{}]", threadPoolId); return; } messageHandler.sendChangeMessage(each, changeParameterNotifyRequest); } catch (Exception ex) { - log.warn("Failed to send thread pool change notification. key :: [{}]", threadPoolId, ex); + log.warn("Failed to send thread pool change notification. key: [{}]", threadPoolId, ex); } }); } diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/ExecutorsListener.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/ExecutorsListener.java index 7bfdac5b..158ce965 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/ExecutorsListener.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/ExecutorsListener.java @@ -86,7 +86,7 @@ public class ExecutorsListener implements ApplicationListener