Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.4.0 Support dynamic update registration group #3249

Open
wants to merge 5 commits into
base: 2.4.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions doc/XXL-JOB官方文档.md
Original file line number Diff line number Diff line change
Expand Up @@ -2301,26 +2301,28 @@ public void execute() {
- 4、【优化】合并多项PR,项目代码结构、健壮性优化:PR-2833、PR-2812、PR-2541、PR-2537、PR-2514、PR-2509、PR-2591。
- 5、【优化】任务线程名优化,提升可读性与问题定位效率(ISSUE-2527)。

### 7.33 版本 v2.4.0 Release Notes[2022-03-23]
### 7.33 版本 v2.4.0 Release Notes[2023-03-23]
- 1、【优化】执行器任务Bean扫描逻辑优化:解决懒加载注解失效问题。
- 2、【优化】多个项目依赖升级至较新稳定版本,涉及netty、groovy、spring、springboot、mybatis等;
- 3、【修复】"CVE-2022-36157" 授权漏洞修复。
- 4、【修复】"CVE-2022-43183" SSRF漏洞修复。

### 7.34 版本 v2.4.1 Release Notes[规划中]
- 1、【优化】[规划中]任务日志重构:一次调度只记录一条主任务,维护起止时间和状态。
- 普通任务:只记录一条主任务;
- 广播任务:记录一条主任务,每个分片任务记录一条次任务,关联在主任务上;
- 重试任务:失败时,新增主任务。所有调度记录,包括入口调度和重试调度,均挂载主任务上。
- 2、【优化】[规划中]分片任务:全部完成后才会出发后置节点;

### 7.34 新版本规划 [规划中]
### 7.35 新版本规划 [规划中]
- 1、[规划中]DAG流程任务
- DAG任务:支持参数传递,共享数据:DAG任务创建、管理,DAG任务日志查看、操作;
- 子任务:废弃
- 2、[规划中]多数据库支持,DAO层通过JPA实现,不限制数据库类型;
- 3、[规划中]告警增强:邮件告警 + webhook告警;
- 4、[规划中]安全强化:AccessToken动态生成、动态启停;控制调度、回调;
- 5、[规划中]任务导入导出工具,灵活支持版本升级、迁移等场景。
- 6、【优化】[规划中]任务日志重构:一次调度只记录一条主任务,维护起止时间和状态。
- 普通任务:只记录一条主任务;
- 广播任务:记录一条主任务,每个分片任务记录一条次任务,关联在主任务上;
- 重试任务:失败时,新增主任务。所有调度记录,包括入口调度和重试调度,均挂载主任务上。
- 7、【优化】[规划中]分片任务:全部完成后才会出发后置节点;


### TODO LIST
- 1、任务分片路由:分片采用一致性Hash算法计算出尽量稳定的分片顺序,即使注册机器存在波动也不会引起分批分片顺序大的波动;目前采用IP自然排序,可以满足需求,待定;
Expand Down
2 changes: 1 addition & 1 deletion doc/db/tables_xxl_job.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# XXL-JOB v2.4.0
# XXL-JOB v2.4.1-SNAPSHOT
# Copyright (c) 2015-present, xuxueli.

CREATE database if NOT EXISTS `xxl_job` default character set utf8mb4 collate utf8mb4_unicode_ci;
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job</artifactId>
<version>2.4.0</version>
<version>2.4.1-SNAPSHOT</version>
<packaging>pom</packaging>

<name>${project.artifactId}</name>
Expand Down
2 changes: 1 addition & 1 deletion xxl-job-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job</artifactId>
<version>2.4.0</version>
<version>2.4.1-SNAPSHOT</version>
</parent>
<artifactId>xxl-job-admin</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.xxl.job.admin.core.conf.XxlJobAdminConfig;
import com.xxl.job.admin.core.model.XxlJobGroup;
import com.xxl.job.admin.core.model.XxlJobRegistry;
import com.xxl.job.admin.dao.XxlJobGroupDao;
import com.xxl.job.core.biz.model.RegistryParam;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.enums.RegistryConfig;
Expand Down Expand Up @@ -100,11 +101,13 @@ public void run() {
}
addressListStr = addressListSB.toString();
addressListStr = addressListStr.substring(0, addressListStr.length()-1);
group.setAddressList(addressListStr);
group.setUpdateTime(new Date());
XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().update(group);
} else {
// executor group can be destroyed when the last executor is destroyed
XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().remove(group.getId());
}
group.setAddressList(addressListStr);
group.setUpdateTime(new Date());

XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().update(group);
}
}
} catch (Exception e) {
Expand Down Expand Up @@ -162,9 +165,37 @@ public void run() {
int ret = XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().registryUpdate(registryParam.getRegistryGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue(), new Date());
if (ret < 1) {
XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().registrySave(registryParam.getRegistryGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue(), new Date());

// fresh
freshGroupRegistryInfo(registryParam);
// after add registry
XxlJobGroupDao xxlJobGroupDao = XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao();
XxlJobGroup group = xxlJobGroupDao.findOneByAppname(registryParam.getRegistryKey());
if (null == group) {
// add group
group = new XxlJobGroup();
group.setAppname(registryParam.getRegistryKey());
group.setTitle(registryParam.getRegistryKey());
group.setAddressType(0);
group.setAddressList(registryParam.getRegistryValue());
group.setUpdateTime(new Date());
xxlJobGroupDao.save(group);
} else {
// update group address_list and update_time
if (null == group.getAddressList()) {
group.setAddressList(registryParam.getRegistryValue());
} else {
group.setAddressList(group.getAddressList().concat(",").concat(registryParam.getRegistryValue()));
}
group.setUpdateTime(new Date());
xxlJobGroupDao.update(group);
}
} else {
// after update registry
XxlJobGroupDao xxlJobGroupDao = XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao();
XxlJobGroup group = xxlJobGroupDao.findOneByAppname(registryParam.getRegistryKey());
if (null == group) {
throw new RuntimeException("after update registry, update group failed, because group is not found");
}
group.setUpdateTime(new Date());
xxlJobGroupDao.update(group);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ public int pageListCount(@Param("offset") int offset,
@Param("appname") String appname,
@Param("title") String title);

public XxlJobGroup findOneByAppname(@Param("appname") String appname);

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
admin_name=Scheduling Center
admin_name_full=Distributed Task Scheduling Platform XXL-JOB
admin_version=2.4.0
admin_version=2.4.1-SNAPSHOT
admin_i18n=en

## system
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
admin_name=任务调度中心
admin_name_full=分布式任务调度平台XXL-JOB
admin_version=2.4.0
admin_version=2.4.1-SNAPSHOT
admin_i18n=

## system
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
admin_name=任務調度中心
admin_name_full=分布式任務調度平臺XXL-JOB
admin_version=2.4.0
admin_version=2.4.1-SNAPSHOT
admin_i18n=

## system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,10 @@
</trim>
</select>

<select id="findOneByAppname" resultMap="XxlJobGroup">
SELECT <include refid="Base_Column_List" />
FROM xxl_job_group AS t
WHERE t.app_name = #{appname}
</select>

</mapper>
2 changes: 1 addition & 1 deletion xxl-job-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job</artifactId>
<version>2.4.0</version>
<version>2.4.1-SNAPSHOT</version>
</parent>
<artifactId>xxl-job-core</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public enum GlueTypeEnum {
GLUE_PYTHON("GLUE(Python)", true, "python", ".py"),
GLUE_PHP("GLUE(PHP)", true, "php", ".php"),
GLUE_NODEJS("GLUE(Nodejs)", true, "node", ".js"),
GLUE_POWERSHELL("GLUE(PowerShell)", true, "powershell", ".ps1");
GLUE_POWERSHELL("GLUE(PowerShell)", true, "pwsh", ".ps1");

private String desc;
private boolean isScript;
Expand Down
2 changes: 1 addition & 1 deletion xxl-job-executor-samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job</artifactId>
<version>2.4.0</version>
<version>2.4.1-SNAPSHOT</version>
</parent>
<artifactId>xxl-job-executor-samples</artifactId>
<packaging>pom</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-executor-samples</artifactId>
<version>2.4.0</version>
<version>2.4.1-SNAPSHOT</version>
</parent>
<artifactId>xxl-job-executor-sample-frameless</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-executor-samples</artifactId>
<version>2.4.0</version>
<version>2.4.1-SNAPSHOT</version>
</parent>
<artifactId>xxl-job-executor-sample-springboot</artifactId>
<packaging>jar</packaging>
Expand Down