diff --git a/doc/sql/easy_retry_mysql.sql b/doc/sql/easy_retry_mysql.sql index 8e9ee0c78..55dc4016d 100644 --- a/doc/sql/easy_retry_mysql.sql +++ b/doc/sql/easy_retry_mysql.sql @@ -412,7 +412,7 @@ CREATE TABLE `job_summary` `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', `namespace_id` VARCHAR(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', `group_name` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '组名称', - `job_id` bigint NOT NULL COMMENT '任务信息id', +ji `business_id` bigint NOT NULL COMMENT '业务id (job_id或workflow_id)', `trigger_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '统计时间', `success_num` int NOT NULL DEFAULT '0' COMMENT '执行成功-日志数量', `fail_num` int NOT NULL DEFAULT '0' COMMENT '执行失败-日志数量', @@ -424,8 +424,8 @@ CREATE TABLE `job_summary` `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', PRIMARY KEY (`id`), - KEY `idx_namespace_id_group_name_job_id` (`namespace_id`, `group_name`, job_id), - UNIQUE KEY `uk_job_id_trigger_at` (`job_id`, `trigger_at`) USING BTREE + KEY `idx_namespace_id_group_name_business_id` (`namespace_id`, `group_name`, business_id), + UNIQUE KEY `uk_business_id_trigger_at` (`business_id`, `trigger_at`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT ='DashBoard_Job'; diff --git a/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/config/EasyRetryProperties.java b/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/config/EasyRetryProperties.java index e6e27acd6..1944eeba0 100644 --- a/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/config/EasyRetryProperties.java +++ b/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/config/EasyRetryProperties.java @@ -123,7 +123,7 @@ public class EasyRetryProperties { } public static String getGroup() { - EasyRetryProperties properties = SpringContext.CONTEXT.getBean(EasyRetryProperties.class); + EasyRetryProperties properties = SpringContext.getBean(EasyRetryProperties.class); return Objects.requireNonNull(properties).group; } } diff --git a/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/init/EasyRetryCloseListener.java b/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/init/EasyRetryCloseListener.java index 610cba7af..021394564 100644 --- a/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/init/EasyRetryCloseListener.java +++ b/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/init/EasyRetryCloseListener.java @@ -6,6 +6,7 @@ import com.aizuda.easy.retry.client.common.event.EasyRetryClosingEvent; import com.aizuda.easy.retry.client.common.event.EasyRetryStartingEvent; import com.aizuda.easy.retry.common.core.context.SpringContext; import com.aizuda.easy.retry.common.core.util.EasyRetryVersion; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationListener; @@ -22,18 +23,17 @@ import java.util.List; * @since 1.0.0 */ @Component +@RequiredArgsConstructor @Slf4j public class EasyRetryCloseListener implements ApplicationListener { - - @Autowired - private List lifecycleList; + private final List lifecycleList; @Override public void onApplicationEvent(ContextClosedEvent event) { log.info("Easy-Retry client about to shutdown v{}", EasyRetryVersion.getVersion()); - SpringContext.CONTEXT.publishEvent(new EasyRetryClosingEvent()); + SpringContext.getContext().publishEvent(new EasyRetryClosingEvent()); lifecycleList.forEach(Lifecycle::close); - SpringContext.CONTEXT.publishEvent(new EasyRetryClosedEvent()); + SpringContext.getContext().publishEvent(new EasyRetryClosedEvent()); log.info("Easy-Retry client closed successfully v{}", EasyRetryVersion.getVersion()); } } diff --git a/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/init/EasyRetryStartListener.java b/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/init/EasyRetryStartListener.java index c0b7071d1..f6fe27a7a 100644 --- a/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/init/EasyRetryStartListener.java +++ b/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/init/EasyRetryStartListener.java @@ -37,9 +37,9 @@ public class EasyRetryStartListener implements ApplicationRunner { System.out.println(MessageFormatter.format(SystemConstants.LOGO, EasyRetryVersion.getVersion()).getMessage()); EasyRetryLog.LOCAL.info("Easy-Retry client is preparing to start... v{}", EasyRetryVersion.getVersion()); - SpringContext.CONTEXT.publishEvent(new EasyRetryStartingEvent()); + SpringContext.getContext().publishEvent(new EasyRetryStartingEvent()); lifecycleList.forEach(Lifecycle::start); - SpringContext.CONTEXT.publishEvent(new EasyRetryStartedEvent()); + SpringContext.getContext().publishEvent(new EasyRetryStartedEvent()); isStarted = true; EasyRetryLog.LOCAL.info("Easy-Retry client started successfully v{}", EasyRetryVersion.getVersion()); } diff --git a/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/netty/NettyChannel.java b/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/netty/NettyChannel.java index f3520fa31..22130f795 100644 --- a/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/netty/NettyChannel.java +++ b/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/netty/NettyChannel.java @@ -69,7 +69,7 @@ public class NettyChannel { * @return port */ public static int getServerPort() { - EasyRetryProperties easyRetryProperties = SpringContext.CONTEXT.getBean(EasyRetryProperties.class); + EasyRetryProperties easyRetryProperties = SpringContext.getContext().getBean(EasyRetryProperties.class); EasyRetryProperties.ServerConfig serverConfig = easyRetryProperties.getServer(); String port = System.getProperty(EASY_RETRY_SERVER_PORT); @@ -86,7 +86,7 @@ public class NettyChannel { * @return host */ public static String getServerHost() { - EasyRetryProperties easyRetryProperties = SpringContext.CONTEXT.getBean(EasyRetryProperties.class); + EasyRetryProperties easyRetryProperties = SpringContext.getBean(EasyRetryProperties.class); EasyRetryProperties.ServerConfig serverConfig = easyRetryProperties.getServer(); String host = System.getProperty(EASY_RETRY_SERVER_HOST); @@ -103,7 +103,7 @@ public class NettyChannel { * @return 客户端IP */ public static String getClientHost() { - EasyRetryProperties easyRetryProperties = SpringContext.CONTEXT.getBean(EasyRetryProperties.class); + EasyRetryProperties easyRetryProperties = SpringContext.getBean(EasyRetryProperties.class); String host = easyRetryProperties.getHost(); // 获取客户端指定的IP地址 @@ -120,8 +120,8 @@ public class NettyChannel { * @return port 端口 */ public static Integer getClientPort() { - EasyRetryProperties easyRetryProperties = SpringContext.CONTEXT.getBean(EasyRetryProperties.class); - ServerProperties serverProperties = SpringContext.CONTEXT.getBean(ServerProperties.class); + EasyRetryProperties easyRetryProperties = SpringContext.getBean(EasyRetryProperties.class); + ServerProperties serverProperties = SpringContext.getBean(ServerProperties.class); Integer port = easyRetryProperties.getPort(); // 获取客户端指定的端口 @@ -156,8 +156,8 @@ public class NettyChannel { FullHttpRequest request = new DefaultFullHttpRequest( HttpVersion.HTTP_1_1, method, url, Unpooled.wrappedBuffer(body.getBytes(StandardCharsets.UTF_8))); - ServerProperties serverProperties = SpringContext.CONTEXT.getBean(ServerProperties.class); - EasyRetryProperties easyRetryProperties = SpringContext.CONTEXT.getBean(EasyRetryProperties.class); + ServerProperties serverProperties = SpringContext.getBean(ServerProperties.class); + EasyRetryProperties easyRetryProperties = SpringContext.getBean(EasyRetryProperties.class); // server配置不能为空 EasyRetryProperties.ServerConfig serverConfig = easyRetryProperties.getServer(); diff --git a/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/netty/NettyHttpClientHandler.java b/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/netty/NettyHttpClientHandler.java index e47ddd525..c51e08eff 100644 --- a/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/netty/NettyHttpClientHandler.java +++ b/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/netty/NettyHttpClientHandler.java @@ -67,7 +67,7 @@ public class NettyHttpClientHandler extends SimpleChannelInboundHandler { try { // 抛出重连事件 - SpringContext.CONTEXT.publishEvent(new ChannelReconnectEvent()); + SpringContext.getContext().publishEvent(new ChannelReconnectEvent()); nettyHttpConnectClient.reconnect(); } catch (Exception e) { EasyRetryLog.LOCAL.error("reconnect error ", e); diff --git a/easy-retry-client/easy-retry-client-core/src/main/java/com/aizuda/easy/retry/client/core/report/ReportListener.java b/easy-retry-client/easy-retry-client-core/src/main/java/com/aizuda/easy/retry/client/core/report/ReportListener.java index 44f836cbf..4a4eae907 100644 --- a/easy-retry-client/easy-retry-client-core/src/main/java/com/aizuda/easy/retry/client/core/report/ReportListener.java +++ b/easy-retry-client/easy-retry-client-core/src/main/java/com/aizuda/easy/retry/client/core/report/ReportListener.java @@ -112,7 +112,7 @@ public class ReportListener implements Listener { return; } - EasyRetryProperties properties = SpringContext.CONTEXT.getBean(EasyRetryProperties.class); + EasyRetryProperties properties = SpringContext.getBean(EasyRetryProperties.class); AlarmContext context = AlarmContext.build() .text(reportErrorTextMessageFormatter, EnvironmentUtils.getActiveProfile(),