|
@@ -1,10 +1,12 @@
|
1
|
1
|
package com.xxl.job.admin.service.impl;
|
2
|
2
|
|
|
3
|
+import com.xxl.job.admin.core.model.XxlJobGroup;
|
3
|
4
|
import com.xxl.job.admin.core.model.XxlJobInfo;
|
4
|
5
|
import com.xxl.job.admin.core.model.XxlJobLog;
|
5
|
6
|
import com.xxl.job.admin.core.thread.JobTriggerPoolHelper;
|
6
|
7
|
import com.xxl.job.admin.core.trigger.TriggerTypeEnum;
|
7
|
8
|
import com.xxl.job.admin.core.util.I18nUtil;
|
|
9
|
+import com.xxl.job.admin.dao.XxlJobGroupDao;
|
8
|
10
|
import com.xxl.job.admin.dao.XxlJobInfoDao;
|
9
|
11
|
import com.xxl.job.admin.dao.XxlJobLogDao;
|
10
|
12
|
import com.xxl.job.admin.dao.XxlJobRegistryDao;
|
|
@@ -16,6 +18,8 @@ import com.xxl.job.core.handler.IJobHandler;
|
16
|
18
|
import org.slf4j.Logger;
|
17
|
19
|
import org.slf4j.LoggerFactory;
|
18
|
20
|
import org.springframework.stereotype.Service;
|
|
21
|
+import org.springframework.util.CollectionUtils;
|
|
22
|
+import org.springframework.util.StringUtils;
|
19
|
23
|
|
20
|
24
|
import javax.annotation.Resource;
|
21
|
25
|
import java.text.MessageFormat;
|
|
@@ -35,6 +39,8 @@ public class AdminBizImpl implements AdminBiz {
|
35
|
39
|
private XxlJobInfoDao xxlJobInfoDao;
|
36
|
40
|
@Resource
|
37
|
41
|
private XxlJobRegistryDao xxlJobRegistryDao;
|
|
42
|
+ @Resource
|
|
43
|
+ private XxlJobGroupDao xxlJobGroupDao;
|
38
|
44
|
|
39
|
45
|
|
40
|
46
|
@Override
|
|
@@ -132,8 +138,40 @@ public class AdminBizImpl implements AdminBiz {
|
132
|
138
|
|
133
|
139
|
@Override
|
134
|
140
|
public ReturnT<String> registryRemove(RegistryParam registryParam) {
|
135
|
|
- xxlJobRegistryDao.registryDelete(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
|
|
141
|
+ int ret = xxlJobRegistryDao.registryDelete(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
|
|
142
|
+ if (ret == 1) {
|
|
143
|
+ List<XxlJobGroup> autoRegisterGroups = xxlJobGroupDao.findAutoRegisterGroupByAppName(registryParam.getRegistryKey());
|
|
144
|
+ removeRegisterFromGroups(autoRegisterGroups, registryParam.getRegistryValue());
|
|
145
|
+ }
|
136
|
146
|
return ReturnT.SUCCESS;
|
137
|
147
|
}
|
138
|
148
|
|
|
149
|
+ private void removeRegisterFromGroups(List<XxlJobGroup> groups, String address) {
|
|
150
|
+ if (StringUtils.isEmpty(address)) {
|
|
151
|
+ return;
|
|
152
|
+ }
|
|
153
|
+ if (CollectionUtils.isEmpty(groups)) {
|
|
154
|
+ return;
|
|
155
|
+ }
|
|
156
|
+
|
|
157
|
+ for (XxlJobGroup group : groups) {
|
|
158
|
+ List<String> addressList = group.getRegistryList();
|
|
159
|
+ if (addressList == null) {
|
|
160
|
+ continue;
|
|
161
|
+ }
|
|
162
|
+ if (!addressList.contains(address)) {
|
|
163
|
+ continue;
|
|
164
|
+ }
|
|
165
|
+
|
|
166
|
+ addressList.remove(address);
|
|
167
|
+ String newAddressListStr = StringUtils.collectionToCommaDelimitedString(addressList);
|
|
168
|
+ String oldAddressListStr = group.getAddressList();
|
|
169
|
+ int update = xxlJobGroupDao.updateAddressListById(group.getId(), newAddressListStr);
|
|
170
|
+ if (logger.isDebugEnabled()) {
|
|
171
|
+ logger.debug("update group name [{}] title [{}] old address list [{}] new address list [{}] update result [{}]",
|
|
172
|
+ group.getAppName(), group.getTitle(), oldAddressListStr, newAddressListStr, update);
|
|
173
|
+ }
|
|
174
|
+ }
|
|
175
|
+ }
|
|
176
|
+
|
139
|
177
|
}
|