From 4fa63e3aae9f6c438d3dc4949d533fb6a6b7db27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E4=BC=A0=E6=96=87?= Date: Thu, 7 Nov 2019 18:34:47 +0800 Subject: [PATCH 1/2] Fix typos and clean some code... --- doc/XXL-JOB-English-Documentation.md | 4 ++-- .../job/admin/controller/JobApiController.java | 2 +- .../job/admin/controller/JobLogController.java | 2 +- .../job/admin/core/conf/XxlJobAdminConfig.java | 2 +- .../xxl/job/admin/core/conf/XxlJobScheduler.java | 4 ++-- .../xxl/job/admin/core/cron/CronExpression.java | 2 -- .../job/admin/core/old/RemoteHttpJobBean.java | 2 +- .../core/route/strategy/ExecutorRouteLRU.java | 2 +- .../job/admin/core/thread/JobScheduleHelper.java | 10 +++++----- .../xxl/job/admin/core/util/LocalCacheUtil.java | 4 ++-- .../com/xxl/job/admin/dao/XxlJobRegistryDao.java | 2 +- .../xxl/job/admin/service/impl/AdminBizImpl.java | 6 +++--- .../admin/service/impl/XxlJobServiceImpl.java | 6 +++--- .../xxl/job/core/biz/model/RegistryParam.java | 16 ++++++++-------- 14 files changed, 31 insertions(+), 33 deletions(-) diff --git a/doc/XXL-JOB-English-Documentation.md b/doc/XXL-JOB-English-Documentation.md index bfc49ebb..8351f6aa 100644 --- a/doc/XXL-JOB-English-Documentation.md +++ b/doc/XXL-JOB-English-Documentation.md @@ -19,8 +19,8 @@ XXL-JOB is a lightweight distributed task scheduling framework, the core design - 1.Simple: support through the Web page on the task CRUD operation, simple operation, a minute to get started; - 2.Dynamic: support dynamic modification of task status, pause / resume tasks, and termination of running tasks,immediate effect; - 3.Dispatch center HA (center type): Dispatch with central design, "dispatch center" based on the cluster of Quartz implementation, can guarantee the scheduling - center HA; -- 4.Executer HA (Distributed): Task Distributed Execution, Task " Executer " supports cluster deployment to ensure that tasks perform HA; -- 5.Task Failover: Deploy the Excuter cluster,tasks will be smooth to switch excuter when the strategy of the router choose ‘failover’; +- 4.Executor HA (Distributed): Task Distributed Execution, Task " Executer " supports cluster deployment to ensure that tasks perform HA; +- 5.Task Failover: Deploy the Excutor cluster,tasks will be smooth to switch excuter when the strategy of the router choose ‘failover’; - 6.Consistency: "Dispatch Center" through the DB lock to ensure the consistency of cluster distributed scheduling,one task excuted for once; - 7.Custom task parameters: support online configuration scheduling tasks into the parameters, immediate effect; - 8.Scheduling thread pool: scheduling system multi-threaded trigger scheduling operation, to ensure accurate scheduling, not blocked; 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..23dc406f 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 @@ -20,7 +20,7 @@ public class JobApiController implements InitializingBean { @Override - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { } 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..a32e71af 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 @@ -96,7 +96,7 @@ public class JobLogController { Date triggerTimeEnd = null; if (filterTime!=null && filterTime.trim().length()>0) { String[] temp = filterTime.split(" - "); - if (temp!=null && temp.length == 2) { + if (temp.length == 2) { triggerTimeStart = DateUtil.parseDateTime(temp[0]); triggerTimeEnd = DateUtil.parseDateTime(temp[1]); } 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 1e348a32..68dd1fa1 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 @@ -26,7 +26,7 @@ public class XxlJobAdminConfig implements InitializingBean{ } @Override - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { adminConfig = this; } 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/conf/XxlJobScheduler.java index 8b51d51b..11e3ad62 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/conf/XxlJobScheduler.java @@ -40,7 +40,7 @@ public class XxlJobScheduler implements InitializingBean, DisposableBean { @Override - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { // init i18n initI18n(); @@ -116,7 +116,7 @@ public class XxlJobScheduler implements InitializingBean, DisposableBean { // ---------------------- executor-client ---------------------- private static ConcurrentMap executorBizRepository = new ConcurrentHashMap(); - public static ExecutorBiz getExecutorBiz(String address) throws Exception { + public static ExecutorBiz getExecutorBiz(String address) { // valid if (address==null || address.trim().length()==0) { return null; diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/cron/CronExpression.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/cron/CronExpression.java index d0f7f38d..fce23524 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/cron/CronExpression.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/cron/CronExpression.java @@ -952,7 +952,6 @@ public final class CronExpression implements Serializable, Cloneable { protected int skipWhiteSpace(int i, String s) { for (; i < s.length() && (s.charAt(i) == ' ' || s.charAt(i) == '\t'); i++) { - ; } return i; @@ -960,7 +959,6 @@ public final class CronExpression implements Serializable, Cloneable { protected int findNextWhiteSpace(int i, String s) { for (; i < s.length() && (s.charAt(i) != ' ' || s.charAt(i) != '\t'); i++) { - ; } return i; diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/old/RemoteHttpJobBean.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/old/RemoteHttpJobBean.java index bd640113..b2dd1515 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/old/RemoteHttpJobBean.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/old/RemoteHttpJobBean.java @@ -11,7 +11,7 @@ // ///** // * http job bean -// * “@DisallowConcurrentExecution” diable concurrent, thread size can not be only one, better given more +// * “@DisallowConcurrentExecution” disable concurrent, thread size can not be only one, better given more // * @author xuxueli 2015-12-17 18:20:34 // */ ////@DisallowConcurrentExecution diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/route/strategy/ExecutorRouteLRU.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/route/strategy/ExecutorRouteLRU.java index 56766838..2d540067 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/route/strategy/ExecutorRouteLRU.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/route/strategy/ExecutorRouteLRU.java @@ -35,7 +35,7 @@ public class ExecutorRouteLRU extends ExecutorRouter { if (lruItem == null) { /** * LinkedHashMap - * a、accessOrder:ture=访问顺序排序(get/put时排序);false=插入顺序排期; + * a、accessOrder:true=访问顺序排序(get/put时排序);false=插入顺序排期; * b、removeEldestEntry:新增元素时将会调用,返回true时会删除最老元素;可封装LinkedHashMap并重写该方法,比如定义最大容量,超出是返回true即可实现固定长度的LRU算法; */ lruItem = new LinkedHashMap(16, 0.75f, true); diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobScheduleHelper.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobScheduleHelper.java index 8e451c53..404851f1 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobScheduleHelper.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobScheduleHelper.java @@ -93,7 +93,7 @@ public class JobScheduleHelper { // 1、trigger JobTriggerPoolHelper.trigger(jobInfo.getId(), TriggerTypeEnum.CRON, -1, null, null); - logger.debug(">>>>>>>>>>> xxl-job, shecule push trigger : jobId = " + jobInfo.getId() ); + logger.debug(">>>>>>>>>>> xxl-job, schedule push trigger : jobId = " + jobInfo.getId() ); // 2、fresh next jobInfo.setTriggerLastTime(jobInfo.getTriggerNextTime()); @@ -177,9 +177,9 @@ public class JobScheduleHelper { if (null != preparedStatement) { try { preparedStatement.close(); - } catch (SQLException ignore) { + } catch (SQLException e) { if (!scheduleThreadToStop) { - logger.error(ignore.getMessage(), ignore); + logger.error(e.getMessage(), e); } } } @@ -238,7 +238,7 @@ public class JobScheduleHelper { // ring trigger logger.debug(">>>>>>>>>>> xxl-job, time-ring beat : " + nowSecond + " = " + Arrays.asList(ringItemData) ); - if (ringItemData!=null && ringItemData.size()>0) { + if (ringItemData.size() > 0) { // do trigger for (int jobId: ringItemData) { // do trigger @@ -291,7 +291,7 @@ public class JobScheduleHelper { } ringItemData.add(jobId); - logger.debug(">>>>>>>>>>> xxl-job, shecule push time-ring : " + ringSecond + " = " + Arrays.asList(ringItemData) ); + logger.debug(">>>>>>>>>>> xxl-job, schedule push time-ring : " + ringSecond + " = " + Arrays.asList(ringItemData) ); } public void toStop(){ diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/LocalCacheUtil.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/LocalCacheUtil.java index aa265948..fbab0613 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/LocalCacheUtil.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/LocalCacheUtil.java @@ -62,7 +62,7 @@ public class LocalCacheUtil { public static boolean set(String key, Object val, long cacheTime){ // clean timeout cache, before set new cache (avoid cache too much) - cleanTimeutCache(); + cleanTimeoutCache(); // set new cache if (key==null || key.trim().length()==0) { @@ -118,7 +118,7 @@ public class LocalCacheUtil { * * @return */ - public static boolean cleanTimeutCache(){ + public static boolean cleanTimeoutCache(){ if (!cacheRepository.keySet().isEmpty()) { for (String key: cacheRepository.keySet()) { LocalCacheData localCacheData = cacheRepository.get(key); diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobRegistryDao.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobRegistryDao.java index 779200b2..10706003 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobRegistryDao.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobRegistryDao.java @@ -26,7 +26,7 @@ public interface XxlJobRegistryDao { @Param("registryKey") String registryKey, @Param("registryValue") String registryValue); - public int registryDelete(@Param("registryGroup") String registGroup, + public int registryDelete(@Param("registryGroup") String registryGroup, @Param("registryKey") String registryKey, @Param("registryValue") String registryValue); diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/AdminBizImpl.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/AdminBizImpl.java index 108f5df3..92f5db26 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/AdminBizImpl.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/AdminBizImpl.java @@ -126,9 +126,9 @@ public class AdminBizImpl implements AdminBiz { @Override public ReturnT registry(RegistryParam registryParam) { - int ret = xxlJobRegistryDao.registryUpdate(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue()); + int ret = xxlJobRegistryDao.registryUpdate(registryParam.getRegistryGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue()); if (ret < 1) { - xxlJobRegistryDao.registrySave(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue()); + xxlJobRegistryDao.registrySave(registryParam.getRegistryGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue()); // fresh freshGroupRegistryInfo(registryParam); @@ -138,7 +138,7 @@ public class AdminBizImpl implements AdminBiz { @Override public ReturnT registryRemove(RegistryParam registryParam) { - int ret = xxlJobRegistryDao.registryDelete(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue()); + int ret = xxlJobRegistryDao.registryDelete(registryParam.getRegistryGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue()); if (ret > 0) { // fresh diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java index 1bd746ad..9bbbf3ac 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java @@ -284,18 +284,18 @@ public class XxlJobServiceImpl implements XxlJobService { int jobLogSuccessCount = xxlJobLogDao.triggerCountByHandleCode(ReturnT.SUCCESS_CODE); // executor count - Set executerAddressSet = new HashSet(); + Set executorAddressSet = new HashSet(); List groupList = xxlJobGroupDao.findAll(); if (groupList!=null && !groupList.isEmpty()) { for (XxlJobGroup group: groupList) { if (group.getRegistryList()!=null && !group.getRegistryList().isEmpty()) { - executerAddressSet.addAll(group.getRegistryList()); + executorAddressSet.addAll(group.getRegistryList()); } } } - int executorCount = executerAddressSet.size(); + int executorCount = executorAddressSet.size(); Map dashboardMap = new HashMap(); dashboardMap.put("jobInfoCount", jobInfoCount); diff --git a/xxl-job-core/src/main/java/com/xxl/job/core/biz/model/RegistryParam.java b/xxl-job-core/src/main/java/com/xxl/job/core/biz/model/RegistryParam.java index 8747a9bd..8526c3e2 100644 --- a/xxl-job-core/src/main/java/com/xxl/job/core/biz/model/RegistryParam.java +++ b/xxl-job-core/src/main/java/com/xxl/job/core/biz/model/RegistryParam.java @@ -8,23 +8,23 @@ import java.io.Serializable; public class RegistryParam implements Serializable { private static final long serialVersionUID = 42L; - private String registGroup; + private String registryGroup; private String registryKey; private String registryValue; public RegistryParam(){} - public RegistryParam(String registGroup, String registryKey, String registryValue) { - this.registGroup = registGroup; + public RegistryParam(String registryGroup, String registryKey, String registryValue) { + this.registryGroup = registryGroup; this.registryKey = registryKey; this.registryValue = registryValue; } - public String getRegistGroup() { - return registGroup; + public String getRegistryGroup() { + return registryGroup; } - public void setRegistGroup(String registGroup) { - this.registGroup = registGroup; + public void setRegistryGroup(String registryGroup) { + this.registryGroup = registryGroup; } public String getRegistryKey() { @@ -46,7 +46,7 @@ public class RegistryParam implements Serializable { @Override public String toString() { return "RegistryParam{" + - "registGroup='" + registGroup + '\'' + + "registryGroup='" + registryGroup + '\'' + ", registryKey='" + registryKey + '\'' + ", registryValue='" + registryValue + '\'' + '}'; From 56ef13576c08e1c006ee13efc14103305fb65182 Mon Sep 17 00:00:00 2001 From: Zhouchuanwen Date: Wed, 20 Nov 2019 15:04:55 +0800 Subject: [PATCH 2/2] Fix typos and clean some code. --- .../com/xxl/job/admin/core/conf/XxlJobAdminConfig.java | 2 +- .../com/xxl/job/admin/service/impl/AdminBizImpl.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) 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 b7224a62..e80be920 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 @@ -34,7 +34,7 @@ public class XxlJobAdminConfig implements InitializingBean, DisposableBean { private XxlJobScheduler xxlJobScheduler; @Override - public void afterPropertiesSet() { + public void afterPropertiesSet() throws Exception { adminConfig = this; xxlJobScheduler = new XxlJobScheduler(); diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/AdminBizImpl.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/AdminBizImpl.java index 88fd2674..1cdeac82 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/AdminBizImpl.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/AdminBizImpl.java @@ -129,15 +129,15 @@ public class AdminBizImpl implements AdminBiz { public ReturnT registry(RegistryParam registryParam) { // valid - if (!StringUtils.hasText(registryParam.getRegistGroup()) + if (!StringUtils.hasText(registryParam.getRegistryGroup()) || !StringUtils.hasText(registryParam.getRegistryKey()) || !StringUtils.hasText(registryParam.getRegistryValue())) { return new ReturnT(ReturnT.FAIL_CODE, "Illegal Argument."); } - int ret = xxlJobRegistryDao.registryUpdate(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue(), new Date()); + int ret = xxlJobRegistryDao.registryUpdate(registryParam.getRegistryGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue(), new Date()); if (ret < 1) { - xxlJobRegistryDao.registrySave(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue(), new Date()); + xxlJobRegistryDao.registrySave(registryParam.getRegistryGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue(), new Date()); // fresh freshGroupRegistryInfo(registryParam); @@ -149,13 +149,13 @@ public class AdminBizImpl implements AdminBiz { public ReturnT registryRemove(RegistryParam registryParam) { // valid - if (!StringUtils.hasText(registryParam.getRegistGroup()) + if (!StringUtils.hasText(registryParam.getRegistryGroup()) || !StringUtils.hasText(registryParam.getRegistryKey()) || !StringUtils.hasText(registryParam.getRegistryValue())) { return new ReturnT(ReturnT.FAIL_CODE, "Illegal Argument."); } - int ret = xxlJobRegistryDao.registryDelete(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue()); + int ret = xxlJobRegistryDao.registryDelete(registryParam.getRegistryGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue()); if (ret > 0) { // fresh