Skip to content

Commit

Permalink
Log print content optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
magestacks committed Aug 6, 2022
1 parent df628c5 commit b9e3d72
Show file tree
Hide file tree
Showing 19 changed files with 40 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -168,7 +168,7 @@ public void updateWebThreadPool(ThreadPoolParameterInfo threadPoolParameterInfo)
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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void updateWebThreadPool(ThreadPoolParameterInfo threadPoolParameterInfo)
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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
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";
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static void notify(String subject, ObserverMessage observerMessage) {
try {
each.accept(observerMessage);
} catch (Exception ex) {
log.error("Notification subject :: {} observer exception", subject);
log.error("Notification subject: {} observer exception", subject);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private void openEventHandler() {
UPDATER.compareAndSet(this, lastEventSequence, Math.max(lastEventSequence, event.sequence()));
}
} catch (Throwable ex) {
log.error("Event listener exception :: {}", ex);
log.error("Event listener exception: {}", ex);
}
}

Expand All @@ -111,7 +111,7 @@ public void addSubscriber(AbstractSubscriber subscriber) {
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;
}
Expand All @@ -130,7 +130,7 @@ public void notifySubscriber(AbstractSubscriber subscriber, AbstractEvent event)
try {
job.run();
} catch (Throwable e) {
log.error("Event callback exception :: {}", e);
log.error("Event callback exception : {}", e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
Expand Down Expand Up @@ -98,7 +98,7 @@ public static boolean publishEvent(final AbstractEvent event) {
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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static String getContentMd5(String groupKey) {
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);
Expand Down Expand Up @@ -178,7 +178,7 @@ private synchronized static void coarseRemove(String coarse) {
List<String> identificationList = MapUtil.parseMapForFilter(CLIENT_CONFIG_CACHE, coarse);
for (String cacheMapKey : identificationList) {
Map<String, CacheItem> 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));
}
}

Expand All @@ -189,7 +189,7 @@ static class ClearConfigCache implements Observer<String> {

@Override
public void accept(ObserverMessage<String> observerMessage) {
log.info("Clean up the configuration cache. Key :: {}", observerMessage.message());
log.info("Clean up the configuration cache. Key : {}", observerMessage.message());
coarseRemove(observerMessage.message());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class StatTask implements Runnable {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public Long addConfigInfo(ConfigAllInfo config) {
}
}
} catch (Exception ex) {
log.error("[db-error] message :: {}", ex.getMessage(), ex);
log.error("[db-error] message : {}", ex.getMessage(), ex);
throw ex;
}
return null;
Expand Down Expand Up @@ -192,7 +192,7 @@ public void updateConfigInfo(String identify, boolean isChangeNotice, ConfigAllI
}
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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static DynamicThreadPoolExecutor buildDynamicPool(ThreadPoolInitParam ini
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public Result<Void> addInstance(@RequestBody InstanceInfo instanceInfo) {
public Result<Void> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ public void remove(InstanceInfo info) {
String instanceId = info.getInstanceId();
Map<String, Lease<InstanceInfo>> 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<InstanceInfo> 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) {
Expand Down Expand Up @@ -150,7 +150,7 @@ protected boolean internalCancel(String appName, String id, String identify) {
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void taskDecoratorTest() {
* 此处打印不为空, taskDecorator 即为生效.
* taskDecorator 配置查看 {@link ThreadPoolConfig#messageConsumeDynamicThreadPool()}
*/
log.info("通过 taskDecorator MDC 传递上下文 :: {}", MDC.get(PLACEHOLDER));
log.info("通过 taskDecorator MDC 传递上下文 : {}", MDC.get(PLACEHOLDER));
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ public void sendAlarmMessage(NotifyTypeEnum typeEnum, AlarmNotifyRequest alarmNo
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)) {
alarmNotifyRequest.setNotifyTypeEnum(typeEnum);
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);
}
});
}
Expand All @@ -82,19 +82,19 @@ public void sendChangeMessage(ChangeParameterNotifyRequest changeParameterNotify
String buildKey = StrUtil.builder(threadPoolId, "+", "CONFIG").toString();
List<NotifyConfigDTO> 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);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void onApplicationEvent(Hippo4jCoreDynamicRefreshEvent threadPoolDynamicR
// refresh executor properties.
GlobalCoreThreadPoolManage.refresh(threadPoolId, properties);
log.info(CHANGE_THREAD_POOL_TEXT,
threadPoolId.toUpperCase(),
threadPoolId,
String.format(CHANGE_DELIMITER, beforeProperties.getCorePoolSize(), properties.getCorePoolSize()),
String.format(CHANGE_DELIMITER, beforeProperties.getMaximumPoolSize(), properties.getMaximumPoolSize()),
String.format(CHANGE_DELIMITER, beforeProperties.getBlockingQueue(), properties.getBlockingQueue()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void refreshDynamicPool(ThreadPoolParameter parameter, ThreadPoolExecutor
request.setNowExecuteTimeOut(originalExecuteTimeOut);
threadPoolNotifyAlarmHandler.sendPoolConfigChange(request);
log.info(CHANGE_THREAD_POOL_TEXT,
threadPoolId.toUpperCase(),
threadPoolId,
String.format(CHANGE_DELIMITER, originalCoreSize, afterExecutor.getCorePoolSize()),
String.format(CHANGE_DELIMITER, originalMaximumPoolSize, afterExecutor.getMaximumPoolSize()),
String.format(CHANGE_DELIMITER, originalQuery, QueueTypeEnum.getBlockingQueueNameByType(parameter.getQueueType())),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public String restApiPost(String url, Object body) {
try {
return doPost(url, body);
} catch (Exception e) {
log.error("httpPost 调用失败. {} message :: {}", url, e.getMessage());
log.error("httpPost 调用失败. {} message : {}", url, e.getMessage());
throw e;
}
}
Expand Down

0 comments on commit b9e3d72

Please sign in to comment.