master
xuxueli 5 years ago
parent 6343f4b030
commit bb62887f52
  1. 4
      doc/XXL-JOB-English-Documentation.md
  2. 2
      doc/XXL-JOB官方文档.md
  3. 26
      xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobGroupController.java
  4. 10
      xxl-job-admin/src/main/java/com/xxl/job/admin/core/model/XxlJobGroup.java
  5. 8
      xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobRegistryMonitorHelper.java
  6. 4
      xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobGroupDao.java
  7. 14
      xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobGroupMapper.xml
  8. 14
      xxl-job-admin/src/main/resources/static/js/jobgroup.index.1.js
  9. 8
      xxl-job-admin/src/main/resources/templates/jobgroup/jobgroup.index.ftl
  10. 4
      xxl-job-admin/src/main/resources/templates/user/user.index.ftl
  11. 4
      xxl-job-admin/src/test/java/com/xxl/job/admin/dao/XxlJobGroupDaoTest.java
  12. 4
      xxl-job-core/src/main/java/com/xxl/job/core/executor/XxlJobExecutor.java

@ -504,7 +504,7 @@ Concrete contet describe as follows:
<!-- executor port[required] --> <!-- executor port[required] -->
<property name="port" value="${xxl.job.executor.port}" /> <property name="port" value="${xxl.job.executor.port}" />
<!-- executor AppName[required],auto register will be closed if it blank --> <!-- executor AppName[required],auto register will be closed if it blank -->
<property name="appName" value="${xxl.job.executor.appname}" /> <property name="appname" value="${xxl.job.executor.appname}" />
<!-- register center address of executor [required],auto register will be closed if it blank --> <!-- register center address of executor [required],auto register will be closed if it blank -->
<property name="adminAddresses" value="${xxl.job.admin.addresses}" /> <property name="adminAddresses" value="${xxl.job.admin.addresses}" />
<!-- log path of executor[required] --> <!-- log path of executor[required] -->
@ -663,7 +663,7 @@ If you want to create a new executor,please click "+新增执行器" button:
### Description of executor attributes ### Description of executor attributes
AppName: the unique identity of the executor cluster,executor will registe automatically and periodically by appName so that it can be scheduled. Appname: the unique identity of the executor cluster,executor will registe automatically and periodically by appname so that it can be scheduled.
名称: the name of ther executor,it is used to describe the executor. 名称: the name of ther executor,it is used to describe the executor.
排序: the order of executor,it will be used in the place where need to select executor. 排序: the order of executor,it will be used in the place where need to select executor.
注册方式:which way the schedule center used to acquire executor address through; 注册方式:which way the schedule center used to acquire executor address through;

