diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/ThreadPoolNotifyAlarmHandler.java b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/ThreadPoolNotifyAlarmHandler.java index 53489a23..77237dd4 100644 --- a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/ThreadPoolNotifyAlarmHandler.java +++ b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/ThreadPoolNotifyAlarmHandler.java @@ -23,7 +23,7 @@ import cn.hippo4j.core.executor.manage.GlobalNotifyAlarmManage; import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage; import cn.hippo4j.core.executor.support.ThreadPoolBuilder; import cn.hippo4j.core.toolkit.IdentifyUtil; -import cn.hippo4j.core.toolkit.TraceContextUtil; +import cn.hippo4j.core.toolkit.ExecutorTraceContextUtil; import cn.hippo4j.message.service.Hippo4jSendMessageService; import cn.hippo4j.message.enums.NotifyTypeEnum; import cn.hippo4j.message.service.ThreadPoolNotifyAlarm; @@ -178,7 +178,7 @@ public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner alarmNotifyRequest.setThreadPoolId(threadPoolId); alarmNotifyRequest.setExecuteTime(executeTime); alarmNotifyRequest.setExecuteTimeOut(executeTimeOut); - String executeTimeoutTrace = TraceContextUtil.getAndRemove(); + String executeTimeoutTrace = ExecutorTraceContextUtil.getAndRemoveTimeoutTrace(); if (StringUtil.isNotBlank(executeTimeoutTrace)) { alarmNotifyRequest.setExecuteTimeoutTrace(executeTimeoutTrace); } diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/ExecutorContext.java b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/ExecutorContext.java deleted file mode 100644 index 7cd2db56..00000000 --- a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/ExecutorContext.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.hippo4j.core.executor.support; - -import org.slf4j.MDC; - -import static cn.hippo4j.common.constant.Constants.EXECUTE_TIMEOUT_TRACE; - -/** - * Executor context. - */ -public class ExecutorContext { - - /** - * Put execute timeout trace. - * - * @param executeTimeoutTrace - */ - public static void putExecuteTimeoutTrace(String executeTimeoutTrace) { - MDC.put(EXECUTE_TIMEOUT_TRACE, executeTimeoutTrace); - } -} diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/toolkit/TraceContextUtil.java b/hippo4j-core/src/main/java/cn/hippo4j/core/toolkit/ExecutorTraceContextUtil.java similarity index 85% rename from hippo4j-core/src/main/java/cn/hippo4j/core/toolkit/TraceContextUtil.java rename to hippo4j-core/src/main/java/cn/hippo4j/core/toolkit/ExecutorTraceContextUtil.java index 8071d1dc..541c821d 100644 --- a/hippo4j-core/src/main/java/cn/hippo4j/core/toolkit/TraceContextUtil.java +++ b/hippo4j-core/src/main/java/cn/hippo4j/core/toolkit/ExecutorTraceContextUtil.java @@ -24,7 +24,7 @@ import static cn.hippo4j.common.constant.Constants.EXECUTE_TIMEOUT_TRACE; /** * Trace context util. */ -public class TraceContextUtil { +public class ExecutorTraceContextUtil { /** * Execute timeout trace key. @@ -36,19 +36,19 @@ public class TraceContextUtil { * * @return */ - public static String getAndRemove() { + public static String getAndRemoveTimeoutTrace() { String val = MDC.get(EXECUTE_TIMEOUT_TRACE_KEY); MDC.remove(EXECUTE_TIMEOUT_TRACE_KEY); return val; } /** - * set. + * Put execute timeout trace. * - * @return + * @param trace */ - public static void set(String trace) { - MDC.put(EXECUTE_TIMEOUT_TRACE_KEY, trace); + public static void putExecuteTimeoutTrace(String trace) { + MDC.put(EXECUTE_TIMEOUT_TRACE, trace); } /** @@ -59,4 +59,5 @@ public class TraceContextUtil { public static void setExecuteTimeoutTraceKey(String key) { EXECUTE_TIMEOUT_TRACE_KEY = key; } + } diff --git a/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/handler/TaskTraceBuilderHandler.java b/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/handler/TaskTraceBuilderHandler.java index d475d6eb..e557fe8f 100644 --- a/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/handler/TaskTraceBuilderHandler.java +++ b/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/handler/TaskTraceBuilderHandler.java @@ -18,7 +18,7 @@ package cn.hippo4j.example.core.handler; import cn.hippo4j.common.toolkit.StringUtil; -import cn.hippo4j.core.executor.support.ExecutorContext; +import cn.hippo4j.core.toolkit.ExecutorTraceContextUtil; import org.slf4j.MDC; import org.springframework.core.task.TaskDecorator; @@ -34,7 +34,7 @@ public final class TaskTraceBuilderHandler implements TaskDecorator { String executeTimeoutTrace = MDC.get(EXECUTE_TIMEOUT_TRACE); Runnable taskRun = () -> { if (StringUtil.isNotBlank(executeTimeoutTrace)) { - ExecutorContext.putExecuteTimeoutTrace(executeTimeoutTrace); + ExecutorTraceContextUtil.putExecuteTimeoutTrace(executeTimeoutTrace); } runnable.run(); // There is no need to clean up here, and it will be cleaned up after the thread task is executed.