|
@@ -6,7 +6,6 @@ import com.xxl.job.admin.core.model.XxlJobLog;
|
6
|
6
|
import com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum;
|
7
|
7
|
import com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler;
|
8
|
8
|
import com.xxl.job.admin.core.thread.JobFailMonitorHelper;
|
9
|
|
-import com.xxl.job.admin.core.thread.JobTriggerPoolHelper;
|
10
|
9
|
import com.xxl.job.admin.core.util.I18nUtil;
|
11
|
10
|
import com.xxl.job.core.biz.ExecutorBiz;
|
12
|
11
|
import com.xxl.job.core.biz.model.ReturnT;
|
|
@@ -36,7 +35,7 @@ public class XxlJobTrigger {
|
36
|
35
|
* <0: use param from job info config
|
37
|
36
|
*
|
38
|
37
|
*/
|
39
|
|
- public static void trigger(int jobId, int failRetryCount) {
|
|
38
|
+ public static void trigger(int jobId, int failRetryCount, String type) {
|
40
|
39
|
|
41
|
40
|
// load data
|
42
|
41
|
XxlJobInfo jobInfo = XxlJobDynamicScheduler.xxlJobInfoDao.loadById(jobId); // job info
|
|
@@ -57,7 +56,6 @@ public class XxlJobTrigger {
|
57
|
56
|
|
58
|
57
|
// broadcast
|
59
|
58
|
if (ExecutorRouteStrategyEnum.SHARDING_BROADCAST == executorRouteStrategyEnum && CollectionUtils.isNotEmpty(addressList)) {
|
60
|
|
- boolean onceFailed = false;
|
61
|
59
|
for (int i = 0; i < addressList.size(); i++) {
|
62
|
60
|
String address = addressList.get(i);
|
63
|
61
|
|
|
@@ -77,6 +75,7 @@ public class XxlJobTrigger {
|
77
|
75
|
|
78
|
76
|
ReturnT<String> triggerResult = new ReturnT<String>(null);
|
79
|
77
|
StringBuffer triggerMsgSb = new StringBuffer();
|
|
78
|
+ triggerMsgSb.append(I18nUtil.getString("jobconf_trigger_type")).append(":").append(type);
|
80
|
79
|
triggerMsgSb.append(I18nUtil.getString("jobconf_trigger_admin_adress")).append(":").append(IpUtil.getIp());
|
81
|
80
|
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobconf_trigger_exe_regtype")).append(":")
|
82
|
81
|
.append( (group.getAddressType() == 0)?I18nUtil.getString("jobgroup_field_addressType_0"):I18nUtil.getString("jobgroup_field_addressType_1") );
|
|
@@ -106,24 +105,13 @@ public class XxlJobTrigger {
|
106
|
105
|
triggerResult = runExecutor(triggerParam, address); // update03
|
107
|
106
|
triggerMsgSb.append("<br><br><span style=\"color:#00c0ef;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_trigger_run") +"<<<<<<<<<<< </span><br>").append(triggerResult.getMsg());
|
108
|
107
|
|
109
|
|
-
|
110
|
|
- // 4、fail retry)
|
111
|
|
- if (triggerResult.getCode()!=ReturnT.SUCCESS_CODE) {
|
112
|
|
- onceFailed = true;
|
113
|
|
- }
|
114
|
|
-
|
115
|
|
- if (addressList.size()==i+1 && onceFailed && finalFailRetryCount > 0) { // each trigger only retry once
|
116
|
|
- JobTriggerPoolHelper.trigger(jobId, (finalFailRetryCount-1));
|
117
|
|
- triggerMsgSb.append("<br><br><span style=\"color:#F39C12;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_fail_trigger_retry") +"<<<<<<<<<<< </span><br>");
|
118
|
|
- }
|
119
|
|
-
|
120
|
|
- // 5、save trigger-info
|
|
108
|
+ // 4、save trigger-info
|
121
|
109
|
jobLog.setExecutorAddress(triggerResult.getContent());
|
122
|
110
|
jobLog.setTriggerCode(triggerResult.getCode());
|
123
|
111
|
jobLog.setTriggerMsg(triggerMsgSb.toString());
|
124
|
112
|
XxlJobDynamicScheduler.xxlJobLogDao.updateTriggerInfo(jobLog);
|
125
|
113
|
|
126
|
|
- // 6、monitor trigger
|
|
114
|
+ // 5、monitor trigger
|
127
|
115
|
JobFailMonitorHelper.monitor(jobLog.getId());
|
128
|
116
|
logger.debug(">>>>>>>>>>> xxl-job trigger end, jobId:{}", jobLog.getId());
|
129
|
117
|
|
|
@@ -182,19 +170,13 @@ public class XxlJobTrigger {
|
182
|
170
|
|
183
|
171
|
}
|
184
|
172
|
|
185
|
|
- // 4、fail retry
|
186
|
|
- if (triggerResult.getCode()!=ReturnT.SUCCESS_CODE && finalFailRetryCount > 0) {
|
187
|
|
- JobTriggerPoolHelper.trigger(jobId, (finalFailRetryCount-1));
|
188
|
|
- triggerMsgSb.append("<br><br><span style=\"color:#F39C12;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_fail_trigger_retry") +"<<<<<<<<<<< </span><br>");
|
189
|
|
- }
|
190
|
|
-
|
191
|
|
- // 5、save trigger-info
|
|
173
|
+ // 4、save trigger-info
|
192
|
174
|
jobLog.setExecutorAddress(triggerResult.getContent());
|
193
|
175
|
jobLog.setTriggerCode(triggerResult.getCode());
|
194
|
176
|
jobLog.setTriggerMsg(triggerMsgSb.toString());
|
195
|
177
|
XxlJobDynamicScheduler.xxlJobLogDao.updateTriggerInfo(jobLog);
|
196
|
178
|
|
197
|
|
- // 6、monitor trigger
|
|
179
|
+ // 5、monitor trigger
|
198
|
180
|
JobFailMonitorHelper.monitor(jobLog.getId());
|
199
|
181
|
logger.debug(">>>>>>>>>>> xxl-job trigger end, jobId:{}", jobLog.getId());
|
200
|
182
|
}
|