@ -617,7 +617,7 @@ public XxlJobSpringExecutor xxlJobExecutor() {
logger.info(">>>>>>>>>>> xxl-job config init."); logger.info(">>>>>>>>>>> xxl-job config init.");
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(adminAddresses); xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
xxlJobSpringExecutor.setAppName(appName); xxlJobSpringExecutor.setAppname(appname);
xxlJobSpringExecutor.setIp(ip); xxlJobSpringExecutor.setIp(ip);
xxlJobSpringExecutor.setPort(port); xxlJobSpringExecutor.setPort(port);
xxlJobSpringExecutor.setAccessToken(accessToken); xxlJobSpringExecutor.setAccessToken(accessToken);

@ -43,11 +43,11 @@ public class JobGroupController {
public Map<String, Object> pageList(HttpServletRequest request, public Map<String, Object> pageList(HttpServletRequest request,
@RequestParam(required = false, defaultValue = "0") int start, @RequestParam(required = false, defaultValue = "0") int start,
@RequestParam(required = false, defaultValue = "10") int length, @RequestParam(required = false, defaultValue = "10") int length,
String appName, String title) { String appname, String title) {
// page query // page query
List<XxlJobGroup> list = xxlJobGroupDao.pageList(start, length, appName, title); List<XxlJobGroup> list = xxlJobGroupDao.pageList(start, length, appname, title);
int list_count = xxlJobGroupDao.pageListCount(start, length, appName, title); int list_count = xxlJobGroupDao.pageListCount(start, length, appname, title);
// package result // package result
Map<String, Object> maps = new HashMap<String, Object>(); Map<String, Object> maps = new HashMap<String, Object>();
@ -62,10 +62,10 @@ public class JobGroupController {
public ReturnT<String> save(XxlJobGroup xxlJobGroup){ public ReturnT<String> save(XxlJobGroup xxlJobGroup){
// valid // valid
if (xxlJobGroup.getAppName()==null || xxlJobGroup.getAppName().trim().length()==0) { if (xxlJobGroup.getAppname()==null || xxlJobGroup.getAppname().trim().length()==0) {
return new ReturnT<String>(500, (I18nUtil.getString("system_please_input")+"AppName") ); return new ReturnT<String>(500, (I18nUtil.getString("system_please_input")+"AppName") );
} }
if (xxlJobGroup.getAppName().length()<4 || xxlJobGroup.getAppName().length()>64) { if (xxlJobGroup.getAppname().length()<4 || xxlJobGroup.getAppname().length()>64) {
return new ReturnT<String>(500, I18nUtil.getString("jobgroup_field_appname_length") ); return new ReturnT<String>(500, I18nUtil.getString("jobgroup_field_appname_length") );
} }
if (xxlJobGroup.getTitle()==null || xxlJobGroup.getTitle().trim().length()==0) { if (xxlJobGroup.getTitle()==null || xxlJobGroup.getTitle().trim().length()==0) {
@ -91,10 +91,10 @@ public class JobGroupController {
@ResponseBody @ResponseBody
public ReturnT<String> update(XxlJobGroup xxlJobGroup){ public ReturnT<String> update(XxlJobGroup xxlJobGroup){
// valid // valid
if (xxlJobGroup.getAppName()==null || xxlJobGroup.getAppName().trim().length()==0) { if (xxlJobGroup.getAppname()==null || xxlJobGroup.getAppname().trim().length()==0) {
return new ReturnT<String>(500, (I18nUtil.getString("system_please_input")+"AppName") ); return new ReturnT<String>(500, (I18nUtil.getString("system_please_input")+"AppName") );
} }
if (xxlJobGroup.getAppName().length()<4 || xxlJobGroup.getAppName().length()>64) { if (xxlJobGroup.getAppname().length()<4 || xxlJobGroup.getAppname().length()>64) {
return new ReturnT<String>(500, I18nUtil.getString("jobgroup_field_appname_length") ); return new ReturnT<String>(500, I18nUtil.getString("jobgroup_field_appname_length") );
} }
if (xxlJobGroup.getTitle()==null || xxlJobGroup.getTitle().trim().length()==0) { if (xxlJobGroup.getTitle()==null || xxlJobGroup.getTitle().trim().length()==0) {
@ -102,7 +102,7 @@ public class JobGroupController {
} }
if (xxlJobGroup.getAddressType() == 0) { if (xxlJobGroup.getAddressType() == 0) {
// 0=自动注册 // 0=自动注册
List<String> registryList = findRegistryByAppName(xxlJobGroup.getAppName()); List<String> registryList = findRegistryByAppName(xxlJobGroup.getAppname());
String addressListStr = null; String addressListStr = null;
if (registryList!=null && !registryList.isEmpty()) { if (registryList!=null && !registryList.isEmpty()) {
Collections.sort(registryList); Collections.sort(registryList);
@ -130,14 +130,14 @@ public class JobGroupController {
return (ret>0)?ReturnT.SUCCESS:ReturnT.FAIL; return (ret>0)?ReturnT.SUCCESS:ReturnT.FAIL;
} }
private List<String> findRegistryByAppName(String appNameParam){ private List<String> findRegistryByAppName(String appnameParam){
HashMap<String, List<String>> appAddressMap = new HashMap<String, List<String>>(); HashMap<String, List<String>> appAddressMap = new HashMap<String, List<String>>();
List<XxlJobRegistry> list = xxlJobRegistryDao.findAll(RegistryConfig.DEAD_TIMEOUT, new Date()); List<XxlJobRegistry> list = xxlJobRegistryDao.findAll(RegistryConfig.DEAD_TIMEOUT, new Date());
if (list != null) { if (list != null) {
for (XxlJobRegistry item: list) { for (XxlJobRegistry item: list) {
if (RegistryConfig.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) { if (RegistryConfig.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) {
String appName = item.getRegistryKey(); String appname = item.getRegistryKey();
List<String> registryList = appAddressMap.get(appName); List<String> registryList = appAddressMap.get(appname);
if (registryList == null) { if (registryList == null) {
registryList = new ArrayList<String>(); registryList = new ArrayList<String>();
} }
@ -145,11 +145,11 @@ public class JobGroupController {
if (!registryList.contains(item.getRegistryValue())) { if (!registryList.contains(item.getRegistryValue())) {
registryList.add(item.getRegistryValue()); registryList.add(item.getRegistryValue());
} }
appAddressMap.put(appName, registryList); appAddressMap.put(appname, registryList);
} }
} }
} }
return appAddressMap.get(appNameParam); return appAddressMap.get(appnameParam);
} }
@RequestMapping("/remove") @RequestMapping("/remove")

@ -10,7 +10,7 @@ import java.util.List;
public class XxlJobGroup { public class XxlJobGroup {
private int id; private int id;
private String appName; private String appname;
private String title; private String title;
private int addressType; // 执行器地址类型:0=自动注册、1=手动录入 private int addressType; // 执行器地址类型:0=自动注册、1=手动录入
private String addressList; // 执行器地址列表,多地址逗号分隔(手动录入) private String addressList; // 执行器地址列表,多地址逗号分隔(手动录入)
@ -32,12 +32,12 @@ public class XxlJobGroup {
this.id = id; this.id = id;
} }
public String getAppName() { public String getAppname() {
return appName; return appname;
} }
public void setAppName(String appName) { public void setAppname(String appname) {
this.appName = appName; this.appname = appname;
} }
public String getTitle() { public String getTitle() {

@ -46,8 +46,8 @@ public class JobRegistryMonitorHelper {
if (list != null) { if (list != null) {
for (XxlJobRegistry item: list) { for (XxlJobRegistry item: list) {
if (RegistryConfig.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) { if (RegistryConfig.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) {
String appName = item.getRegistryKey(); String appname = item.getRegistryKey();
List<String> registryList = appAddressMap.get(appName); List<String> registryList = appAddressMap.get(appname);
if (registryList == null) { if (registryList == null) {
registryList = new ArrayList<String>(); registryList = new ArrayList<String>();
} }
@ -55,14 +55,14 @@ public class JobRegistryMonitorHelper {
if (!registryList.contains(item.getRegistryValue())) { if (!registryList.contains(item.getRegistryValue())) {
registryList.add(item.getRegistryValue()); registryList.add(item.getRegistryValue());
} }
appAddressMap.put(appName, registryList); appAddressMap.put(appname, registryList);
} }
} }
} }
// fresh group address // fresh group address
for (XxlJobGroup group: groupList) { for (XxlJobGroup group: groupList) {
List<String> registryList = appAddressMap.get(group.getAppName()); List<String> registryList = appAddressMap.get(group.getAppname());
String addressListStr = null; String addressListStr = null;
if (registryList!=null && !registryList.isEmpty()) { if (registryList!=null && !registryList.isEmpty()) {
Collections.sort(registryList); Collections.sort(registryList);

@ -26,12 +26,12 @@ public interface XxlJobGroupDao {
public List<XxlJobGroup> pageList(@Param("offset") int offset, public List<XxlJobGroup> pageList(@Param("offset") int offset,
@Param("pagesize") int pagesize, @Param("pagesize") int pagesize,
@Param("appName") String appName, @Param("appname") String appname,
@Param("title") String title); @Param("title") String title);
public int pageListCount(@Param("offset") int offset, public int pageListCount(@Param("offset") int offset,
@Param("pagesize") int pagesize, @Param("pagesize") int pagesize,
@Param("appName") String appName, @Param("appname") String appname,
@Param("title") String title); @Param("title") String title);
} }

@ -5,7 +5,7 @@
<resultMap id="XxlJobGroup" type="com.xxl.job.admin.core.model.XxlJobGroup" > <resultMap id="XxlJobGroup" type="com.xxl.job.admin.core.model.XxlJobGroup" >
<result column="id" property="id" /> <result column="id" property="id" />
<result column="app_name" property="appName" /> <result column="app_name" property="appname" />
<result column="title" property="title" /> <result column="title" property="title" />
<result column="address_type" property="addressType" /> <result column="address_type" property="addressType" />
<result column="address_list" property="addressList" /> <result column="address_list" property="addressList" />
@ -34,12 +34,12 @@
<insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobGroup" useGeneratedKeys="true" keyProperty="id" > <insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobGroup" useGeneratedKeys="true" keyProperty="id" >
INSERT INTO xxl_job_group ( `app_name`, `title`, `address_type`, `address_list`) INSERT INTO xxl_job_group ( `app_name`, `title`, `address_type`, `address_list`)
values ( #{appName}, #{title}, #{addressType}, #{addressList}); values ( #{appname}, #{title}, #{addressType}, #{addressList});
</insert> </insert>
<update id="update" parameterType="com.xxl.job.admin.core.model.XxlJobGroup" > <update id="update" parameterType="com.xxl.job.admin.core.model.XxlJobGroup" >
UPDATE xxl_job_group UPDATE xxl_job_group
SET `app_name` = #{appName}, SET `app_name` = #{appname},
`title` = #{title}, `title` = #{title},
`address_type` = #{addressType}, `address_type` = #{addressType},
`address_list` = #{addressList} `address_list` = #{addressList}
@ -61,8 +61,8 @@
SELECT <include refid="Base_Column_List" /> SELECT <include refid="Base_Column_List" />
FROM xxl_job_group AS t FROM xxl_job_group AS t
<trim prefix="WHERE" prefixOverrides="AND | OR" > <trim prefix="WHERE" prefixOverrides="AND | OR" >
<if test="appName != null and appName != ''"> <if test="appname != null and appname != ''">
AND t.app_name like CONCAT(CONCAT('%', #{appName}), '%') AND t.app_name like CONCAT(CONCAT('%', #{appname}), '%')
</if> </if>
<if test="title != null and title != ''"> <if test="title != null and title != ''">
AND t.title like CONCAT(CONCAT('%', #{title}), '%') AND t.title like CONCAT(CONCAT('%', #{title}), '%')
@ -76,8 +76,8 @@
SELECT count(1) SELECT count(1)
FROM xxl_job_group AS t FROM xxl_job_group AS t
<trim prefix="WHERE" prefixOverrides="AND | OR" > <trim prefix="WHERE" prefixOverrides="AND | OR" >
<if test="appName != null and appName != ''"> <if test="appname != null and appname != ''">
AND t.app_name like CONCAT(CONCAT('%', #{appName}), '%') AND t.app_name like CONCAT(CONCAT('%', #{appname}), '%')
</if> </if>
<if test="title != null and title != ''"> <if test="title != null and title != ''">
AND t.title like CONCAT(CONCAT('%', #{title}), '%') AND t.title like CONCAT(CONCAT('%', #{title}), '%')

@ -10,7 +10,7 @@ $(function() {
type:"post", type:"post",
data : function ( d ) { data : function ( d ) {
var obj = {}; var obj = {};
obj.appName = $('#appName').val(); obj.appname = $('#appname').val();
obj.title = $('#title').val(); obj.title = $('#title').val();
obj.start = d.start; obj.start = d.start;
obj.length = d.length; obj.length = d.length;
@ -26,7 +26,7 @@ $(function() {
"visible" : false "visible" : false
}, },
{ {
"data": 'appName', "data": 'appname',
"visible" : true, "visible" : true,
"width":'30%' "width":'30%'
}, },
@ -196,7 +196,7 @@ $(function() {
errorClass : 'help-block', errorClass : 'help-block',
focusInvalid : true, focusInvalid : true,
rules : { rules : {
appName : { appname : {
required : true, required : true,
rangelength:[4,64], rangelength:[4,64],
myValid01 : true myValid01 : true
@ -207,7 +207,7 @@ $(function() {
} }
}, },
messages : { messages : {
appName : { appname : {
required : I18n.system_please_input+"AppName", required : I18n.system_please_input+"AppName",
rangelength: I18n.jobgroup_field_appname_length , rangelength: I18n.jobgroup_field_appname_length ,
myValid01: I18n.jobgroup_field_appname_limit myValid01: I18n.jobgroup_field_appname_limit
@ -277,7 +277,7 @@ $(function() {
var row = tableData['key'+id]; var row = tableData['key'+id];
$("#updateModal .form input[name='id']").val( row.id ); $("#updateModal .form input[name='id']").val( row.id );
$("#updateModal .form input[name='appName']").val( row.appName ); $("#updateModal .form input[name='appname']").val( row.appname );
$("#updateModal .form input[name='title']").val( row.title ); $("#updateModal .form input[name='title']").val( row.title );
// 注册方式 // 注册方式
@ -293,7 +293,7 @@ $(function() {
errorClass : 'help-block', errorClass : 'help-block',
focusInvalid : true, focusInvalid : true,
rules : { rules : {
appName : { appname : {
required : true, required : true,
rangelength:[4,64], rangelength:[4,64],
myValid01 : true myValid01 : true
@ -304,7 +304,7 @@ $(function() {
} }
}, },
messages : { messages : {
appName : { appname : {
required : I18n.system_please_input+"AppName", required : I18n.system_please_input+"AppName",
rangelength: I18n.jobgroup_field_appname_length , rangelength: I18n.jobgroup_field_appname_length ,
myValid01: I18n.jobgroup_field_appname_limit myValid01: I18n.jobgroup_field_appname_limit

@ -28,7 +28,7 @@
<div class="col-xs-3"> <div class="col-xs-3">
<div class="input-group"> <div class="input-group">
<span class="input-group-addon">AppName</span> <span class="input-group-addon">AppName</span>
<input type="text" class="form-control" id="appName" autocomplete="on" placeholder="${I18n.system_please_input}AppName" > <input type="text" class="form-control" id="appname" autocomplete="on" placeholder="${I18n.system_please_input}AppName" >
</div> </div>
</div> </div>
<div class="col-xs-3"> <div class="col-xs-3">
@ -53,7 +53,7 @@
<thead> <thead>
<tr> <tr>
<th name="id" >ID</th> <th name="id" >ID</th>
<th name="appName" >AppName</th> <th name="appname" >AppName</th>
<th name="title" >${I18n.jobgroup_field_title}</th> <th name="title" >${I18n.jobgroup_field_title}</th>
<th name="addressType" >${I18n.jobgroup_field_addressType}</th> <th name="addressType" >${I18n.jobgroup_field_addressType}</th>
<th name="registryList" >OnLine ${I18n.jobgroup_field_registryList}</th> <th name="registryList" >OnLine ${I18n.jobgroup_field_registryList}</th>
@ -81,7 +81,7 @@
<form class="form-horizontal form" role="form" > <form class="form-horizontal form" role="form" >
<div class="form-group"> <div class="form-group">
<label for="lastname" class="col-sm-2 control-label">AppName<font color="red">*</font></label> <label for="lastname" class="col-sm-2 control-label">AppName<font color="red">*</font></label>
<div class="col-sm-10"><input type="text" class="form-control" name="appName" placeholder="${I18n.system_please_input}AppName" maxlength="64" ></div> <div class="col-sm-10"><input type="text" class="form-control" name="appname" placeholder="${I18n.system_please_input}AppName" maxlength="64" ></div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="lastname" class="col-sm-2 control-label">${I18n.jobgroup_field_title}<font color="red">*</font></label> <label for="lastname" class="col-sm-2 control-label">${I18n.jobgroup_field_title}<font color="red">*</font></label>
@ -125,7 +125,7 @@
<form class="form-horizontal form" role="form" > <form class="form-horizontal form" role="form" >
<div class="form-group"> <div class="form-group">
<label for="lastname" class="col-sm-2 control-label">AppName<font color="red">*</font></label> <label for="lastname" class="col-sm-2 control-label">AppName<font color="red">*</font></label>
<div class="col-sm-10"><input type="text" class="form-control" name="appName" placeholder="${I18n.system_please_input}AppName" maxlength="64" ></div> <div class="col-sm-10"><input type="text" class="form-control" name="appname" placeholder="${I18n.system_please_input}AppName" maxlength="64" ></div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="lastname" class="col-sm-2 control-label">${I18n.jobgroup_field_title}<font color="red">*</font></label> <label for="lastname" class="col-sm-2 control-label">${I18n.jobgroup_field_title}<font color="red">*</font></label>

@ -108,7 +108,7 @@
<div class="col-sm-10"> <div class="col-sm-10">
<#if groupList?exists && groupList?size gt 0> <#if groupList?exists && groupList?size gt 0>
<#list groupList as item> <#list groupList as item>
<input type="checkbox" name="permission" value="${item.id}" />${item.title}(${item.appName})<br> <input type="checkbox" name="permission" value="${item.id}" />${item.title}(${item.appname})<br>
</#list> </#list>
</#if> </#if>
</div> </div>
@ -158,7 +158,7 @@
<div class="col-sm-10"> <div class="col-sm-10">
<#if groupList?exists && groupList?size gt 0> <#if groupList?exists && groupList?size gt 0>
<#list groupList as item> <#list groupList as item>
<input type="checkbox" name="permission" value="${item.id}" />${item.title}(${item.appName})<br> <input type="checkbox" name="permission" value="${item.id}" />${item.title}(${item.appname})<br>
</#list> </#list>
</#if> </#if>
</div> </div>

@ -23,7 +23,7 @@ public class XxlJobGroupDaoTest {
List<XxlJobGroup> list2 = xxlJobGroupDao.findByAddressType(0); List<XxlJobGroup> list2 = xxlJobGroupDao.findByAddressType(0);
XxlJobGroup group = new XxlJobGroup(); XxlJobGroup group = new XxlJobGroup();
group.setAppName("setAppName"); group.setAppname("setAppName");
group.setTitle("setTitle"); group.setTitle("setTitle");
group.setAddressType(0); group.setAddressType(0);
group.setAddressList("setAddressList"); group.setAddressList("setAddressList");
@ -31,7 +31,7 @@ public class XxlJobGroupDaoTest {
int ret = xxlJobGroupDao.save(group); int ret = xxlJobGroupDao.save(group);
XxlJobGroup group2 = xxlJobGroupDao.load(group.getId()); XxlJobGroup group2 = xxlJobGroupDao.load(group.getId());
group2.setAppName("setAppName2"); group2.setAppname("setAppName2");
group2.setTitle("setTitle2"); group2.setTitle("setTitle2");
group2.setAddressType(2); group2.setAddressType(2);
group2.setAddressList("setAddressList2"); group2.setAddressList("setAddressList2");

@ -135,7 +135,7 @@ public class XxlJobExecutor {
// ---------------------- executor-server (rpc provider) ---------------------- // ---------------------- executor-server (rpc provider) ----------------------
private EmbedServer embedServer = null; private EmbedServer embedServer = null;
private void initEmbedServer(String address, String ip, int port, String appName, String accessToken) throws Exception { private void initEmbedServer(String address, String ip, int port, String appname, String accessToken) throws Exception {
// fill ip port // fill ip port
port = port>0?port: NetUtil.findAvailablePort(9999); port = port>0?port: NetUtil.findAvailablePort(9999);
@ -149,7 +149,7 @@ public class XxlJobExecutor {
// start // start
embedServer = new EmbedServer(); embedServer = new EmbedServer();
embedServer.start(address, port, appName, accessToken); embedServer.start(address, port, appname, accessToken);
} }
private void stopEmbedServer() { private void stopEmbedServer() {

Loading…
Cancel
Save