From 97625a67851c4b9205f828d68f82e1446bb21540 Mon Sep 17 00:00:00 2001 From: xuxueli <931591021@qq.com> Date: Tue, 19 Nov 2019 14:30:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E8=A7=A6=E5=8F=91=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=8A=A0=E8=BD=BD=E9=A1=BA=E5=BA=8F=E8=B0=83=E6=95=B4?= =?UTF-8?q?=EF=BC=8C=E9=81=BF=E5=85=8D=E5=B0=8F=E6=A6=82=E7=8E=87=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8B=E7=BB=84=E4=BB=B6=E9=9A=8F=E6=9C=BA=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E9=A1=BA=E5=BA=8F=E5=AF=BC=E8=87=B4=E7=9A=84I18N?= =?UTF-8?q?=E7=9A=84NPE=E9=97=AE=E9=A2=98;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/XXL-JOB官方文档.md | 2 +- .../admin/controller/JobApiController.java | 2 +- .../admin/controller/JobLogController.java | 2 +- .../xxl/job/admin/core/conf/XxlJobAdminBean | 27 ------------------- .../admin/core/conf/XxlJobAdminConfig.java | 27 ++++++++++++++++--- .../route/strategy/ExecutorRouteBusyover.java | 2 +- .../route/strategy/ExecutorRouteFailover.java | 2 +- .../{conf => scheduler}/XxlJobScheduler.java | 8 ++---- .../job/admin/core/trigger/XxlJobTrigger.java | 2 +- 9 files changed, 32 insertions(+), 42 deletions(-) delete mode 100644 xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminBean rename xxl-job-admin/src/main/java/com/xxl/job/admin/core/{conf => scheduler}/XxlJobScheduler.java (94%) diff --git a/doc/XXL-JOB官方文档.md b/doc/XXL-JOB官方文档.md index 728c5d14..dd3d8a06 100644 --- a/doc/XXL-JOB官方文档.md +++ b/doc/XXL-JOB官方文档.md @@ -1573,7 +1573,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段 - 6、调度组件优化:针对永远不会触发的Cron禁止配置和启动;任务Cron最后一次触发后再也不会触发时,比如一次性任务,主动停止相关任务; - 7、任务列表交互优化,支持查看任务所属执行器的注册节点; - 8、DB重连优化,修复DB宕机重连后任务调度停止的问题,重连后自动加入调度集群触发任务调度; -- 9、任务触发组件加载顺序调整,避免小概率情况下组件随机加载顺序导致的I18N的NPE问题。 +- 9、任务触发组件加载顺序调整,避免小概率情况下组件随机加载顺序导致的I18N的NPE问题; - 10、项目依赖升级至较新稳定版本,如spring、spring-boot、mybatis、slf4j、groovy等等; - 11、JobThread自销毁优化,避免并发触发导致triggerQueue中任务丢失问题; - 12、[ING,交互兼容问题待处理]Cron在线生成工具:任务新增、编辑框通过组件在线生成Cron表达式; diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobApiController.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobApiController.java index 2a6c738f..2198395a 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobApiController.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobApiController.java @@ -1,7 +1,7 @@ package com.xxl.job.admin.controller; import com.xxl.job.admin.controller.annotation.PermissionLimit; -import com.xxl.job.admin.core.conf.XxlJobScheduler; +import com.xxl.job.admin.core.scheduler.XxlJobScheduler; import com.xxl.job.core.biz.AdminBiz; import org.springframework.beans.factory.InitializingBean; import org.springframework.stereotype.Controller; diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java index 62929c09..f313f037 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java @@ -1,6 +1,6 @@ package com.xxl.job.admin.controller; -import com.xxl.job.admin.core.conf.XxlJobScheduler; +import com.xxl.job.admin.core.scheduler.XxlJobScheduler; import com.xxl.job.admin.core.exception.XxlJobException; import com.xxl.job.admin.core.model.XxlJobGroup; import com.xxl.job.admin.core.model.XxlJobInfo; diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminBean b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminBean deleted file mode 100644 index 32b78eae..00000000 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminBean +++ /dev/null @@ -1,27 +0,0 @@ -package com.xxl.job.admin.conf; - -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @Auther: zhuolin.ji - * @Date: 2019/10/12 18:08 - * @Package: com.xxl.job.admin.conf - * @Description: - */ -@Configuration -public class XxlJobAdminBean { - - @Bean(name = "xxlJobAdminConfig") - public XxlJobAdminConfig getXxlJobAdminConfig() { - return new XxlJobAdminConfig(); - } - - @Bean(initMethod = "init", destroyMethod = "destroy") - public XxlJobScheduler getXxlJobScheduler(@Qualifier(value = "xxlJobAdminConfig") XxlJobAdminConfig xxlJobAdminConfig) { - XxlJobAdminConfig.setAdminConfig(xxlJobAdminConfig); - return new XxlJobScheduler(); - } - -} diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminConfig.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminConfig.java index 8eb91da6..b57b88bd 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminConfig.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminConfig.java @@ -1,10 +1,12 @@ package com.xxl.job.admin.core.conf; +import com.xxl.job.admin.core.scheduler.XxlJobScheduler; import com.xxl.job.admin.dao.XxlJobGroupDao; import com.xxl.job.admin.dao.XxlJobInfoDao; import com.xxl.job.admin.dao.XxlJobLogDao; import com.xxl.job.admin.dao.XxlJobRegistryDao; import com.xxl.job.core.biz.AdminBiz; +import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Value; import org.springframework.mail.javamail.JavaMailSender; @@ -19,16 +21,35 @@ import javax.sql.DataSource; * @author xuxueli 2017-04-28 */ -public class XxlJobAdminConfig { +@Component +public class XxlJobAdminConfig implements InitializingBean, DisposableBean { + private static XxlJobAdminConfig adminConfig = null; public static XxlJobAdminConfig getAdminConfig() { return adminConfig; } - public static void setAdminConfig(XxlJobAdminConfig config) { - XxlJobAdminConfig.adminConfig = config; + + // ---------------------- XxlJobScheduler ---------------------- + + private XxlJobScheduler xxlJobScheduler; + + @Override + public void afterPropertiesSet() throws Exception { + adminConfig = this; + + xxlJobScheduler = new XxlJobScheduler(); + xxlJobScheduler.init(); } + @Override + public void destroy() throws Exception { + xxlJobScheduler.destroy(); + } + + + // ---------------------- XxlJobScheduler ---------------------- + // conf @Value("${xxl.job.i18n}") private String i18n; diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/route/strategy/ExecutorRouteBusyover.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/route/strategy/ExecutorRouteBusyover.java index 992b4ceb..26015991 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/route/strategy/ExecutorRouteBusyover.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/route/strategy/ExecutorRouteBusyover.java @@ -1,6 +1,6 @@ package com.xxl.job.admin.core.route.strategy; -import com.xxl.job.admin.core.conf.XxlJobScheduler; +import com.xxl.job.admin.core.scheduler.XxlJobScheduler; import com.xxl.job.admin.core.route.ExecutorRouter; import com.xxl.job.admin.core.util.I18nUtil; import com.xxl.job.core.biz.ExecutorBiz; diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/route/strategy/ExecutorRouteFailover.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/route/strategy/ExecutorRouteFailover.java index 26aaa067..a2e4c909 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/route/strategy/ExecutorRouteFailover.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/route/strategy/ExecutorRouteFailover.java @@ -1,6 +1,6 @@ package com.xxl.job.admin.core.route.strategy; -import com.xxl.job.admin.core.conf.XxlJobScheduler; +import com.xxl.job.admin.core.scheduler.XxlJobScheduler; import com.xxl.job.admin.core.route.ExecutorRouter; import com.xxl.job.admin.core.util.I18nUtil; import com.xxl.job.core.biz.ExecutorBiz; diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobScheduler.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/scheduler/XxlJobScheduler.java similarity index 94% rename from xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobScheduler.java rename to xxl-job-admin/src/main/java/com/xxl/job/admin/core/scheduler/XxlJobScheduler.java index 52deb23e..cc73c840 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobScheduler.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/scheduler/XxlJobScheduler.java @@ -1,5 +1,6 @@ -package com.xxl.job.admin.core.conf; +package com.xxl.job.admin.core.scheduler; +import com.xxl.job.admin.core.conf.XxlJobAdminConfig; import com.xxl.job.admin.core.thread.JobFailMonitorHelper; import com.xxl.job.admin.core.thread.JobRegistryMonitorHelper; import com.xxl.job.admin.core.thread.JobScheduleHelper; @@ -18,10 +19,6 @@ import com.xxl.rpc.remoting.provider.XxlRpcProviderFactory; import com.xxl.rpc.serialize.Serializer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.DisposableBean; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.context.annotation.DependsOn; -import org.springframework.stereotype.Component; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -38,7 +35,6 @@ public class XxlJobScheduler { private static final Logger logger = LoggerFactory.getLogger(XxlJobScheduler.class); - public void init() throws Exception { // init i18n initI18n(); diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/trigger/XxlJobTrigger.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/trigger/XxlJobTrigger.java index 7b3971c7..04bde35b 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/trigger/XxlJobTrigger.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/trigger/XxlJobTrigger.java @@ -1,7 +1,7 @@ package com.xxl.job.admin.core.trigger; import com.xxl.job.admin.core.conf.XxlJobAdminConfig; -import com.xxl.job.admin.core.conf.XxlJobScheduler; +import com.xxl.job.admin.core.scheduler.XxlJobScheduler; import com.xxl.job.admin.core.model.XxlJobGroup; import com.xxl.job.admin.core.model.XxlJobInfo; import com.xxl.job.admin.core.model.XxlJobLog;