Log print content optimization

pull/487/head
chen.ma 2 years ago
parent df628c5a8f
commit b9e3d726ec

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

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

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

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

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

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

@ -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<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));
}
}
@ -189,7 +189,7 @@ public class ConfigCacheService {
@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());
}
}

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

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

@ -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)) {

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

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

@ -58,7 +58,7 @@ public class ApplicationController {
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();

@ -113,15 +113,15 @@ public class BaseInstanceRegistry implements InstanceRegistry<InstanceInfo> {
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) {
@ -150,7 +150,7 @@ public class BaseInstanceRegistry implements InstanceRegistry<InstanceInfo> {
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;
}

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

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

@ -86,7 +86,7 @@ public class ExecutorsListener implements ApplicationListener<Hippo4jCoreDynamic
// 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()),

@ -104,7 +104,7 @@ public class ServerThreadPoolDynamicRefresh implements ThreadPoolDynamicRefresh
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())),

@ -121,7 +121,7 @@ public class HttpClientUtil {
try {
return doPost(url, body);
} catch (Exception e) {
log.error("httpPost 调用失败. {} message :: {}", url, e.getMessage());
log.error("httpPost 调用失败. {} message : {}", url, e.getMessage());
throw e;
}
}

Loading…
Cancel
Save