refactor(core):重构注册类型常量引用

- 将注册类型枚举从 Const 类中提取为独立的 RegistType 类- 更新所有使用 Const.RegistType 的地方为 RegistType- 优化集合判空条件判断方式
- 添加必要的 import 语句以支持新的枚举类引用
3.3.0-release
xuxueli 1 month ago
parent 75c49edbe7
commit fa0ce058d8

@ -8,6 +8,7 @@ import com.xxl.job.admin.mapper.XxlJobGroupMapper;
import com.xxl.job.admin.mapper.XxlJobInfoMapper;
import com.xxl.job.admin.mapper.XxlJobRegistryMapper;
import com.xxl.job.core.constant.Const;
import com.xxl.job.core.constant.RegistType;
import com.xxl.sso.core.annotation.XxlSso;
import com.xxl.tool.core.CollectionTool;
import com.xxl.tool.core.StringTool;
@ -155,7 +156,7 @@ public class JobGroupController {
List<XxlJobRegistry> list = xxlJobRegistryMapper.findAll(Const.DEAD_TIMEOUT, new Date());
if (CollectionTool.isNotEmpty(list)) {
for (XxlJobRegistry item: list) {
if (!Const.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) {
if (!RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) {
continue;
}

@ -3,6 +3,7 @@ package com.xxl.job.admin.scheduler.thread;
import com.xxl.job.admin.model.XxlJobGroup;
import com.xxl.job.admin.model.XxlJobRegistry;
import com.xxl.job.admin.scheduler.config.XxlJobAdminBootstrap;
import com.xxl.job.core.constant.RegistType;
import com.xxl.job.core.openapi.model.RegistryRequest;
import com.xxl.job.core.constant.Const;
import com.xxl.tool.core.StringTool;
@ -74,7 +75,7 @@ public class JobRegistryHelper {
List<XxlJobRegistry> list = XxlJobAdminBootstrap.getInstance().getXxlJobRegistryMapper().findAll(Const.DEAD_TIMEOUT, new Date());
if (list != null) {
for (XxlJobRegistry item: list) {
if (Const.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) {
if (RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) {
String appname = item.getRegistryKey();
List<String> registryList = appAddressMap.get(appname);
if (registryList == null) {

@ -1,5 +1,6 @@
package com.xxl.job.adminbiz;
import com.xxl.job.core.constant.RegistType;
import com.xxl.job.core.openapi.AdminBiz;
import com.xxl.job.core.openapi.model.HandleCallbackRequest;
import com.xxl.job.core.openapi.model.RegistryRequest;
@ -62,7 +63,7 @@ public class AdminBizTest {
public void registry() throws Exception {
AdminBiz adminBiz = buildClient();
RegistryRequest registryParam = new RegistryRequest(Const.RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999");
RegistryRequest registryParam = new RegistryRequest(RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999");
Response<String> returnT = adminBiz.registry(registryParam);
assertTrue(returnT.isSuccess());
@ -77,7 +78,7 @@ public class AdminBizTest {
public void registryRemove() throws Exception {
AdminBiz adminBiz = buildClient();
RegistryRequest registryParam = new RegistryRequest(Const.RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999");
RegistryRequest registryParam = new RegistryRequest(RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999");
Response<String> returnT = adminBiz.registryRemove(registryParam);
assertTrue(returnT.isSuccess());

@ -25,9 +25,4 @@ public class Const {
*/
public static final int DEAD_TIMEOUT = BEAT_TIMEOUT * 3;
/**
* registry type
*/
public enum RegistType{ EXECUTOR, ADMIN }
}

@ -0,0 +1,18 @@
package com.xxl.job.core.constant;
/**
* Created by xuxueli on 17/5/9.
*/
public enum RegistType{
/**
* executor registry
*/
EXECUTOR,
/**
* admin registry
*/
ADMIN;
}

@ -94,7 +94,7 @@ public class XxlJobExecutor {
stopEmbedServer();
// destroy jobThreadRepository
if (jobThreadRepository.size() > 0) {
if (!jobThreadRepository.isEmpty()) {
for (Map.Entry<Integer, JobThread> item: jobThreadRepository.entrySet()) {
JobThread oldJobThread = removeJobThread(item.getKey(), "web container destroy and kill the job.");
// wait for job thread push result to callback queue

@ -1,5 +1,6 @@
package com.xxl.job.core.thread;
import com.xxl.job.core.constant.RegistType;
import com.xxl.job.core.openapi.AdminBiz;
import com.xxl.job.core.openapi.model.RegistryRequest;
import com.xxl.job.core.constant.Const;
@ -42,7 +43,7 @@ public class ExecutorRegistryThread {
// registry
while (!toStop) {
try {
RegistryRequest registryParam = new RegistryRequest(Const.RegistType.EXECUTOR.name(), appname, address);
RegistryRequest registryParam = new RegistryRequest(RegistType.EXECUTOR.name(), appname, address);
for (AdminBiz adminBiz: XxlJobExecutor.getAdminBizList()) {
try {
Response<String> registryResult = adminBiz.registry(registryParam);
@ -78,7 +79,7 @@ public class ExecutorRegistryThread {
// registry remove
try {
RegistryRequest registryParam = new RegistryRequest(Const.RegistType.EXECUTOR.name(), appname, address);
RegistryRequest registryParam = new RegistryRequest(RegistType.EXECUTOR.name(), appname, address);
for (AdminBiz adminBiz: XxlJobExecutor.getAdminBizList()) {
try {
Response<String> registryResult = adminBiz.registryRemove(registryParam);

Loading…
Cancel
Save