【fix sonar】微服务修改文件
This commit is contained in:
+3
-45
@@ -60,8 +60,9 @@ public class DynamicRouteLoader implements ApplicationEventPublisherAware {
|
|||||||
|
|
||||||
|
|
||||||
public DynamicRouteLoader(InMemoryRouteDefinitionRepository repository, DynamicRouteService dynamicRouteService, RedisUtil redisUtil) {
|
public DynamicRouteLoader(InMemoryRouteDefinitionRepository repository, DynamicRouteService dynamicRouteService, RedisUtil redisUtil) {
|
||||||
|
if(this.repository == null){
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
|
}
|
||||||
this.dynamicRouteService = dynamicRouteService;
|
this.dynamicRouteService = dynamicRouteService;
|
||||||
this.redisUtil = redisUtil;
|
this.redisUtil = redisUtil;
|
||||||
}
|
}
|
||||||
@@ -234,49 +235,6 @@ public class DynamicRouteLoader implements ApplicationEventPublisherAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// private void loadRoutesByDataBase() {
|
|
||||||
// List<GatewayRouteVo> routeList = jdbcTemplate.query(SELECT_ROUTES, new RowMapper<GatewayRouteVo>() {
|
|
||||||
// @Override
|
|
||||||
// public GatewayRouteVo mapRow(ResultSet rs, int i) throws SQLException {
|
|
||||||
// GatewayRouteVo result = new GatewayRouteVo();
|
|
||||||
// result.setId(rs.getString("id"));
|
|
||||||
// result.setName(rs.getString("name"));
|
|
||||||
// result.setUri(rs.getString("uri"));
|
|
||||||
// result.setStatus(rs.getInt("status"));
|
|
||||||
// result.setRetryable(rs.getInt("retryable"));
|
|
||||||
// result.setPredicates(rs.getString("predicates"));
|
|
||||||
// result.setStripPrefix(rs.getInt("strip_prefix"));
|
|
||||||
// result.setPersist(rs.getInt("persist"));
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// if (ObjectUtil.isNotEmpty(routeList)) {
|
|
||||||
// // 加载路由
|
|
||||||
// routeList.forEach(route -> {
|
|
||||||
// RouteDefinition definition = new RouteDefinition();
|
|
||||||
// List<PredicateDefinition> predicatesList = Lists.newArrayList();
|
|
||||||
// List<FilterDefinition> filtersList = Lists.newArrayList();
|
|
||||||
// definition.setId(route.getId());
|
|
||||||
// String predicates = route.getPredicates();
|
|
||||||
// String filters = route.getFilters();
|
|
||||||
// if (StringUtils.isNotEmpty(predicates)) {
|
|
||||||
// predicatesList = JSON.parseArray(predicates, PredicateDefinition.class);
|
|
||||||
// definition.setPredicates(predicatesList);
|
|
||||||
// }
|
|
||||||
// if (StringUtils.isNotEmpty(filters)) {
|
|
||||||
// filtersList = JSON.parseArray(filters, FilterDefinition.class);
|
|
||||||
// definition.setFilters(filtersList);
|
|
||||||
// }
|
|
||||||
// URI uri = UriComponentsBuilder.fromUriString(route.getUri()).build().toUri();
|
|
||||||
// definition.setUri(uri);
|
|
||||||
// this.repository.save(Mono.just(definition)).subscribe();
|
|
||||||
// });
|
|
||||||
// log.info("加载路由:{}==============", routeList.size());
|
|
||||||
// Mono.empty();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监听Nacos下发的动态路由配置
|
* 监听Nacos下发的动态路由配置
|
||||||
*
|
*
|
||||||
|
|||||||
-5
@@ -73,11 +73,6 @@ public class IndexController {
|
|||||||
|
|
||||||
@RequestMapping("/help")
|
@RequestMapping("/help")
|
||||||
public String help() {
|
public String help() {
|
||||||
|
|
||||||
/*if (!PermissionInterceptor.ifLogin(request)) {
|
|
||||||
return "redirect:/toLogin";
|
|
||||||
}*/
|
|
||||||
|
|
||||||
return "help";
|
return "help";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -36,10 +36,10 @@ public class JobCodeController {
|
|||||||
List<XxlJobLogGlue> jobLogGlues = xxlJobLogGlueDao.findByJobId(jobId);
|
List<XxlJobLogGlue> jobLogGlues = xxlJobLogGlueDao.findByJobId(jobId);
|
||||||
|
|
||||||
if (jobInfo == null) {
|
if (jobInfo == null) {
|
||||||
throw new RuntimeException(I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
|
throw new IllegalArgumentException(I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
|
||||||
}
|
}
|
||||||
if (GlueTypeEnum.BEAN == GlueTypeEnum.match(jobInfo.getGlueType())) {
|
if (GlueTypeEnum.BEAN == GlueTypeEnum.match(jobInfo.getGlueType())) {
|
||||||
throw new RuntimeException(I18nUtil.getString("jobinfo_glue_gluetype_unvalid"));
|
throw new IllegalArgumentException(I18nUtil.getString("jobinfo_glue_gluetype_unvalid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// valid permission
|
// valid permission
|
||||||
|
|||||||
+42
-23
@@ -74,14 +74,9 @@ public class JobGroupController {
|
|||||||
return new ReturnT<>(500, (I18nUtil.getString(systemPleaseInput) + I18nUtil.getString("jobgroup_field_title")) );
|
return new ReturnT<>(500, (I18nUtil.getString(systemPleaseInput) + I18nUtil.getString("jobgroup_field_title")) );
|
||||||
}
|
}
|
||||||
if (xxlJobGroup.getAddressType()!=0) {
|
if (xxlJobGroup.getAddressType()!=0) {
|
||||||
if (xxlJobGroup.getAddressList()==null || xxlJobGroup.getAddressList().trim().length()==0) {
|
ReturnT<String> x = getStringReturnT(xxlJobGroup);
|
||||||
return new ReturnT<>(500, I18nUtil.getString("jobgroup_field_addressType_limit") );
|
if (x != null) {
|
||||||
}
|
return x;
|
||||||
String[] addresss = xxlJobGroup.getAddressList().split(",");
|
|
||||||
for (String item: addresss) {
|
|
||||||
if (item==null || item.trim().length()==0) {
|
|
||||||
return new ReturnT<>(500, I18nUtil.getString("jobgroup_field_registryList_unvalid") );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,6 +84,19 @@ public class JobGroupController {
|
|||||||
return (ret>0)?ReturnT.SUCCESS:ReturnT.FAIL;
|
return (ret>0)?ReturnT.SUCCESS:ReturnT.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ReturnT<String> getStringReturnT(XxlJobGroup xxlJobGroup) {
|
||||||
|
if (xxlJobGroup.getAddressList()==null || xxlJobGroup.getAddressList().trim().length()==0) {
|
||||||
|
return new ReturnT<>(500, I18nUtil.getString("jobgroup_field_addressType_limit") );
|
||||||
|
}
|
||||||
|
String[] addresss = xxlJobGroup.getAddressList().split(",");
|
||||||
|
for (String item: addresss) {
|
||||||
|
if (item==null || item.trim().length()==0) {
|
||||||
|
return new ReturnT<>(500, I18nUtil.getString("jobgroup_field_registryList_unvalid") );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping("/update")
|
@RequestMapping("/update")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ReturnT<String> update(XxlJobGroup xxlJobGroup){
|
public ReturnT<String> update(XxlJobGroup xxlJobGroup){
|
||||||
@@ -105,33 +113,44 @@ 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());
|
||||||
StringBuilder addressListStr = new StringBuilder();
|
StringBuilder addressListStr = getStringBuilder(registryList);
|
||||||
if (registryList!=null && !registryList.isEmpty()) {
|
|
||||||
Collections.sort(registryList);
|
|
||||||
addressListStr = new StringBuilder();
|
|
||||||
for (String item:registryList) {
|
|
||||||
addressListStr.append(item).append(",");
|
|
||||||
}
|
|
||||||
addressListStr = new StringBuilder(addressListStr.substring(0, addressListStr.length() - 1));
|
|
||||||
}
|
|
||||||
xxlJobGroup.setAddressList(addressListStr.toString());
|
xxlJobGroup.setAddressList(addressListStr.toString());
|
||||||
} else {
|
} else {
|
||||||
// 1=手动录入
|
// 1=手动录入
|
||||||
if (xxlJobGroup.getAddressList()==null || xxlJobGroup.getAddressList().trim().length()==0) {
|
if (xxlJobGroup.getAddressList()==null || xxlJobGroup.getAddressList().trim().length()==0) {
|
||||||
return new ReturnT<>(500, I18nUtil.getString("jobgroup_field_addressType_limit") );
|
return new ReturnT<>(500, I18nUtil.getString("jobgroup_field_addressType_limit") );
|
||||||
}
|
}
|
||||||
String[] addresss = xxlJobGroup.getAddressList().split(",");
|
if (getAddresss(xxlJobGroup))
|
||||||
for (String item: addresss) {
|
return new ReturnT<>(500, I18nUtil.getString("jobgroup_field_registryList_unvalid"));
|
||||||
if (item==null || item.trim().length()==0) {
|
|
||||||
return new ReturnT<>(500, I18nUtil.getString("jobgroup_field_registryList_unvalid") );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = xxlJobGroupDao.update(xxlJobGroup);
|
int ret = xxlJobGroupDao.update(xxlJobGroup);
|
||||||
return (ret>0)?ReturnT.SUCCESS:ReturnT.FAIL;
|
return (ret>0)?ReturnT.SUCCESS:ReturnT.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean getAddresss(XxlJobGroup xxlJobGroup) {
|
||||||
|
String[] addresss = xxlJobGroup.getAddressList().split(",");
|
||||||
|
for (String item : addresss) {
|
||||||
|
if (item == null || item.trim().length() == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private StringBuilder getStringBuilder(List<String> registryList) {
|
||||||
|
StringBuilder addressListStr = new StringBuilder();
|
||||||
|
if (registryList!=null && !registryList.isEmpty()) {
|
||||||
|
Collections.sort(registryList);
|
||||||
|
addressListStr = new StringBuilder();
|
||||||
|
for (String item:registryList) {
|
||||||
|
addressListStr.append(item).append(",");
|
||||||
|
}
|
||||||
|
addressListStr = new StringBuilder(addressListStr.substring(0, addressListStr.length() - 1));
|
||||||
|
}
|
||||||
|
return addressListStr;
|
||||||
|
}
|
||||||
|
|
||||||
private List<String> findRegistryByAppName(String appnameParam){
|
private List<String> findRegistryByAppName(String appnameParam){
|
||||||
HashMap<String, List<String>> appAddressMap = new HashMap<>();
|
HashMap<String, List<String>> appAddressMap = new HashMap<>();
|
||||||
List<XxlJobRegistry> list = xxlJobRegistryDao.findAll(RegistryConfig.DEAD_TIMEOUT, new Date());
|
List<XxlJobRegistry> list = xxlJobRegistryDao.findAll(RegistryConfig.DEAD_TIMEOUT, new Date());
|
||||||
|
|||||||
+9
-4
@@ -75,18 +75,23 @@ public class JobInfoController {
|
|||||||
groupIdStrs = Arrays.asList(loginUser.getPermission().trim().split(","));
|
groupIdStrs = Arrays.asList(loginUser.getPermission().trim().split(","));
|
||||||
}
|
}
|
||||||
for (XxlJobGroup groupItem:jobGroupListAll) {
|
for (XxlJobGroup groupItem:jobGroupListAll) {
|
||||||
if (groupIdStrs.contains(String.valueOf(groupItem.getId()))) {
|
getAdd(jobGroupList, groupIdStrs, groupItem);
|
||||||
jobGroupList.add(groupItem);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return jobGroupList;
|
return jobGroupList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void getAdd(List<XxlJobGroup> jobGroupList, List<String> groupIdStrs, XxlJobGroup groupItem) {
|
||||||
|
if (groupIdStrs.contains(String.valueOf(groupItem.getId()))) {
|
||||||
|
jobGroupList.add(groupItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void validPermission(HttpServletRequest request, int jobGroup) {
|
public static void validPermission(HttpServletRequest request, int jobGroup) {
|
||||||
XxlJobUser loginUser = (XxlJobUser) request.getAttribute(LoginService.LOGIN_IDENTITY_KEY);
|
XxlJobUser loginUser = (XxlJobUser) request.getAttribute(LoginService.LOGIN_IDENTITY_KEY);
|
||||||
if (!loginUser.validPermission(jobGroup)) {
|
if (!loginUser.validPermission(jobGroup)) {
|
||||||
throw new RuntimeException(I18nUtil.getString("system_permission_limit") + "[username="+ loginUser.getUsername() +"]");
|
throw new IllegalArgumentException(I18nUtil.getString("system_permission_limit") + "[username="+ loginUser.getUsername() +"]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -64,7 +64,7 @@ public class JobLogController {
|
|||||||
if (jobId > 0) {
|
if (jobId > 0) {
|
||||||
XxlJobInfo jobInfo = xxlJobInfoDao.loadById(jobId);
|
XxlJobInfo jobInfo = xxlJobInfoDao.loadById(jobId);
|
||||||
if (jobInfo == null) {
|
if (jobInfo == null) {
|
||||||
throw new RuntimeException(I18nUtil.getString("jobinfo_field_id") + I18nUtil.getString("system_unvalid"));
|
throw new IllegalArgumentException(I18nUtil.getString("jobinfo_field_id") + I18nUtil.getString("system_unvalid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
model.addAttribute("jobInfo", jobInfo);
|
model.addAttribute("jobInfo", jobInfo);
|
||||||
@@ -120,10 +120,9 @@ public class JobLogController {
|
|||||||
public String logDetailPage(int id, Model model){
|
public String logDetailPage(int id, Model model){
|
||||||
|
|
||||||
// base check
|
// base check
|
||||||
// ReturnT<String> logStatue = ReturnT.SUCCESS;
|
|
||||||
XxlJobLog jobLog = xxlJobLogDao.load(id);
|
XxlJobLog jobLog = xxlJobLogDao.load(id);
|
||||||
if (jobLog == null) {
|
if (jobLog == null) {
|
||||||
throw new RuntimeException(I18nUtil.getString("joblog_logid_unvalid"));
|
throw new IllegalArgumentException(I18nUtil.getString("joblog_logid_unvalid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
model.addAttribute("triggerCode", jobLog.getTriggerCode());
|
model.addAttribute("triggerCode", jobLog.getTriggerCode());
|
||||||
|
|||||||
+3
-4
@@ -25,7 +25,7 @@ public class PermissionInterceptor extends HandlerInterceptorAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
|
|
||||||
if (!(handler instanceof HandlerMethod)) {
|
if (!(handler instanceof HandlerMethod)) {
|
||||||
return super.preHandle(request, response, handler);
|
return super.preHandle(request, response, handler);
|
||||||
}
|
}
|
||||||
@@ -44,16 +44,15 @@ public class PermissionInterceptor extends HandlerInterceptorAdapter {
|
|||||||
XxlJobUser loginUser = loginService.ifLogin(request, response);
|
XxlJobUser loginUser = loginService.ifLogin(request, response);
|
||||||
if (loginUser == null) {
|
if (loginUser == null) {
|
||||||
response.sendRedirect(request.getContextPath() + "/toLogin");
|
response.sendRedirect(request.getContextPath() + "/toLogin");
|
||||||
//request.getRequestDispatcher("/toLogin").forward(request, response);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (needAdminuser && loginUser.getRole()!=1) {
|
if (needAdminuser && loginUser.getRole()!=1) {
|
||||||
throw new RuntimeException(I18nUtil.getString("system_permission_limit"));
|
throw new IllegalArgumentException(I18nUtil.getString("system_permission_limit"));
|
||||||
}
|
}
|
||||||
request.setAttribute(LoginService.LOGIN_IDENTITY_KEY, loginUser);
|
request.setAttribute(LoginService.LOGIN_IDENTITY_KEY, loginUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.preHandle(request, response, handler);
|
return super.preHandle(request, response, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-6
@@ -1,10 +1,9 @@
|
|||||||
package com.xxl.job.admin.controller.resolver;
|
package com.xxl.job.admin.controller.resolver;
|
||||||
|
|
||||||
import com.xxl.job.admin.core.exception.XxlJobException;
|
import com.xxl.job.admin.core.exception.XxlJobException;
|
||||||
import com.xxl.job.core.biz.model.ReturnT;
|
|
||||||
import com.xxl.job.admin.core.util.JacksonUtil;
|
import com.xxl.job.admin.core.util.JacksonUtil;
|
||||||
import org.slf4j.Logger;
|
import com.xxl.job.core.biz.model.ReturnT;
|
||||||
import org.slf4j.LoggerFactory;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.method.HandlerMethod;
|
import org.springframework.web.method.HandlerMethod;
|
||||||
@@ -20,16 +19,16 @@ import java.io.IOException;
|
|||||||
*
|
*
|
||||||
* @author xuxueli 2016-1-6 19:22:18
|
* @author xuxueli 2016-1-6 19:22:18
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class WebExceptionResolver implements HandlerExceptionResolver {
|
public class WebExceptionResolver implements HandlerExceptionResolver {
|
||||||
private static Logger logger = LoggerFactory.getLogger(WebExceptionResolver.class);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ModelAndView resolveException(HttpServletRequest request,
|
public ModelAndView resolveException(HttpServletRequest request,
|
||||||
HttpServletResponse response, Object handler, Exception ex) {
|
HttpServletResponse response, Object handler, Exception ex) {
|
||||||
|
|
||||||
if (!(ex instanceof XxlJobException)) {
|
if (!(ex instanceof XxlJobException)) {
|
||||||
logger.error("WebExceptionResolver:{}", ex);
|
log.error("WebExceptionResolver:{}", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if json
|
// if json
|
||||||
@@ -50,7 +49,7 @@ public class WebExceptionResolver implements HandlerExceptionResolver {
|
|||||||
response.setContentType("application/json;charset=utf-8");
|
response.setContentType("application/json;charset=utf-8");
|
||||||
response.getWriter().print(JacksonUtil.writeValueAsString(errorResult));
|
response.getWriter().print(JacksonUtil.writeValueAsString(errorResult));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
return mv;
|
return mv;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+8
-6
@@ -27,6 +27,8 @@ import java.util.Set;
|
|||||||
public class EmailJobAlarm implements JobAlarm {
|
public class EmailJobAlarm implements JobAlarm {
|
||||||
private static Logger logger = LoggerFactory.getLogger(EmailJobAlarm.class);
|
private static Logger logger = LoggerFactory.getLogger(EmailJobAlarm.class);
|
||||||
|
|
||||||
|
private static final String TD = "</td>\n";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fail alarm
|
* fail alarm
|
||||||
*
|
*
|
||||||
@@ -94,11 +96,11 @@ public class EmailJobAlarm implements JobAlarm {
|
|||||||
"<table border=\"1\" cellpadding=\"3\" style=\"border-collapse:collapse; width:80%;\" >\n" +
|
"<table border=\"1\" cellpadding=\"3\" style=\"border-collapse:collapse; width:80%;\" >\n" +
|
||||||
" <thead style=\"font-weight: bold;color: #ffffff;background-color: #ff8c00;\" >" +
|
" <thead style=\"font-weight: bold;color: #ffffff;background-color: #ff8c00;\" >" +
|
||||||
" <tr>\n" +
|
" <tr>\n" +
|
||||||
" <td width=\"20%\" >"+ I18nUtil.getString("jobinfo_field_jobgroup") +"</td>\n" +
|
" <td width=\"20%\" >"+ I18nUtil.getString("jobinfo_field_jobgroup") +TD +
|
||||||
" <td width=\"10%\" >"+ I18nUtil.getString("jobinfo_field_id") +"</td>\n" +
|
" <td width=\"10%\" >"+ I18nUtil.getString("jobinfo_field_id") +TD +
|
||||||
" <td width=\"20%\" >"+ I18nUtil.getString("jobinfo_field_jobdesc") +"</td>\n" +
|
" <td width=\"20%\" >"+ I18nUtil.getString("jobinfo_field_jobdesc") +TD +
|
||||||
" <td width=\"10%\" >"+ I18nUtil.getString("jobconf_monitor_alarm_title") +"</td>\n" +
|
" <td width=\"10%\" >"+ I18nUtil.getString("jobconf_monitor_alarm_title") +TD +
|
||||||
" <td width=\"40%\" >"+ I18nUtil.getString("jobconf_monitor_alarm_content") +"</td>\n" +
|
" <td width=\"40%\" >"+ I18nUtil.getString("jobconf_monitor_alarm_content") +TD +
|
||||||
" </tr>\n" +
|
" </tr>\n" +
|
||||||
" </thead>\n" +
|
" </thead>\n" +
|
||||||
" <tbody>\n" +
|
" <tbody>\n" +
|
||||||
@@ -106,7 +108,7 @@ public class EmailJobAlarm implements JobAlarm {
|
|||||||
" <td>{0}</td>\n" +
|
" <td>{0}</td>\n" +
|
||||||
" <td>{1}</td>\n" +
|
" <td>{1}</td>\n" +
|
||||||
" <td>{2}</td>\n" +
|
" <td>{2}</td>\n" +
|
||||||
" <td>"+ I18nUtil.getString("jobconf_monitor_alarm_type") +"</td>\n" +
|
" <td>"+ I18nUtil.getString("jobconf_monitor_alarm_type") +TD +
|
||||||
" <td>{3}</td>\n" +
|
" <td>{3}</td>\n" +
|
||||||
" </tr>\n" +
|
" </tr>\n" +
|
||||||
" </tbody>\n" +
|
" </tbody>\n" +
|
||||||
|
|||||||
-2
@@ -34,8 +34,6 @@ public class XxlJobAdminConfig implements InitializingBean, DisposableBean {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
adminConfig = this;
|
|
||||||
|
|
||||||
xxlJobScheduler = new XxlJobScheduler();
|
xxlJobScheduler = new XxlJobScheduler();
|
||||||
xxlJobScheduler.init();
|
xxlJobScheduler.init();
|
||||||
}
|
}
|
||||||
|
|||||||
+579
-448
File diff suppressed because it is too large
Load Diff
-32
@@ -1,32 +0,0 @@
|
|||||||
//package com.xxl.job.admin.core.jobbean;
|
|
||||||
//
|
|
||||||
//import com.xxl.job.admin.core.thread.JobTriggerPoolHelper;
|
|
||||||
//import com.xxl.job.admin.core.trigger.TriggerTypeEnum;
|
|
||||||
//import org.quartz.JobExecutionContext;
|
|
||||||
//import org.quartz.JobExecutionException;
|
|
||||||
//import org.quartz.JobKey;
|
|
||||||
//import org.slf4j.Logger;
|
|
||||||
//import org.slf4j.LoggerFactory;
|
|
||||||
//import org.springframework.scheduling.quartz.QuartzJobBean;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * http job bean
|
|
||||||
// * “@DisallowConcurrentExecution” disable concurrent, thread size can not be only one, better given more
|
|
||||||
// * @author xuxueli 2015-12-17 18:20:34
|
|
||||||
// */
|
|
||||||
////@DisallowConcurrentExecution
|
|
||||||
//public class RemoteHttpJobBean extends QuartzJobBean {
|
|
||||||
// private static Logger logger = LoggerFactory.getLogger(RemoteHttpJobBean.class);
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected void executeInternal(JobExecutionContext context)
|
|
||||||
// throws JobExecutionException {
|
|
||||||
//
|
|
||||||
// // load jobId
|
|
||||||
// JobKey jobKey = context.getTrigger().getJobKey();
|
|
||||||
// Integer jobId = Integer.valueOf(jobKey.getName());
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
-413
@@ -1,413 +0,0 @@
|
|||||||
//package com.xxl.job.admin.core.schedule;
|
|
||||||
//
|
|
||||||
//import com.xxl.job.admin.core.conf.XxlJobAdminConfig;
|
|
||||||
//import com.xxl.job.admin.core.jobbean.RemoteHttpJobBean;
|
|
||||||
//import com.xxl.job.admin.core.model.XxlJobInfo;
|
|
||||||
//import com.xxl.job.admin.core.thread.JobFailMonitorHelper;
|
|
||||||
//import com.xxl.job.admin.core.thread.JobRegistryMonitorHelper;
|
|
||||||
//import com.xxl.job.admin.core.thread.JobTriggerPoolHelper;
|
|
||||||
//import com.xxl.job.admin.core.util.I18nUtil;
|
|
||||||
//import com.xxl.job.core.biz.AdminBiz;
|
|
||||||
//import com.xxl.job.core.biz.ExecutorBiz;
|
|
||||||
//import com.xxl.job.core.enums.ExecutorBlockStrategyEnum;
|
|
||||||
//import com.xxl.rpc.remoting.invoker.XxlRpcInvokerFactory;
|
|
||||||
//import com.xxl.rpc.remoting.invoker.call.CallType;
|
|
||||||
//import com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean;
|
|
||||||
//import com.xxl.rpc.remoting.invoker.route.LoadBalance;
|
|
||||||
//import com.xxl.rpc.remoting.net.NetEnum;
|
|
||||||
//import com.xxl.rpc.remoting.net.impl.servlet.server.ServletServerHandler;
|
|
||||||
//import com.xxl.rpc.remoting.provider.XxlRpcProviderFactory;
|
|
||||||
//import com.xxl.rpc.serialize.Serializer;
|
|
||||||
//import org.quartz.*;
|
|
||||||
//import org.quartz.Trigger.TriggerState;
|
|
||||||
//import org.quartz.impl.triggers.CronTriggerImpl;
|
|
||||||
//import org.slf4j.Logger;
|
|
||||||
//import org.slf4j.LoggerFactory;
|
|
||||||
//import org.springframework.util.Assert;
|
|
||||||
//
|
|
||||||
//import javax.servlet.ServletException;
|
|
||||||
//import javax.servlet.http.HttpServletRequest;
|
|
||||||
//import javax.servlet.http.HttpServletResponse;
|
|
||||||
//import java.io.IOException;
|
|
||||||
//import java.util.Date;
|
|
||||||
//import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * base quartz scheduler util
|
|
||||||
// * @author xuxueli 2015-12-19 16:13:53
|
|
||||||
// */
|
|
||||||
//public final class XxlJobDynamicScheduler {
|
|
||||||
// private static final Logger logger = LoggerFactory.getLogger(XxlJobDynamicScheduler_old.class);
|
|
||||||
//
|
|
||||||
// // ---------------------- param ----------------------
|
|
||||||
//
|
|
||||||
// // scheduler
|
|
||||||
// private static Scheduler scheduler;
|
|
||||||
// public void setScheduler(Scheduler scheduler) {
|
|
||||||
// XxlJobDynamicScheduler_old.scheduler = scheduler;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// // ---------------------- init + destroy ----------------------
|
|
||||||
// public void start() throws Exception {
|
|
||||||
// // valid
|
|
||||||
// Assert.notNull(scheduler, "quartz scheduler is null");
|
|
||||||
//
|
|
||||||
// // init i18n
|
|
||||||
// initI18n();
|
|
||||||
//
|
|
||||||
// // admin registry monitor run
|
|
||||||
// JobRegistryMonitorHelper.getInstance().start();
|
|
||||||
//
|
|
||||||
// // admin monitor run
|
|
||||||
// JobFailMonitorHelper.getInstance().start();
|
|
||||||
//
|
|
||||||
// // admin-server
|
|
||||||
// initRpcProvider();
|
|
||||||
//
|
|
||||||
// logger.info(">>>>>>>>> init xxl-job admin success.");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// public void destroy() throws Exception {
|
|
||||||
// // admin trigger pool stop
|
|
||||||
// JobTriggerPoolHelper.toStop();
|
|
||||||
//
|
|
||||||
// // admin registry stop
|
|
||||||
// JobRegistryMonitorHelper.getInstance().toStop();
|
|
||||||
//
|
|
||||||
// // admin monitor stop
|
|
||||||
// JobFailMonitorHelper.getInstance().toStop();
|
|
||||||
//
|
|
||||||
// // admin-server
|
|
||||||
// stopRpcProvider();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// // ---------------------- I18n ----------------------
|
|
||||||
//
|
|
||||||
// private void initI18n(){
|
|
||||||
// for (ExecutorBlockStrategyEnum item:ExecutorBlockStrategyEnum.values()) {
|
|
||||||
// item.setTitle(I18nUtil.getString("jobconf_block_".concat(item.name())));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// // ---------------------- admin rpc provider (no server version) ----------------------
|
|
||||||
// private static ServletServerHandler servletServerHandler;
|
|
||||||
// private void initRpcProvider(){
|
|
||||||
// // init
|
|
||||||
// XxlRpcProviderFactory xxlRpcProviderFactory = new XxlRpcProviderFactory();
|
|
||||||
// xxlRpcProviderFactory.initConfig(
|
|
||||||
// NetEnum.NETTY_HTTP,
|
|
||||||
// Serializer.SerializeEnum.HESSIAN.getSerializer(),
|
|
||||||
// null,
|
|
||||||
// 0,
|
|
||||||
// XxlJobAdminConfig.getAdminConfig().getAccessToken(),
|
|
||||||
// null,
|
|
||||||
// null);
|
|
||||||
//
|
|
||||||
// // add services
|
|
||||||
// xxlRpcProviderFactory.addService(AdminBiz.class.getName(), null, XxlJobAdminConfig.getAdminConfig().getAdminBiz());
|
|
||||||
//
|
|
||||||
// // servlet handler
|
|
||||||
// servletServerHandler = new ServletServerHandler(xxlRpcProviderFactory);
|
|
||||||
// }
|
|
||||||
// private void stopRpcProvider() throws Exception {
|
|
||||||
// XxlRpcInvokerFactory.getInstance().stop();
|
|
||||||
// }
|
|
||||||
// public static void invokeAdminService(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
|
|
||||||
// servletServerHandler.handle(null, request, response);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// // ---------------------- executor-client ----------------------
|
|
||||||
// private static ConcurrentHashMap<String, ExecutorBiz> executorBizRepository = new ConcurrentHashMap<String, ExecutorBiz>();
|
|
||||||
// public static ExecutorBiz getExecutorBiz(String address) throws Exception {
|
|
||||||
// // valid
|
|
||||||
// if (address==null || address.trim().length()==0) {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // load-cache
|
|
||||||
// address = address.trim();
|
|
||||||
// ExecutorBiz executorBiz = executorBizRepository.get(address);
|
|
||||||
// if (executorBiz != null) {
|
|
||||||
// return executorBiz;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // set-cache
|
|
||||||
// executorBiz = (ExecutorBiz) new XxlRpcReferenceBean(
|
|
||||||
// NetEnum.NETTY_HTTP,
|
|
||||||
// Serializer.SerializeEnum.HESSIAN.getSerializer(),
|
|
||||||
// CallType.SYNC,
|
|
||||||
// LoadBalance.ROUND,
|
|
||||||
// ExecutorBiz.class,
|
|
||||||
// null,
|
|
||||||
// 5000,
|
|
||||||
// address,
|
|
||||||
// XxlJobAdminConfig.getAdminConfig().getAccessToken(),
|
|
||||||
// null,
|
|
||||||
// null).getObject();
|
|
||||||
//
|
|
||||||
// executorBizRepository.put(address, executorBiz);
|
|
||||||
// return executorBiz;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// // ---------------------- schedule util ----------------------
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * fill job info
|
|
||||||
// *
|
|
||||||
// * @param jobInfo
|
|
||||||
// */
|
|
||||||
// public static void fillJobInfo(XxlJobInfo jobInfo) {
|
|
||||||
//
|
|
||||||
// String name = String.valueOf(jobInfo.getId());
|
|
||||||
//
|
|
||||||
// // trigger key
|
|
||||||
// TriggerKey triggerKey = TriggerKey.triggerKey(name);
|
|
||||||
// try {
|
|
||||||
//
|
|
||||||
// // trigger cron
|
|
||||||
// Trigger trigger = scheduler.getTrigger(triggerKey);
|
|
||||||
// if (trigger!=null && trigger instanceof CronTriggerImpl) {
|
|
||||||
// String cronExpression = ((CronTriggerImpl) trigger).getCronExpression();
|
|
||||||
// jobInfo.setJobCron(cronExpression);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // trigger state
|
|
||||||
// TriggerState triggerState = scheduler.getTriggerState(triggerKey);
|
|
||||||
// if (triggerState!=null) {
|
|
||||||
// jobInfo.setJobStatus(triggerState.name());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //JobKey jobKey = new JobKey(jobInfo.getJobName(), String.valueOf(jobInfo.getJobGroup()));
|
|
||||||
// //JobDetail jobDetail = scheduler.getJobDetail(jobKey);
|
|
||||||
// //String jobClass = jobDetail.getJobClass().getName();
|
|
||||||
//
|
|
||||||
// } catch (SchedulerException e) {
|
|
||||||
// logger.error(e.getMessage(), e);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * add trigger + job
|
|
||||||
// *
|
|
||||||
// * @param jobName
|
|
||||||
// * @param cronExpression
|
|
||||||
// * @return
|
|
||||||
// * @throws SchedulerException
|
|
||||||
// */
|
|
||||||
// public static boolean addJob(String jobName, String cronExpression) throws SchedulerException {
|
|
||||||
// // 1、job key
|
|
||||||
// TriggerKey triggerKey = TriggerKey.triggerKey(jobName);
|
|
||||||
// JobKey jobKey = new JobKey(jobName);
|
|
||||||
//
|
|
||||||
// // 2、valid
|
|
||||||
// if (scheduler.checkExists(triggerKey)) {
|
|
||||||
// return true; // PASS
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 3、corn trigger
|
|
||||||
// CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression).withMisfireHandlingInstructionDoNothing(); // withMisfireHandlingInstructionDoNothing 忽略掉调度终止过程中忽略的调度
|
|
||||||
// CronTrigger cronTrigger = TriggerBuilder.newTrigger().withIdentity(triggerKey).withSchedule(cronScheduleBuilder).build();
|
|
||||||
//
|
|
||||||
// // 4、job detail
|
|
||||||
// Class<? extends Job> jobClass_ = RemoteHttpJobBean.class; // Class.forName(jobInfo.getJobClass());
|
|
||||||
// JobDetail jobDetail = JobBuilder.newJob(jobClass_).withIdentity(jobKey).build();
|
|
||||||
//
|
|
||||||
// /*if (jobInfo.getJobData()!=null) {
|
|
||||||
// JobDataMap jobDataMap = jobDetail.getJobDataMap();
|
|
||||||
// jobDataMap.putAll(JacksonUtil.readValue(jobInfo.getJobData(), Map.class));
|
|
||||||
// // JobExecutionContext context.getMergedJobDataMap().get("mailGuid");
|
|
||||||
// }*/
|
|
||||||
//
|
|
||||||
// // 5、schedule job
|
|
||||||
// Date date = scheduler.scheduleJob(jobDetail, cronTrigger);
|
|
||||||
//
|
|
||||||
// logger.info(">>>>>>>>>>> addJob success(quartz), jobDetail:{}, cronTrigger:{}, date:{}", jobDetail, cronTrigger, date);
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * remove trigger + job
|
|
||||||
// *
|
|
||||||
// * @param jobName
|
|
||||||
// * @return
|
|
||||||
// * @throws SchedulerException
|
|
||||||
// */
|
|
||||||
// public static boolean removeJob(String jobName) throws SchedulerException {
|
|
||||||
//
|
|
||||||
// JobKey jobKey = new JobKey(jobName);
|
|
||||||
// scheduler.deleteJob(jobKey);
|
|
||||||
//
|
|
||||||
// /*TriggerKey triggerKey = TriggerKey.triggerKey(jobName);
|
|
||||||
// if (scheduler.checkExists(triggerKey)) {
|
|
||||||
// scheduler.unscheduleJob(triggerKey); // trigger + job
|
|
||||||
// }*/
|
|
||||||
//
|
|
||||||
// logger.info(">>>>>>>>>>> removeJob success(quartz), jobKey:{}", jobKey);
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * updateJobCron
|
|
||||||
// *
|
|
||||||
// * @param jobName
|
|
||||||
// * @param cronExpression
|
|
||||||
// * @return
|
|
||||||
// * @throws SchedulerException
|
|
||||||
// */
|
|
||||||
// public static boolean updateJobCron(String jobName, String cronExpression) throws SchedulerException {
|
|
||||||
//
|
|
||||||
// // 1、job key
|
|
||||||
// TriggerKey triggerKey = TriggerKey.triggerKey(jobName);
|
|
||||||
//
|
|
||||||
// // 2、valid
|
|
||||||
// if (!scheduler.checkExists(triggerKey)) {
|
|
||||||
// return true; // PASS
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// CronTrigger oldTrigger = (CronTrigger) scheduler.getTrigger(triggerKey);
|
|
||||||
//
|
|
||||||
// // 3、avoid repeat cron
|
|
||||||
// String oldCron = oldTrigger.getCronExpression();
|
|
||||||
// if (oldCron.equals(cronExpression)){
|
|
||||||
// return true; // PASS
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 4、new cron trigger
|
|
||||||
// CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression).withMisfireHandlingInstructionDoNothing();
|
|
||||||
// oldTrigger = oldTrigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(cronScheduleBuilder).build();
|
|
||||||
//
|
|
||||||
// // 5、rescheduleJob
|
|
||||||
// scheduler.rescheduleJob(triggerKey, oldTrigger);
|
|
||||||
//
|
|
||||||
// /*
|
|
||||||
// JobKey jobKey = new JobKey(jobName);
|
|
||||||
//
|
|
||||||
// // old job detail
|
|
||||||
// JobDetail jobDetail = scheduler.getJobDetail(jobKey);
|
|
||||||
//
|
|
||||||
// // new trigger
|
|
||||||
// HashSet<Trigger> triggerSet = new HashSet<Trigger>();
|
|
||||||
// triggerSet.add(cronTrigger);
|
|
||||||
// // cover trigger of job detail
|
|
||||||
// scheduler.scheduleJob(jobDetail, triggerSet, true);*/
|
|
||||||
//
|
|
||||||
// logger.info(">>>>>>>>>>> resumeJob success, JobName:{}", jobName);
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * pause
|
|
||||||
// *
|
|
||||||
// * @param jobName
|
|
||||||
// * @return
|
|
||||||
// * @throws SchedulerException
|
|
||||||
// */
|
|
||||||
// /*public static boolean pauseJob(String jobName) throws SchedulerException {
|
|
||||||
//
|
|
||||||
// TriggerKey triggerKey = TriggerKey.triggerKey(jobName);
|
|
||||||
//
|
|
||||||
// boolean result = false;
|
|
||||||
// if (scheduler.checkExists(triggerKey)) {
|
|
||||||
// scheduler.pauseTrigger(triggerKey);
|
|
||||||
// result = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// logger.info(">>>>>>>>>>> pauseJob {}, triggerKey:{}", (result?"success":"fail"),triggerKey);
|
|
||||||
// return result;
|
|
||||||
// }*/
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * resume
|
|
||||||
// *
|
|
||||||
// * @param jobName
|
|
||||||
// * @return
|
|
||||||
// * @throws SchedulerException
|
|
||||||
// */
|
|
||||||
// /*public static boolean resumeJob(String jobName) throws SchedulerException {
|
|
||||||
//
|
|
||||||
// TriggerKey triggerKey = TriggerKey.triggerKey(jobName);
|
|
||||||
//
|
|
||||||
// boolean result = false;
|
|
||||||
// if (scheduler.checkExists(triggerKey)) {
|
|
||||||
// scheduler.resumeTrigger(triggerKey);
|
|
||||||
// result = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// logger.info(">>>>>>>>>>> resumeJob {}, triggerKey:{}", (result?"success":"fail"), triggerKey);
|
|
||||||
// return result;
|
|
||||||
// }*/
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * run
|
|
||||||
// *
|
|
||||||
// * @param jobName
|
|
||||||
// * @return
|
|
||||||
// * @throws SchedulerException
|
|
||||||
// */
|
|
||||||
// /*public static boolean triggerJob(String jobName) throws SchedulerException {
|
|
||||||
// // TriggerKey : name + group
|
|
||||||
// JobKey jobKey = new JobKey(jobName);
|
|
||||||
// TriggerKey triggerKey = TriggerKey.triggerKey(jobName);
|
|
||||||
//
|
|
||||||
// boolean result = false;
|
|
||||||
// if (scheduler.checkExists(triggerKey)) {
|
|
||||||
// scheduler.triggerJob(jobKey);
|
|
||||||
// result = true;
|
|
||||||
// logger.info(">>>>>>>>>>> runJob success, jobKey:{}", jobKey);
|
|
||||||
// } else {
|
|
||||||
// logger.info(">>>>>>>>>>> runJob fail, jobKey:{}", jobKey);
|
|
||||||
// }
|
|
||||||
// return result;
|
|
||||||
// }*/
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * finaAllJobList
|
|
||||||
// *
|
|
||||||
// * @return
|
|
||||||
// *//*
|
|
||||||
// @Deprecated
|
|
||||||
// public static List<Map<String, Object>> finaAllJobList(){
|
|
||||||
// List<Map<String, Object>> jobList = new ArrayList<Map<String,Object>>();
|
|
||||||
//
|
|
||||||
// try {
|
|
||||||
// if (scheduler.getJobGroupNames()==null || scheduler.getJobGroupNames().size()==0) {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// String groupName = scheduler.getJobGroupNames().get(0);
|
|
||||||
// Set<JobKey> jobKeys = scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName));
|
|
||||||
// if (jobKeys!=null && jobKeys.size()>0) {
|
|
||||||
// for (JobKey jobKey : jobKeys) {
|
|
||||||
// TriggerKey triggerKey = TriggerKey.triggerKey(jobKey.getName(), Scheduler.DEFAULT_GROUP);
|
|
||||||
// Trigger trigger = scheduler.getTrigger(triggerKey);
|
|
||||||
// JobDetail jobDetail = scheduler.getJobDetail(jobKey);
|
|
||||||
// TriggerState triggerState = scheduler.getTriggerState(triggerKey);
|
|
||||||
// Map<String, Object> jobMap = new HashMap<String, Object>();
|
|
||||||
// jobMap.put("TriggerKey", triggerKey);
|
|
||||||
// jobMap.put("Trigger", trigger);
|
|
||||||
// jobMap.put("JobDetail", jobDetail);
|
|
||||||
// jobMap.put("TriggerState", triggerState);
|
|
||||||
// jobList.add(jobMap);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// } catch (SchedulerException e) {
|
|
||||||
// logger.error(e.getMessage(), e);
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// return jobList;
|
|
||||||
// }*/
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
-58
@@ -1,58 +0,0 @@
|
|||||||
//package com.xxl.job.admin.core.quartz;
|
|
||||||
//
|
|
||||||
//import org.quartz.SchedulerConfigException;
|
|
||||||
//import org.quartz.spi.ThreadPool;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * single thread pool, for async trigger
|
|
||||||
// *
|
|
||||||
// * @author xuxueli 2019-03-06
|
|
||||||
// */
|
|
||||||
//public class XxlJobThreadPool implements ThreadPool {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean runInThread(Runnable runnable) {
|
|
||||||
//
|
|
||||||
// // async run
|
|
||||||
// runnable.run();
|
|
||||||
// return true;
|
|
||||||
//
|
|
||||||
// //return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public int blockForAvailableThreads() {
|
|
||||||
// return 1;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void initialize() throws SchedulerConfigException {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void shutdown(boolean waitForJobsToComplete) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public int getPoolSize() {
|
|
||||||
// return 1;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void setInstanceId(String schedInstId) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void setInstanceName(String schedName) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // support
|
|
||||||
// public void setThreadCount(int count) {
|
|
||||||
// //
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
|
|||||||
+1
-1
@@ -33,7 +33,7 @@ public class ExecutorRouteConsistentHash extends ExecutorRouter {
|
|||||||
try {
|
try {
|
||||||
md5 = MessageDigest.getInstance("MD5");
|
md5 = MessageDigest.getInstance("MD5");
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
throw new RuntimeException("MD5 not supported", e);
|
throw new IllegalArgumentException("MD5 not supported", e);
|
||||||
}
|
}
|
||||||
md5.reset();
|
md5.reset();
|
||||||
byte[] keyBytes = null;
|
byte[] keyBytes = null;
|
||||||
|
|||||||
+16
-9
@@ -3,7 +3,10 @@ package com.xxl.job.admin.core.route.strategy;
|
|||||||
import com.xxl.job.admin.core.route.ExecutorRouter;
|
import com.xxl.job.admin.core.route.ExecutorRouter;
|
||||||
import com.xxl.job.core.biz.model.ReturnT;
|
import com.xxl.job.core.biz.model.ReturnT;
|
||||||
import com.xxl.job.core.biz.model.TriggerParam;
|
import com.xxl.job.core.biz.model.TriggerParam;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.SecureRandom;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
@@ -15,11 +18,21 @@ import java.util.concurrent.ConcurrentMap;
|
|||||||
*
|
*
|
||||||
* Created by xuxueli on 17/3/10.
|
* Created by xuxueli on 17/3/10.
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class ExecutorRouteLFU extends ExecutorRouter {
|
public class ExecutorRouteLFU extends ExecutorRouter {
|
||||||
|
|
||||||
private static ConcurrentMap<Integer, HashMap<String, Integer>> jobLfuMap = new ConcurrentHashMap<>();
|
private static ConcurrentMap<Integer, HashMap<String, Integer>> jobLfuMap = new ConcurrentHashMap<>();
|
||||||
private long cacheValidTime = 0;
|
private long cacheValidTime = 0;
|
||||||
|
|
||||||
|
private static Random rand;
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
rand = SecureRandom.getInstanceStrong();
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
log.info("Exception:{}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String route(int jobId, List<String> addressList) {
|
public String route(int jobId, List<String> addressList) {
|
||||||
|
|
||||||
// cache clear
|
// cache clear
|
||||||
@@ -38,7 +51,8 @@ public class ExecutorRouteLFU extends ExecutorRouter {
|
|||||||
// put new
|
// put new
|
||||||
for (String address: addressList) {
|
for (String address: addressList) {
|
||||||
if (!lfuItemMap.containsKey(address) || lfuItemMap.get(address) >1000000 ) {
|
if (!lfuItemMap.containsKey(address) || lfuItemMap.get(address) >1000000 ) {
|
||||||
lfuItemMap.put(address, new Random().nextInt(addressList.size())); // 初始化时主动Random一次,缓解首次压力
|
// 初始化时主动Random一次,缓解首次压力
|
||||||
|
lfuItemMap.put(address, rand.nextInt(addressList.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// remove old
|
// remove old
|
||||||
@@ -56,16 +70,9 @@ public class ExecutorRouteLFU extends ExecutorRouter {
|
|||||||
|
|
||||||
// load least userd count address
|
// load least userd count address
|
||||||
List<Map.Entry<String, Integer>> lfuItemList = new ArrayList<>(lfuItemMap.entrySet());
|
List<Map.Entry<String, Integer>> lfuItemList = new ArrayList<>(lfuItemMap.entrySet());
|
||||||
/* Collections.sort(lfuItemList, new Comparator<Map.Entry<String, Integer>>() {
|
Collections.sort(lfuItemList, Comparator.comparing(Map.Entry::getValue));
|
||||||
@Override
|
|
||||||
public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
|
|
||||||
return o1.getValue().compareTo(o2.getValue());
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
Collections.sort(lfuItemList, (o1,o2)-> o1.getValue().compareTo(o2.getValue()));
|
|
||||||
|
|
||||||
Map.Entry<String, Integer> addressItem = lfuItemList.get(0);
|
Map.Entry<String, Integer> addressItem = lfuItemList.get(0);
|
||||||
// String minAddress = addressItem.getKey();
|
|
||||||
addressItem.setValue(addressItem.getValue() + 1);
|
addressItem.setValue(addressItem.getValue() + 1);
|
||||||
|
|
||||||
return addressItem.getKey();
|
return addressItem.getKey();
|
||||||
|
|||||||
-3
@@ -44,9 +44,6 @@ public class ExecutorRouteLRU extends ExecutorRouter {
|
|||||||
|
|
||||||
// put new
|
// put new
|
||||||
for (String address: addressList) {
|
for (String address: addressList) {
|
||||||
/*if (!lruItem.containsKey(address)) {
|
|
||||||
lruItem.put(address, address);
|
|
||||||
}*/
|
|
||||||
lruItem.computeIfAbsent(address,key->address);
|
lruItem.computeIfAbsent(address,key->address);
|
||||||
}
|
}
|
||||||
// remove old
|
// remove old
|
||||||
|
|||||||
+15
-1
@@ -3,7 +3,10 @@ package com.xxl.job.admin.core.route.strategy;
|
|||||||
import com.xxl.job.admin.core.route.ExecutorRouter;
|
import com.xxl.job.admin.core.route.ExecutorRouter;
|
||||||
import com.xxl.job.core.biz.model.ReturnT;
|
import com.xxl.job.core.biz.model.ReturnT;
|
||||||
import com.xxl.job.core.biz.model.TriggerParam;
|
import com.xxl.job.core.biz.model.TriggerParam;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.SecureRandom;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@@ -12,10 +15,21 @@ import java.util.concurrent.ConcurrentMap;
|
|||||||
/**
|
/**
|
||||||
* Created by xuxueli on 17/3/10.
|
* Created by xuxueli on 17/3/10.
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class ExecutorRouteRound extends ExecutorRouter {
|
public class ExecutorRouteRound extends ExecutorRouter {
|
||||||
|
|
||||||
private static ConcurrentMap<Integer, Integer> routeCountEachJob = new ConcurrentHashMap<>();
|
private static ConcurrentMap<Integer, Integer> routeCountEachJob = new ConcurrentHashMap<>();
|
||||||
private static long cacheValidTime = 0;
|
private static long cacheValidTime = 0;
|
||||||
|
|
||||||
|
private static Random rand;
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
rand = SecureRandom.getInstanceStrong();
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
log.info("Exception:{}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static int count(int jobId) {
|
private static int count(int jobId) {
|
||||||
// cache clear
|
// cache clear
|
||||||
if (System.currentTimeMillis() > cacheValidTime) {
|
if (System.currentTimeMillis() > cacheValidTime) {
|
||||||
@@ -25,7 +39,7 @@ public class ExecutorRouteRound extends ExecutorRouter {
|
|||||||
|
|
||||||
// count++
|
// count++
|
||||||
Integer count = routeCountEachJob.get(jobId);
|
Integer count = routeCountEachJob.get(jobId);
|
||||||
count = (count==null || count>1000000)?(new Random().nextInt(100)):++count; // 初始化时主动Random一次,缓解首次压力
|
count = (count==null || count>1000000)?(rand.nextInt(100)):++count; // 初始化时主动Random一次,缓解首次压力
|
||||||
routeCountEachJob.put(jobId, count);
|
routeCountEachJob.put(jobId, count);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|||||||
+86
-76
@@ -5,6 +5,7 @@ import com.xxl.job.admin.core.model.XxlJobInfo;
|
|||||||
import com.xxl.job.admin.core.model.XxlJobLog;
|
import com.xxl.job.admin.core.model.XxlJobLog;
|
||||||
import com.xxl.job.admin.core.trigger.TriggerTypeEnum;
|
import com.xxl.job.admin.core.trigger.TriggerTypeEnum;
|
||||||
import com.xxl.job.admin.core.util.I18nUtil;
|
import com.xxl.job.admin.core.util.I18nUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -16,93 +17,102 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*
|
*
|
||||||
* @author xuxueli 2015-9-1 18:05:56
|
* @author xuxueli 2015-9-1 18:05:56
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class JobFailMonitorHelper {
|
public class JobFailMonitorHelper {
|
||||||
private static Logger logger = LoggerFactory.getLogger(JobFailMonitorHelper.class);
|
|
||||||
|
|
||||||
private static JobFailMonitorHelper instance = new JobFailMonitorHelper();
|
private static JobFailMonitorHelper instance = new JobFailMonitorHelper();
|
||||||
public static JobFailMonitorHelper getInstance(){
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------- monitor ----------------------
|
public static JobFailMonitorHelper getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
private Thread monitorThread;
|
// ---------------------- monitor ----------------------
|
||||||
private volatile boolean toStop = false;
|
|
||||||
public void start(){
|
private Thread monitorThread;
|
||||||
monitorThread = new Thread(()-> {
|
private volatile boolean toStop = false;
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
monitorThread = new Thread(() -> {
|
||||||
|
// monitor
|
||||||
|
getWhile();
|
||||||
|
|
||||||
|
log.info(">>>>>>>>>>> xxl-job, job fail monitor thread stop");
|
||||||
|
|
||||||
|
|
||||||
// monitor
|
});
|
||||||
while (!toStop) {
|
monitorThread.setDaemon(true);
|
||||||
try {
|
monitorThread.setName("xxl-job, admin JobFailMonitorHelper");
|
||||||
|
monitorThread.start();
|
||||||
List<Long> failLogIds = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().findFailJobLogIds(1000);
|
}
|
||||||
if (failLogIds!=null && !failLogIds.isEmpty()) {
|
|
||||||
for (long failLogId: failLogIds) {
|
|
||||||
|
|
||||||
// lock log
|
|
||||||
int lockRet = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().updateAlarmStatus(failLogId, 0, -1);
|
|
||||||
if (lockRet < 1) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
XxlJobLog log = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().load(failLogId);
|
|
||||||
XxlJobInfo info = XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().loadById(log.getJobId());
|
|
||||||
|
|
||||||
// 1、fail retry monitor
|
|
||||||
if (log.getExecutorFailRetryCount() > 0) {
|
|
||||||
JobTriggerPoolHelper.trigger(log.getJobId(), TriggerTypeEnum.RETRY, (log.getExecutorFailRetryCount()-1), log.getExecutorShardingParam(), log.getExecutorParam(), null);
|
|
||||||
String retryMsg = "<br><br><span style=\"color:#F39C12;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_trigger_type_retry") +"<<<<<<<<<<< </span><br>";
|
|
||||||
log.setTriggerMsg(log.getTriggerMsg() + retryMsg);
|
|
||||||
XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().updateTriggerInfo(log);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2、fail alarm monitor
|
|
||||||
int newAlarmStatus = 0; // 告警状态:0-默认、-1=锁定状态、1-无需告警、2-告警成功、3-告警失败
|
|
||||||
if (info!=null && info.getAlarmEmail()!=null && info.getAlarmEmail().trim().length()>0) {
|
|
||||||
boolean alarmResult = XxlJobAdminConfig.getAdminConfig().getJobAlarmer().alarm(info, log);
|
|
||||||
newAlarmStatus = alarmResult?2:3;
|
|
||||||
} else {
|
|
||||||
newAlarmStatus = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().updateAlarmStatus(failLogId, -1, newAlarmStatus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (!toStop) {
|
|
||||||
logger.error(">>>>>>>>>>> xxl-job, job fail monitor thread error:{}", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
TimeUnit.SECONDS.sleep(10);
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (!toStop) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
private void getWhile() {
|
||||||
|
while (!toStop) {
|
||||||
|
try {
|
||||||
|
List<Long> failLogIds = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().findFailJobLogIds(1000);
|
||||||
|
if (failLogIds != null && !failLogIds.isEmpty()) {
|
||||||
|
getFor(failLogIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(">>>>>>>>>>> xxl-job, job fail monitor thread stop");
|
} catch (Exception e) {
|
||||||
|
if (!toStop) {
|
||||||
|
log.error(">>>>>>>>>>> xxl-job, job fail monitor thread error:{}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
TimeUnit.SECONDS.sleep(10);
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (!toStop) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
|
||||||
});
|
}
|
||||||
monitorThread.setDaemon(true);
|
}
|
||||||
monitorThread.setName("xxl-job, admin JobFailMonitorHelper");
|
|
||||||
monitorThread.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toStop(){
|
private void getFor(List<Long> failLogIds) {
|
||||||
toStop = true;
|
for (long failLogId : failLogIds) {
|
||||||
// interrupt and wait
|
|
||||||
monitorThread.interrupt();
|
// lock log
|
||||||
try {
|
int lockRet = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().updateAlarmStatus(failLogId, 0, -1);
|
||||||
monitorThread.join();
|
if (lockRet < 1) {
|
||||||
} catch (InterruptedException e) {
|
continue;
|
||||||
logger.error(e.getMessage(), e);
|
}
|
||||||
}
|
XxlJobLog log = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().load(failLogId);
|
||||||
}
|
XxlJobInfo info = XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().loadById(log.getJobId());
|
||||||
|
|
||||||
|
// 1、fail retry monitor
|
||||||
|
if (log.getExecutorFailRetryCount() > 0) {
|
||||||
|
JobTriggerPoolHelper.trigger(log.getJobId(), TriggerTypeEnum.RETRY, (log.getExecutorFailRetryCount() - 1), log.getExecutorShardingParam(), log.getExecutorParam(), null);
|
||||||
|
String retryMsg = "<br><br><span style=\"color:#F39C12;\" > >>>>>>>>>>>" + I18nUtil.getString("jobconf_trigger_type_retry") + "<<<<<<<<<<< </span><br>";
|
||||||
|
log.setTriggerMsg(log.getTriggerMsg() + retryMsg);
|
||||||
|
XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().updateTriggerInfo(log);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2、fail alarm monitor
|
||||||
|
int newAlarmStatus = 0; // 告警状态:0-默认、-1=锁定状态、1-无需告警、2-告警成功、3-告警失败
|
||||||
|
if (info != null && info.getAlarmEmail() != null && info.getAlarmEmail().trim().length() > 0) {
|
||||||
|
boolean alarmResult = XxlJobAdminConfig.getAdminConfig().getJobAlarmer().alarm(info, log);
|
||||||
|
newAlarmStatus = alarmResult ? 2 : 3;
|
||||||
|
} else {
|
||||||
|
newAlarmStatus = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().updateAlarmStatus(failLogId, -1, newAlarmStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toStop() {
|
||||||
|
toStop = true;
|
||||||
|
// interrupt and wait
|
||||||
|
monitorThread.interrupt();
|
||||||
|
try {
|
||||||
|
monitorThread.join();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+114
-104
@@ -2,8 +2,7 @@ package com.xxl.job.admin.core.thread;
|
|||||||
|
|
||||||
import com.xxl.job.admin.core.conf.XxlJobAdminConfig;
|
import com.xxl.job.admin.core.conf.XxlJobAdminConfig;
|
||||||
import com.xxl.job.admin.core.model.XxlJobLogReport;
|
import com.xxl.job.admin.core.model.XxlJobLogReport;
|
||||||
import org.slf4j.Logger;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -16,131 +15,142 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*
|
*
|
||||||
* @author xuxueli 2019-11-22
|
* @author xuxueli 2019-11-22
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class JobLogReportHelper {
|
public class JobLogReportHelper {
|
||||||
private static Logger logger = LoggerFactory.getLogger(JobLogReportHelper.class);
|
|
||||||
|
|
||||||
private static JobLogReportHelper instance = new JobLogReportHelper();
|
private static JobLogReportHelper instance = new JobLogReportHelper();
|
||||||
public static JobLogReportHelper getInstance(){
|
|
||||||
|
public static JobLogReportHelper getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Thread logrThread;
|
private Thread logrThread;
|
||||||
private volatile boolean toStop = false;
|
private volatile boolean toStop = false;
|
||||||
public void start(){
|
|
||||||
logrThread = new Thread(()-> {
|
|
||||||
|
|
||||||
// last clean log time
|
public void start() {
|
||||||
long lastCleanLogTime = 0;
|
logrThread = new Thread(() -> {
|
||||||
|
// last clean log time
|
||||||
|
long lastCleanLogTime = 0;
|
||||||
|
getWhile(lastCleanLogTime);
|
||||||
|
|
||||||
|
log.info(">>>>>>>>>>> xxl-job, job log report thread stop");
|
||||||
while (!toStop) {
|
|
||||||
|
|
||||||
// 1、log-report refresh: refresh log report in 3 days
|
|
||||||
try {
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
|
|
||||||
// today
|
|
||||||
Calendar itemDay = Calendar.getInstance();
|
|
||||||
itemDay.add(Calendar.DAY_OF_MONTH, -i);
|
|
||||||
itemDay.set(Calendar.HOUR_OF_DAY, 0);
|
|
||||||
itemDay.set(Calendar.MINUTE, 0);
|
|
||||||
itemDay.set(Calendar.SECOND, 0);
|
|
||||||
itemDay.set(Calendar.MILLISECOND, 0);
|
|
||||||
|
|
||||||
Date todayFrom = itemDay.getTime();
|
|
||||||
|
|
||||||
itemDay.set(Calendar.HOUR_OF_DAY, 23);
|
|
||||||
itemDay.set(Calendar.MINUTE, 59);
|
|
||||||
itemDay.set(Calendar.SECOND, 59);
|
|
||||||
itemDay.set(Calendar.MILLISECOND, 999);
|
|
||||||
|
|
||||||
Date todayTo = itemDay.getTime();
|
|
||||||
|
|
||||||
// refresh log-report every minute
|
|
||||||
XxlJobLogReport xxlJobLogReport = new XxlJobLogReport();
|
|
||||||
xxlJobLogReport.setTriggerDay(todayFrom);
|
|
||||||
xxlJobLogReport.setRunningCount(0);
|
|
||||||
xxlJobLogReport.setSucCount(0);
|
|
||||||
xxlJobLogReport.setFailCount(0);
|
|
||||||
|
|
||||||
Map<String, Object> triggerCountMap = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().findLogReport(todayFrom, todayTo);
|
|
||||||
if (triggerCountMap!=null && triggerCountMap.size()>0) {
|
|
||||||
int triggerDayCount = triggerCountMap.containsKey("triggerDayCount")?Integer.valueOf(String.valueOf(triggerCountMap.get("triggerDayCount"))):0;
|
|
||||||
int triggerDayCountRunning = triggerCountMap.containsKey("triggerDayCountRunning")?Integer.valueOf(String.valueOf(triggerCountMap.get("triggerDayCountRunning"))):0;
|
|
||||||
int triggerDayCountSuc = triggerCountMap.containsKey("triggerDayCountSuc")?Integer.valueOf(String.valueOf(triggerCountMap.get("triggerDayCountSuc"))):0;
|
|
||||||
int triggerDayCountFail = triggerDayCount - triggerDayCountRunning - triggerDayCountSuc;
|
|
||||||
|
|
||||||
xxlJobLogReport.setRunningCount(triggerDayCountRunning);
|
|
||||||
xxlJobLogReport.setSucCount(triggerDayCountSuc);
|
|
||||||
xxlJobLogReport.setFailCount(triggerDayCountFail);
|
|
||||||
}
|
|
||||||
|
|
||||||
// do refresh
|
|
||||||
int ret = XxlJobAdminConfig.getAdminConfig().getXxlJobLogReportDao().update(xxlJobLogReport);
|
|
||||||
if (ret < 1) {
|
|
||||||
XxlJobAdminConfig.getAdminConfig().getXxlJobLogReportDao().save(xxlJobLogReport);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (!toStop) {
|
|
||||||
logger.error(">>>>>>>>>>> xxl-job, job log report thread error:{}", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2、log-clean: switch open & once each day
|
|
||||||
if (XxlJobAdminConfig.getAdminConfig().getLogretentiondays()>0
|
|
||||||
&& System.currentTimeMillis() - lastCleanLogTime > 24*60*60*1000) {
|
|
||||||
|
|
||||||
// expire-time
|
|
||||||
Calendar expiredDay = Calendar.getInstance();
|
|
||||||
expiredDay.add(Calendar.DAY_OF_MONTH, -1 * XxlJobAdminConfig.getAdminConfig().getLogretentiondays());
|
|
||||||
expiredDay.set(Calendar.HOUR_OF_DAY, 0);
|
|
||||||
expiredDay.set(Calendar.MINUTE, 0);
|
|
||||||
expiredDay.set(Calendar.SECOND, 0);
|
|
||||||
expiredDay.set(Calendar.MILLISECOND, 0);
|
|
||||||
Date clearBeforeTime = expiredDay.getTime();
|
|
||||||
|
|
||||||
// clean expired log
|
|
||||||
List<Long> logIds = null;
|
|
||||||
do {
|
|
||||||
logIds = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().findClearLogIds(0, 0, clearBeforeTime, 0, 1000);
|
|
||||||
if (logIds!=null && !logIds.isEmpty()) {
|
|
||||||
XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().clearLog(logIds);
|
|
||||||
}
|
|
||||||
} while (logIds!=null && !logIds.isEmpty());
|
|
||||||
|
|
||||||
// update clean time
|
|
||||||
lastCleanLogTime = System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
TimeUnit.MINUTES.sleep(1);
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (!toStop) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info(">>>>>>>>>>> xxl-job, job log report thread stop");
|
|
||||||
});
|
});
|
||||||
logrThread.setDaemon(true);
|
logrThread.setDaemon(true);
|
||||||
logrThread.setName("xxl-job, admin JobLogReportHelper");
|
logrThread.setName("xxl-job, admin JobLogReportHelper");
|
||||||
logrThread.start();
|
logrThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toStop(){
|
private void getWhile(long lastCleanLogTime) {
|
||||||
|
while (!toStop) {
|
||||||
|
// 1、log-report refresh: refresh log report in 3 days
|
||||||
|
try {
|
||||||
|
getFor();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (!toStop) {
|
||||||
|
log.error(">>>>>>>>>>> xxl-job, job log report thread error:{}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2、log-clean: switch open & once each day
|
||||||
|
lastCleanLogTime = getLastCleanLogTime(lastCleanLogTime);
|
||||||
|
|
||||||
|
try {
|
||||||
|
TimeUnit.MINUTES.sleep(1);
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (!toStop) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private long getLastCleanLogTime(long lastCleanLogTime) {
|
||||||
|
if (XxlJobAdminConfig.getAdminConfig().getLogretentiondays() > 0
|
||||||
|
&& System.currentTimeMillis() - lastCleanLogTime > 24 * 60 * 60 * 1000) {
|
||||||
|
|
||||||
|
// expire-time
|
||||||
|
Calendar expiredDay = Calendar.getInstance();
|
||||||
|
expiredDay.add(Calendar.DAY_OF_MONTH, -1 * XxlJobAdminConfig.getAdminConfig().getLogretentiondays());
|
||||||
|
expiredDay.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
expiredDay.set(Calendar.MINUTE, 0);
|
||||||
|
expiredDay.set(Calendar.SECOND, 0);
|
||||||
|
expiredDay.set(Calendar.MILLISECOND, 0);
|
||||||
|
Date clearBeforeTime = expiredDay.getTime();
|
||||||
|
|
||||||
|
// clean expired log
|
||||||
|
List<Long> logIds = null;
|
||||||
|
do {
|
||||||
|
logIds = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().findClearLogIds(0, 0, clearBeforeTime, 0, 1000);
|
||||||
|
if (logIds != null && !logIds.isEmpty()) {
|
||||||
|
XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().clearLog(logIds);
|
||||||
|
}
|
||||||
|
} while (logIds != null && !logIds.isEmpty());
|
||||||
|
|
||||||
|
// update clean time
|
||||||
|
lastCleanLogTime = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
return lastCleanLogTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getFor() {
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
// today
|
||||||
|
Calendar itemDay = Calendar.getInstance();
|
||||||
|
itemDay.add(Calendar.DAY_OF_MONTH, -i);
|
||||||
|
itemDay.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
itemDay.set(Calendar.MINUTE, 0);
|
||||||
|
itemDay.set(Calendar.SECOND, 0);
|
||||||
|
itemDay.set(Calendar.MILLISECOND, 0);
|
||||||
|
|
||||||
|
Date todayFrom = itemDay.getTime();
|
||||||
|
|
||||||
|
itemDay.set(Calendar.HOUR_OF_DAY, 23);
|
||||||
|
itemDay.set(Calendar.MINUTE, 59);
|
||||||
|
itemDay.set(Calendar.SECOND, 59);
|
||||||
|
itemDay.set(Calendar.MILLISECOND, 999);
|
||||||
|
|
||||||
|
Date todayTo = itemDay.getTime();
|
||||||
|
|
||||||
|
// refresh log-report every minute
|
||||||
|
XxlJobLogReport xxlJobLogReport = new XxlJobLogReport();
|
||||||
|
xxlJobLogReport.setTriggerDay(todayFrom);
|
||||||
|
xxlJobLogReport.setRunningCount(0);
|
||||||
|
xxlJobLogReport.setSucCount(0);
|
||||||
|
xxlJobLogReport.setFailCount(0);
|
||||||
|
|
||||||
|
Map<String, Object> triggerCountMap = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().findLogReport(todayFrom, todayTo);
|
||||||
|
if (triggerCountMap != null && triggerCountMap.size() > 0) {
|
||||||
|
int triggerDayCount = triggerCountMap.containsKey("triggerDayCount") ? Integer.valueOf(String.valueOf(triggerCountMap.get("triggerDayCount"))) : 0;
|
||||||
|
int triggerDayCountRunning = triggerCountMap.containsKey("triggerDayCountRunning") ? Integer.valueOf(String.valueOf(triggerCountMap.get("triggerDayCountRunning"))) : 0;
|
||||||
|
int triggerDayCountSuc = triggerCountMap.containsKey("triggerDayCountSuc") ? Integer.valueOf(String.valueOf(triggerCountMap.get("triggerDayCountSuc"))) : 0;
|
||||||
|
int triggerDayCountFail = triggerDayCount - triggerDayCountRunning - triggerDayCountSuc;
|
||||||
|
|
||||||
|
xxlJobLogReport.setRunningCount(triggerDayCountRunning);
|
||||||
|
xxlJobLogReport.setSucCount(triggerDayCountSuc);
|
||||||
|
xxlJobLogReport.setFailCount(triggerDayCountFail);
|
||||||
|
}
|
||||||
|
|
||||||
|
// do refresh
|
||||||
|
int ret = XxlJobAdminConfig.getAdminConfig().getXxlJobLogReportDao().update(xxlJobLogReport);
|
||||||
|
if (ret < 1) {
|
||||||
|
XxlJobAdminConfig.getAdminConfig().getXxlJobLogReportDao().save(xxlJobLogReport);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toStop() {
|
||||||
toStop = true;
|
toStop = true;
|
||||||
// interrupt and wait
|
// interrupt and wait
|
||||||
logrThread.interrupt();
|
logrThread.interrupt();
|
||||||
try {
|
try {
|
||||||
logrThread.join();
|
logrThread.join();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
logger.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+67
-57
@@ -5,8 +5,7 @@ import com.xxl.job.admin.core.model.XxlJobLog;
|
|||||||
import com.xxl.job.admin.core.util.I18nUtil;
|
import com.xxl.job.admin.core.util.I18nUtil;
|
||||||
import com.xxl.job.core.biz.model.ReturnT;
|
import com.xxl.job.core.biz.model.ReturnT;
|
||||||
import com.xxl.job.core.util.DateUtil;
|
import com.xxl.job.core.util.DateUtil;
|
||||||
import org.slf4j.Logger;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -17,70 +16,81 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*
|
*
|
||||||
* @author xuxueli 2015-9-1 18:05:56
|
* @author xuxueli 2015-9-1 18:05:56
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class JobLosedMonitorHelper {
|
public class JobLosedMonitorHelper {
|
||||||
private static Logger logger = LoggerFactory.getLogger(JobLosedMonitorHelper.class);
|
|
||||||
|
|
||||||
private static JobLosedMonitorHelper instance = new JobLosedMonitorHelper();
|
private static JobLosedMonitorHelper instance = new JobLosedMonitorHelper();
|
||||||
public static JobLosedMonitorHelper getInstance(){
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------- monitor ----------------------
|
public static JobLosedMonitorHelper getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
private Thread monitorThread;
|
// ---------------------- monitor ----------------------
|
||||||
private volatile boolean toStop = false;
|
|
||||||
public void start(){
|
|
||||||
monitorThread = new Thread(()->{
|
|
||||||
// monitor
|
|
||||||
while (!toStop) {
|
|
||||||
try {
|
|
||||||
// 任务结果丢失处理:调度记录停留在 "运行中" 状态超过10min,且对应执行器心跳注册失败不在线,则将本地调度主动标记失败;
|
|
||||||
Date losedTime = DateUtil.addMinutes(new Date(), -10);
|
|
||||||
List<Long> losedJobIds = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().findLostJobIds(losedTime);
|
|
||||||
|
|
||||||
if (losedJobIds!=null && !losedJobIds.isEmpty()) {
|
private Thread monitorThread;
|
||||||
for (Long logId: losedJobIds) {
|
private volatile boolean toStop = false;
|
||||||
|
|
||||||
XxlJobLog jobLog = new XxlJobLog();
|
public void start() {
|
||||||
jobLog.setId(logId);
|
monitorThread = new Thread(() -> {
|
||||||
|
// monitor
|
||||||
|
getWhile();
|
||||||
|
log.info(">>>>>>>>>>> xxl-job, JobLosedMonitorHelper stop");
|
||||||
|
});
|
||||||
|
monitorThread.setDaemon(true);
|
||||||
|
monitorThread.setName("xxl-job, admin JobLosedMonitorHelper");
|
||||||
|
monitorThread.start();
|
||||||
|
}
|
||||||
|
|
||||||
jobLog.setHandleTime(new Date());
|
private void getWhile() {
|
||||||
jobLog.setHandleCode(ReturnT.FAIL_CODE);
|
while (!toStop) {
|
||||||
jobLog.setHandleMsg( I18nUtil.getString("joblog_lost_fail") );
|
try {
|
||||||
|
// 任务结果丢失处理:调度记录停留在 "运行中" 状态超过10min,且对应执行器心跳注册失败不在线,则将本地调度主动标记失败;
|
||||||
|
Date losedTime = DateUtil.addMinutes(new Date(), -10);
|
||||||
|
List<Long> losedJobIds = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().findLostJobIds(losedTime);
|
||||||
|
|
||||||
XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().updateHandleInfo(jobLog);
|
if (losedJobIds != null && !losedJobIds.isEmpty()) {
|
||||||
}
|
getFor(losedJobIds);
|
||||||
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (!toStop) {
|
|
||||||
logger.error(">>>>>>>>>>> xxl-job, job fail monitor thread error:{}", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
TimeUnit.SECONDS.sleep(60);
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (!toStop) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
logger.info(">>>>>>>>>>> xxl-job, JobLosedMonitorHelper stop");
|
} catch (Exception e) {
|
||||||
});
|
if (!toStop) {
|
||||||
monitorThread.setDaemon(true);
|
log.error(">>>>>>>>>>> xxl-job, job fail monitor thread error:{}", e);
|
||||||
monitorThread.setName("xxl-job, admin JobLosedMonitorHelper");
|
}
|
||||||
monitorThread.start();
|
}
|
||||||
}
|
try {
|
||||||
|
TimeUnit.SECONDS.sleep(60);
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (!toStop) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void toStop(){
|
private void getFor(List<Long> losedJobIds) {
|
||||||
toStop = true;
|
for (Long logId : losedJobIds) {
|
||||||
// interrupt and wait
|
|
||||||
monitorThread.interrupt();
|
XxlJobLog jobLog = new XxlJobLog();
|
||||||
try {
|
jobLog.setId(logId);
|
||||||
monitorThread.join();
|
|
||||||
} catch (InterruptedException e) {
|
jobLog.setHandleTime(new Date());
|
||||||
logger.error(e.getMessage(), e);
|
jobLog.setHandleCode(ReturnT.FAIL_CODE);
|
||||||
}
|
jobLog.setHandleMsg(I18nUtil.getString("joblog_lost_fail"));
|
||||||
}
|
|
||||||
|
XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().updateHandleInfo(jobLog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toStop() {
|
||||||
|
toStop = true;
|
||||||
|
// interrupt and wait
|
||||||
|
monitorThread.interrupt();
|
||||||
|
try {
|
||||||
|
monitorThread.join();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+103
-84
@@ -4,105 +4,124 @@ import com.xxl.job.admin.core.conf.XxlJobAdminConfig;
|
|||||||
import com.xxl.job.admin.core.model.XxlJobGroup;
|
import com.xxl.job.admin.core.model.XxlJobGroup;
|
||||||
import com.xxl.job.admin.core.model.XxlJobRegistry;
|
import com.xxl.job.admin.core.model.XxlJobRegistry;
|
||||||
import com.xxl.job.core.enums.RegistryConfig;
|
import com.xxl.job.core.enums.RegistryConfig;
|
||||||
import org.slf4j.Logger;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* job registry instance
|
* job registry instance
|
||||||
|
*
|
||||||
* @author xuxueli 2016-10-02 19:10:24
|
* @author xuxueli 2016-10-02 19:10:24
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class JobRegistryMonitorHelper {
|
public class JobRegistryMonitorHelper {
|
||||||
private static Logger logger = LoggerFactory.getLogger(JobRegistryMonitorHelper.class);
|
|
||||||
|
|
||||||
private static JobRegistryMonitorHelper instance = new JobRegistryMonitorHelper();
|
private static JobRegistryMonitorHelper instance = new JobRegistryMonitorHelper();
|
||||||
public static JobRegistryMonitorHelper getInstance(){
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Thread registryThread;
|
public static JobRegistryMonitorHelper getInstance() {
|
||||||
private volatile boolean toStop = false;
|
return instance;
|
||||||
public void start(){
|
}
|
||||||
registryThread = new Thread(()-> {
|
|
||||||
while (!toStop) {
|
|
||||||
try {
|
|
||||||
// auto registry group
|
|
||||||
List<XxlJobGroup> groupList = XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().findByAddressType(0);
|
|
||||||
if (groupList!=null && !groupList.isEmpty()) {
|
|
||||||
|
|
||||||
// remove dead address (admin/executor)
|
private Thread registryThread;
|
||||||
List<Integer> ids = XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().findDead(RegistryConfig.DEAD_TIMEOUT, new Date());
|
private volatile boolean toStop = false;
|
||||||
if (ids!=null && !ids.isEmpty()) {
|
|
||||||
XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().removeDead(ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
// fresh online address (admin/executor)
|
public void start() {
|
||||||
HashMap<String, List<String>> appAddressMap = new HashMap<>();
|
registryThread = new Thread(() -> {
|
||||||
List<XxlJobRegistry> list = XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().findAll(RegistryConfig.DEAD_TIMEOUT, new Date());
|
getWhile();
|
||||||
if (list != null) {
|
log.info(">>>>>>>>>>> xxl-job, job registry monitor thread stop");
|
||||||
for (XxlJobRegistry item: list) {
|
});
|
||||||
if (RegistryConfig.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) {
|
registryThread.setDaemon(true);
|
||||||
String appname = item.getRegistryKey();
|
registryThread.setName("xxl-job, admin JobRegistryMonitorHelper");
|
||||||
List<String> registryList = appAddressMap.get(appname);
|
registryThread.start();
|
||||||
if (registryList == null) {
|
}
|
||||||
registryList = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!registryList.contains(item.getRegistryValue())) {
|
private void getWhile() {
|
||||||
registryList.add(item.getRegistryValue());
|
while (!toStop) {
|
||||||
}
|
try {
|
||||||
appAddressMap.put(appname, registryList);
|
// auto registry group
|
||||||
}
|
List<XxlJobGroup> groupList = XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().findByAddressType(0);
|
||||||
}
|
getGroupList(groupList);
|
||||||
}
|
} catch (Exception e) {
|
||||||
|
if (!toStop) {
|
||||||
|
log.error(">>>>>>>>>>> xxl-job, job registry monitor thread error:{}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
TimeUnit.SECONDS.sleep(RegistryConfig.BEAT_TIMEOUT);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
if (!toStop) {
|
||||||
|
log.error(">>>>>>>>>>> xxl-job, job registry monitor thread error:{}", e);
|
||||||
|
}
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// fresh group address
|
private void getGroupList(List<XxlJobGroup> groupList) {
|
||||||
for (XxlJobGroup group: groupList) {
|
if (groupList != null && !groupList.isEmpty()) {
|
||||||
List<String> registryList = appAddressMap.get(group.getAppname());
|
|
||||||
StringBuilder addressListStr = null;
|
|
||||||
if (registryList!=null && !registryList.isEmpty()) {
|
|
||||||
Collections.sort(registryList);
|
|
||||||
addressListStr = new StringBuilder();
|
|
||||||
for (String item:registryList) {
|
|
||||||
addressListStr.append(item).append(",");
|
|
||||||
}
|
|
||||||
addressListStr = new StringBuilder(addressListStr.substring(0, addressListStr.length() - 1));
|
|
||||||
}
|
|
||||||
group.setAddressList(addressListStr.toString());
|
|
||||||
XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().update(group);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (!toStop) {
|
|
||||||
logger.error(">>>>>>>>>>> xxl-job, job registry monitor thread error:{}", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
TimeUnit.SECONDS.sleep(RegistryConfig.BEAT_TIMEOUT);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
if (!toStop) {
|
|
||||||
logger.error(">>>>>>>>>>> xxl-job, job registry monitor thread error:{}", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logger.info(">>>>>>>>>>> xxl-job, job registry monitor thread stop");
|
|
||||||
});
|
|
||||||
registryThread.setDaemon(true);
|
|
||||||
registryThread.setName("xxl-job, admin JobRegistryMonitorHelper");
|
|
||||||
registryThread.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toStop(){
|
// remove dead address (admin/executor)
|
||||||
toStop = true;
|
List<Integer> ids = XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().findDead(RegistryConfig.DEAD_TIMEOUT, new Date());
|
||||||
// interrupt and wait
|
if (ids != null && !ids.isEmpty()) {
|
||||||
registryThread.interrupt();
|
XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().removeDead(ids);
|
||||||
try {
|
}
|
||||||
registryThread.join();
|
|
||||||
} catch (InterruptedException e) {
|
// fresh online address (admin/executor)
|
||||||
logger.error(e.getMessage(), e);
|
HashMap<String, List<String>> appAddressMap = new HashMap<>();
|
||||||
}
|
List<XxlJobRegistry> list = XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().findAll(RegistryConfig.DEAD_TIMEOUT, new Date());
|
||||||
}
|
if (list != null) {
|
||||||
|
getFor(appAddressMap, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
// fresh group address
|
||||||
|
getFreshGroupAddress(groupList, appAddressMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getFreshGroupAddress(List<XxlJobGroup> groupList, HashMap<String, List<String>> appAddressMap) {
|
||||||
|
for (XxlJobGroup group : groupList) {
|
||||||
|
List<String> registryList = appAddressMap.get(group.getAppname());
|
||||||
|
StringBuilder addressListStr = new StringBuilder();
|
||||||
|
if (registryList != null && !registryList.isEmpty()) {
|
||||||
|
Collections.sort(registryList);
|
||||||
|
for (String item : registryList) {
|
||||||
|
addressListStr.append(item).append(",");
|
||||||
|
}
|
||||||
|
addressListStr = new StringBuilder(addressListStr.substring(0, addressListStr.length() - 1));
|
||||||
|
}
|
||||||
|
group.setAddressList(addressListStr.toString());
|
||||||
|
XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().update(group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getFor(HashMap<String, List<String>> appAddressMap, List<XxlJobRegistry> list) {
|
||||||
|
for (XxlJobRegistry item : list) {
|
||||||
|
if (RegistryConfig.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) {
|
||||||
|
String appname = item.getRegistryKey();
|
||||||
|
List<String> registryList = appAddressMap.get(appname);
|
||||||
|
if (registryList == null) {
|
||||||
|
registryList = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!registryList.contains(item.getRegistryValue())) {
|
||||||
|
registryList.add(item.getRegistryValue());
|
||||||
|
}
|
||||||
|
appAddressMap.put(appname, registryList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toStop() {
|
||||||
|
toStop = true;
|
||||||
|
// interrupt and wait
|
||||||
|
registryThread.interrupt();
|
||||||
|
try {
|
||||||
|
registryThread.join();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+270
-244
@@ -4,8 +4,7 @@ import com.xxl.job.admin.core.conf.XxlJobAdminConfig;
|
|||||||
import com.xxl.job.admin.core.cron.CronExpression;
|
import com.xxl.job.admin.core.cron.CronExpression;
|
||||||
import com.xxl.job.admin.core.model.XxlJobInfo;
|
import com.xxl.job.admin.core.model.XxlJobInfo;
|
||||||
import com.xxl.job.admin.core.trigger.TriggerTypeEnum;
|
import com.xxl.job.admin.core.trigger.TriggerTypeEnum;
|
||||||
import org.slf4j.Logger;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
@@ -18,11 +17,12 @@ import java.util.concurrent.TimeUnit;
|
|||||||
/**
|
/**
|
||||||
* @author xuxueli 2019-05-21
|
* @author xuxueli 2019-05-21
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class JobScheduleHelper {
|
public class JobScheduleHelper {
|
||||||
private static Logger logger = LoggerFactory.getLogger(JobScheduleHelper.class);
|
|
||||||
|
|
||||||
private static JobScheduleHelper instance = new JobScheduleHelper();
|
private static JobScheduleHelper instance = new JobScheduleHelper();
|
||||||
public static JobScheduleHelper getInstance(){
|
|
||||||
|
public static JobScheduleHelper getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,169 +32,14 @@ public class JobScheduleHelper {
|
|||||||
private Thread ringThread;
|
private Thread ringThread;
|
||||||
private volatile boolean scheduleThreadToStop = false;
|
private volatile boolean scheduleThreadToStop = false;
|
||||||
private volatile boolean ringThreadToStop = false;
|
private volatile boolean ringThreadToStop = false;
|
||||||
private static volatile Map<Integer, List<Integer>> ringData = new ConcurrentHashMap<>();
|
private static Map<Integer, List<Integer>> ringData = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public void start(){
|
public void start() {
|
||||||
|
|
||||||
// schedule thread
|
// schedule thread
|
||||||
scheduleThread = new Thread(()-> {
|
scheduleThread = new Thread(() -> {
|
||||||
try {
|
getThread();
|
||||||
TimeUnit.MILLISECONDS.sleep(5000 - System.currentTimeMillis()%1000 );
|
log.info(">>>>>>>>>>> xxl-job, JobScheduleHelper#scheduleThread stop");
|
||||||
} catch (InterruptedException e) {
|
|
||||||
if (!scheduleThreadToStop) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logger.info(">>>>>>>>> init xxl-job admin scheduler success.");
|
|
||||||
// pre-read count: treadpool-size * trigger-qps (each trigger cost 50ms, qps = 1000/50 = 20)
|
|
||||||
int preReadCount = (XxlJobAdminConfig.getAdminConfig().getTriggerPoolFastMax() + XxlJobAdminConfig.getAdminConfig().getTriggerPoolSlowMax()) * 20;
|
|
||||||
|
|
||||||
while (!scheduleThreadToStop) {
|
|
||||||
// Scan Job
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
Connection conn = null;
|
|
||||||
Boolean connAutoCommit = null;
|
|
||||||
PreparedStatement preparedStatement = null;
|
|
||||||
|
|
||||||
boolean preReadSuc = true;
|
|
||||||
try {
|
|
||||||
|
|
||||||
conn = XxlJobAdminConfig.getAdminConfig().getDataSource().getConnection();
|
|
||||||
connAutoCommit = conn.getAutoCommit();
|
|
||||||
conn.setAutoCommit(false);
|
|
||||||
|
|
||||||
preparedStatement = conn.prepareStatement( "select * from xxl_job_lock where lock_name = 'schedule_lock' for update" );
|
|
||||||
preparedStatement.execute();
|
|
||||||
|
|
||||||
// tx start
|
|
||||||
|
|
||||||
// 1、pre read
|
|
||||||
long nowTime = System.currentTimeMillis();
|
|
||||||
List<XxlJobInfo> scheduleList = XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().scheduleJobQuery(nowTime + PRE_READ_MS, preReadCount);
|
|
||||||
if (scheduleList!=null && !scheduleList.isEmpty()) {
|
|
||||||
// 2、push time-ring
|
|
||||||
for (XxlJobInfo jobInfo: scheduleList) {
|
|
||||||
|
|
||||||
// time-ring jump
|
|
||||||
if (nowTime > jobInfo.getTriggerNextTime() + PRE_READ_MS) {
|
|
||||||
// 2.1、trigger-expire > 5s:pass && make next-trigger-time
|
|
||||||
logger.warn(">>>>>>>>>>> xxl-job, schedule misfire, jobId = " + jobInfo.getId());
|
|
||||||
|
|
||||||
// fresh next
|
|
||||||
refreshNextValidTime(jobInfo, new Date());
|
|
||||||
|
|
||||||
} else if (nowTime > jobInfo.getTriggerNextTime()) {
|
|
||||||
// 2.2、trigger-expire < 5s:direct-trigger && make next-trigger-time
|
|
||||||
|
|
||||||
// 1、trigger
|
|
||||||
JobTriggerPoolHelper.trigger(jobInfo.getId(), TriggerTypeEnum.CRON, -1, null, null, null);
|
|
||||||
logger.debug(">>>>>>>>>>> xxl-job, schedule push trigger : jobId = {}" , jobInfo.getId() );
|
|
||||||
|
|
||||||
// 2、fresh next
|
|
||||||
refreshNextValidTime(jobInfo, new Date());
|
|
||||||
|
|
||||||
// next-trigger-time in 5s, pre-read again
|
|
||||||
if (jobInfo.getTriggerStatus()==1 && nowTime + PRE_READ_MS > jobInfo.getTriggerNextTime()) {
|
|
||||||
|
|
||||||
// 1、make ring second
|
|
||||||
int ringSecond = (int)((jobInfo.getTriggerNextTime()/1000)%60);
|
|
||||||
|
|
||||||
// 2、push time ring
|
|
||||||
pushTimeRing(ringSecond, jobInfo.getId());
|
|
||||||
|
|
||||||
// 3、fresh next
|
|
||||||
refreshNextValidTime(jobInfo, new Date(jobInfo.getTriggerNextTime()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// 2.3、trigger-pre-read:time-ring trigger && make next-trigger-time
|
|
||||||
|
|
||||||
// 1、make ring second
|
|
||||||
int ringSecond = (int)((jobInfo.getTriggerNextTime()/1000)%60);
|
|
||||||
|
|
||||||
// 2、push time ring
|
|
||||||
pushTimeRing(ringSecond, jobInfo.getId());
|
|
||||||
|
|
||||||
// 3、fresh next
|
|
||||||
refreshNextValidTime(jobInfo, new Date(jobInfo.getTriggerNextTime()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3、update trigger info
|
|
||||||
for (XxlJobInfo jobInfo: scheduleList) {
|
|
||||||
XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().scheduleUpdate(jobInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
preReadSuc = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// tx stop
|
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (!scheduleThreadToStop) {
|
|
||||||
logger.error(">>>>>>>>>>> xxl-job, JobScheduleHelper#scheduleThread error:{}", e);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
|
|
||||||
// commit
|
|
||||||
if (conn != null) {
|
|
||||||
try {
|
|
||||||
conn.commit();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
if (!scheduleThreadToStop) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
conn.setAutoCommit(connAutoCommit);
|
|
||||||
} catch (SQLException e) {
|
|
||||||
if (!scheduleThreadToStop) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
if (!scheduleThreadToStop) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// close PreparedStatement
|
|
||||||
if (null != preparedStatement) {
|
|
||||||
try {
|
|
||||||
preparedStatement.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
if (!scheduleThreadToStop) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
long cost = System.currentTimeMillis()-start;
|
|
||||||
|
|
||||||
|
|
||||||
// Wait seconds, align second
|
|
||||||
if (cost < 1000) { // scan-overtime, not wait
|
|
||||||
try {
|
|
||||||
// pre-read period: success > scan each second; fail > skip this period;
|
|
||||||
TimeUnit.MILLISECONDS.sleep((preReadSuc?1000:PRE_READ_MS) - System.currentTimeMillis()%1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
if (!scheduleThreadToStop) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logger.info(">>>>>>>>>>> xxl-job, JobScheduleHelper#scheduleThread stop");
|
|
||||||
});
|
});
|
||||||
scheduleThread.setDaemon(true);
|
scheduleThread.setDaemon(true);
|
||||||
scheduleThread.setName("xxl-job, admin JobScheduleHelper#scheduleThread");
|
scheduleThread.setName("xxl-job, admin JobScheduleHelper#scheduleThread");
|
||||||
@@ -202,65 +47,245 @@ public class JobScheduleHelper {
|
|||||||
|
|
||||||
|
|
||||||
// ring thread
|
// ring thread
|
||||||
ringThread = new Thread(()-> {
|
ringThread = new Thread(() -> {
|
||||||
// align second
|
// align second
|
||||||
try {
|
getThread1();
|
||||||
TimeUnit.MILLISECONDS.sleep(1000 - System.currentTimeMillis()%1000 );
|
log.info(">>>>>>>>>>> xxl-job, JobScheduleHelper#ringThread stop");
|
||||||
} catch (InterruptedException e) {
|
|
||||||
if (!ringThreadToStop) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!ringThreadToStop) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
// second data
|
|
||||||
List<Integer> ringItemData = new ArrayList<>();
|
|
||||||
int nowSecond = Calendar.getInstance().get(Calendar.SECOND); // 避免处理耗时太长,跨过刻度,向前校验一个刻度;
|
|
||||||
for (int i = 0; i < 2; i++) {
|
|
||||||
List<Integer> tmpData = ringData.remove( (nowSecond+60-i)%60 );
|
|
||||||
if (tmpData != null) {
|
|
||||||
ringItemData.addAll(tmpData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ring trigger
|
|
||||||
logger.debug(">>>>>>>>>>> xxl-job, time-ring beat : " + nowSecond + " = " + Arrays.asList(ringItemData) );
|
|
||||||
if (!ringItemData.isEmpty()) {
|
|
||||||
// do trigger
|
|
||||||
for (int jobId: ringItemData) {
|
|
||||||
// do trigger
|
|
||||||
JobTriggerPoolHelper.trigger(jobId, TriggerTypeEnum.CRON, -1, null, null, null);
|
|
||||||
}
|
|
||||||
// clear
|
|
||||||
ringItemData.clear();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (!ringThreadToStop) {
|
|
||||||
logger.error(">>>>>>>>>>> xxl-job, JobScheduleHelper#ringThread error:{}", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// next second, align second
|
|
||||||
try {
|
|
||||||
TimeUnit.MILLISECONDS.sleep(1000 - System.currentTimeMillis()%1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
if (!ringThreadToStop) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logger.info(">>>>>>>>>>> xxl-job, JobScheduleHelper#ringThread stop");
|
|
||||||
});
|
});
|
||||||
ringThread.setDaemon(true);
|
ringThread.setDaemon(true);
|
||||||
ringThread.setName("xxl-job, admin JobScheduleHelper#ringThread");
|
ringThread.setName("xxl-job, admin JobScheduleHelper#ringThread");
|
||||||
ringThread.start();
|
ringThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getThread1() {
|
||||||
|
try {
|
||||||
|
TimeUnit.MILLISECONDS.sleep(1000 - System.currentTimeMillis() % 1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
if (!ringThreadToStop) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!ringThreadToStop) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
// second data
|
||||||
|
getSecondData();
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (!ringThreadToStop) {
|
||||||
|
log.error(">>>>>>>>>>> xxl-job, JobScheduleHelper#ringThread error:{}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// next second, align second
|
||||||
|
try {
|
||||||
|
TimeUnit.MILLISECONDS.sleep(1000 - System.currentTimeMillis() % 1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
if (!ringThreadToStop) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getSecondData() {
|
||||||
|
List<Integer> ringItemData = new ArrayList<>();
|
||||||
|
int nowSecond = Calendar.getInstance().get(Calendar.SECOND); // 避免处理耗时太长,跨过刻度,向前校验一个刻度;
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
List<Integer> tmpData = ringData.remove((nowSecond + 60 - i) % 60);
|
||||||
|
if (tmpData != null) {
|
||||||
|
ringItemData.addAll(tmpData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ring trigger
|
||||||
|
log.debug(">>>>>>>>>>> xxl-job, time-ring beat : " + nowSecond + " = " + Arrays.asList(ringItemData));
|
||||||
|
if (!ringItemData.isEmpty()) {
|
||||||
|
// do trigger
|
||||||
|
for (int jobId : ringItemData) {
|
||||||
|
// do trigger
|
||||||
|
JobTriggerPoolHelper.trigger(jobId, TriggerTypeEnum.CRON, -1, null, null, null);
|
||||||
|
}
|
||||||
|
// clear
|
||||||
|
ringItemData.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getThread() {
|
||||||
|
try {
|
||||||
|
TimeUnit.MILLISECONDS.sleep(5000 - System.currentTimeMillis() % 1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
if (!scheduleThreadToStop) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.info(">>>>>>>>> init xxl-job admin scheduler success.");
|
||||||
|
// pre-read count: treadpool-size * trigger-qps (each trigger cost 50ms, qps = 1000/50 = 20)
|
||||||
|
int preReadCount = (XxlJobAdminConfig.getAdminConfig().getTriggerPoolFastMax() + XxlJobAdminConfig.getAdminConfig().getTriggerPoolSlowMax()) * 20;
|
||||||
|
|
||||||
|
while (!scheduleThreadToStop) {
|
||||||
|
// Scan Job
|
||||||
|
getWhile(preReadCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getWhile(int preReadCount) {
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
Connection conn = null;
|
||||||
|
Boolean connAutoCommit = null;
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
|
||||||
|
boolean preReadSuc = true;
|
||||||
|
try {
|
||||||
|
|
||||||
|
conn = XxlJobAdminConfig.getAdminConfig().getDataSource().getConnection();
|
||||||
|
connAutoCommit = conn.getAutoCommit();
|
||||||
|
conn.setAutoCommit(false);
|
||||||
|
|
||||||
|
preparedStatement = conn.prepareStatement("select * from xxl_job_lock where lock_name = 'schedule_lock' for update");
|
||||||
|
preparedStatement.execute();
|
||||||
|
|
||||||
|
// tx start
|
||||||
|
|
||||||
|
// 1、pre read
|
||||||
|
long nowTime = System.currentTimeMillis();
|
||||||
|
List<XxlJobInfo> scheduleList = XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().scheduleJobQuery(nowTime + PRE_READ_MS, preReadCount);
|
||||||
|
if (scheduleList != null && !scheduleList.isEmpty()) {
|
||||||
|
// 2、push time-ring
|
||||||
|
getFor(nowTime, scheduleList);
|
||||||
|
|
||||||
|
// 3、update trigger info
|
||||||
|
for (XxlJobInfo jobInfo : scheduleList) {
|
||||||
|
XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().scheduleUpdate(jobInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
preReadSuc = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// tx stop
|
||||||
|
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (!scheduleThreadToStop) {
|
||||||
|
log.error(">>>>>>>>>>> xxl-job, JobScheduleHelper#scheduleThread error:{}", e);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
|
||||||
|
// commit
|
||||||
|
getFinally(conn, connAutoCommit, preparedStatement);
|
||||||
|
}
|
||||||
|
long cost = System.currentTimeMillis() - start;
|
||||||
|
|
||||||
|
|
||||||
|
// Wait seconds, align second
|
||||||
|
getCost(preReadSuc, cost);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getCost(boolean preReadSuc, long cost) {
|
||||||
|
if (cost < 1000) { // scan-overtime, not wait
|
||||||
|
try {
|
||||||
|
TimeUnit.MILLISECONDS.sleep((preReadSuc ? 1000 : PRE_READ_MS) - System.currentTimeMillis() % 1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
if (!scheduleThreadToStop) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getFinally(Connection conn, Boolean connAutoCommit, PreparedStatement preparedStatement) {
|
||||||
|
if (conn != null) {
|
||||||
|
try {
|
||||||
|
conn.commit();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
getScheduleThreadToStop(e);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
conn.setAutoCommit(connAutoCommit);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
getScheduleThreadToStop(e);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
getScheduleThreadToStop(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// close PreparedStatement
|
||||||
|
if (null != preparedStatement) {
|
||||||
|
try {
|
||||||
|
preparedStatement.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
getScheduleThreadToStop(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getScheduleThreadToStop(SQLException e) {
|
||||||
|
if (!scheduleThreadToStop) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getFor(long nowTime, List<XxlJobInfo> scheduleList) throws ParseException {
|
||||||
|
for (XxlJobInfo jobInfo : scheduleList) {
|
||||||
|
|
||||||
|
// time-ring jump
|
||||||
|
if (nowTime > jobInfo.getTriggerNextTime() + PRE_READ_MS) {
|
||||||
|
// 2.1、trigger-expire > 5s:pass && make next-trigger-time
|
||||||
|
log.warn(">>>>>>>>>>> xxl-job, schedule misfire, jobId = " + jobInfo.getId());
|
||||||
|
|
||||||
|
// fresh next
|
||||||
|
refreshNextValidTime(jobInfo, new Date());
|
||||||
|
|
||||||
|
} else if (nowTime > jobInfo.getTriggerNextTime()) {
|
||||||
|
// 2.2、trigger-expire < 5s:direct-trigger && make next-trigger-time
|
||||||
|
|
||||||
|
// 1、trigger
|
||||||
|
JobTriggerPoolHelper.trigger(jobInfo.getId(), TriggerTypeEnum.CRON, -1, null, null, null);
|
||||||
|
log.debug(">>>>>>>>>>> xxl-job, schedule push trigger : jobId = {}", jobInfo.getId());
|
||||||
|
|
||||||
|
// 2、fresh next
|
||||||
|
refreshNextValidTime(jobInfo, new Date());
|
||||||
|
|
||||||
|
// next-trigger-time in 5s, pre-read again
|
||||||
|
if (jobInfo.getTriggerStatus() == 1 && nowTime + PRE_READ_MS > jobInfo.getTriggerNextTime()) {
|
||||||
|
|
||||||
|
// 1、make ring second
|
||||||
|
int ringSecond = (int) ((jobInfo.getTriggerNextTime() / 1000) % 60);
|
||||||
|
|
||||||
|
// 2、push time ring
|
||||||
|
pushTimeRing(ringSecond, jobInfo.getId());
|
||||||
|
|
||||||
|
// 3、fresh next
|
||||||
|
refreshNextValidTime(jobInfo, new Date(jobInfo.getTriggerNextTime()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// 2.3、trigger-pre-read:time-ring trigger && make next-trigger-time
|
||||||
|
|
||||||
|
// 1、make ring second
|
||||||
|
int ringSecond = (int) ((jobInfo.getTriggerNextTime() / 1000) % 60);
|
||||||
|
|
||||||
|
// 2、push time ring
|
||||||
|
pushTimeRing(ringSecond, jobInfo.getId());
|
||||||
|
|
||||||
|
// 3、fresh next
|
||||||
|
refreshNextValidTime(jobInfo, new Date(jobInfo.getTriggerNextTime()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void refreshNextValidTime(XxlJobInfo jobInfo, Date fromTime) throws ParseException {
|
private void refreshNextValidTime(XxlJobInfo jobInfo, Date fromTime) throws ParseException {
|
||||||
Date nextValidTime = new CronExpression(jobInfo.getJobCron()).getNextValidTimeAfter(fromTime);
|
Date nextValidTime = new CronExpression(jobInfo.getJobCron()).getNextValidTimeAfter(fromTime);
|
||||||
if (nextValidTime != null) {
|
if (nextValidTime != null) {
|
||||||
@@ -273,56 +298,42 @@ public class JobScheduleHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pushTimeRing(int ringSecond, int jobId){
|
private void pushTimeRing(int ringSecond, int jobId) {
|
||||||
// push async ring
|
// push async ring
|
||||||
List<Integer> ringItemData = ringData.get(ringSecond);
|
List<Integer> ringItemData = ringData.computeIfAbsent(ringSecond, k -> new ArrayList<>());
|
||||||
if (ringItemData == null) {
|
|
||||||
ringItemData = new ArrayList<>();
|
|
||||||
ringData.put(ringSecond, ringItemData);
|
|
||||||
}
|
|
||||||
ringItemData.add(jobId);
|
ringItemData.add(jobId);
|
||||||
|
|
||||||
logger.debug(">>>>>>>>>>> xxl-job, schedule push time-ring : " + ringSecond + " = " + Arrays.asList(ringItemData) );
|
log.debug(">>>>>>>>>>> xxl-job, schedule push time-ring : " + ringSecond + " = " + Arrays.asList(ringItemData));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toStop(){
|
public void toStop() {
|
||||||
|
|
||||||
// 1、stop schedule
|
// 1、stop schedule
|
||||||
scheduleThreadToStop = true;
|
scheduleThreadToStop = true;
|
||||||
try {
|
try {
|
||||||
TimeUnit.SECONDS.sleep(1); // wait
|
TimeUnit.SECONDS.sleep(1); // wait
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
logger.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
if (scheduleThread.getState() != Thread.State.TERMINATED){
|
if (scheduleThread.getState() != Thread.State.TERMINATED) {
|
||||||
// interrupt and wait
|
// interrupt and wait
|
||||||
scheduleThread.interrupt();
|
scheduleThread.interrupt();
|
||||||
try {
|
try {
|
||||||
scheduleThread.join();
|
scheduleThread.join();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
logger.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if has ring data
|
// if has ring data
|
||||||
boolean hasRingData = false;
|
boolean hasRingData = isHasRingData();
|
||||||
if (!ringData.isEmpty()) {
|
|
||||||
Set<Map.Entry<Integer, List<Integer>>> entries = ringData.entrySet();
|
|
||||||
for (Map.Entry<Integer, List<Integer>> e : entries) {
|
|
||||||
List<Integer> tmpData = e.getValue();
|
|
||||||
if (tmpData!=null && !tmpData.isEmpty()) {
|
|
||||||
hasRingData = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hasRingData) {
|
if (hasRingData) {
|
||||||
try {
|
try {
|
||||||
TimeUnit.SECONDS.sleep(8);
|
TimeUnit.SECONDS.sleep(8);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
logger.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -332,21 +343,36 @@ public class JobScheduleHelper {
|
|||||||
try {
|
try {
|
||||||
TimeUnit.SECONDS.sleep(1);
|
TimeUnit.SECONDS.sleep(1);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
logger.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
if (ringThread.getState() != Thread.State.TERMINATED){
|
if (ringThread.getState() != Thread.State.TERMINATED) {
|
||||||
// interrupt and wait
|
// interrupt and wait
|
||||||
ringThread.interrupt();
|
ringThread.interrupt();
|
||||||
try {
|
try {
|
||||||
ringThread.join();
|
ringThread.join();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
logger.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(">>>>>>>>>>> xxl-job, JobScheduleHelper stop");
|
log.info(">>>>>>>>>>> xxl-job, JobScheduleHelper stop");
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isHasRingData() {
|
||||||
|
boolean hasRingData = false;
|
||||||
|
if (!ringData.isEmpty()) {
|
||||||
|
Set<Map.Entry<Integer, List<Integer>>> entries = ringData.entrySet();
|
||||||
|
for (Map.Entry<Integer, List<Integer>> e : entries) {
|
||||||
|
List<Integer> tmpData = e.getValue();
|
||||||
|
if (tmpData != null && !tmpData.isEmpty()) {
|
||||||
|
hasRingData = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hasRingData;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-14
@@ -32,12 +32,6 @@ public class JobTriggerPoolHelper {
|
|||||||
TimeUnit.SECONDS,
|
TimeUnit.SECONDS,
|
||||||
new LinkedBlockingQueue<>(1000),
|
new LinkedBlockingQueue<>(1000),
|
||||||
r-> new Thread(r, "xxl-job, admin JobTriggerPoolHelper-fastTriggerPool-" + r.hashCode()));
|
r-> new Thread(r, "xxl-job, admin JobTriggerPoolHelper-fastTriggerPool-" + r.hashCode()));
|
||||||
/*new ThreadFactory() {
|
|
||||||
@Override
|
|
||||||
public Thread newThread(Runnable r) {
|
|
||||||
return new Thread(r, "xxl-job, admin JobTriggerPoolHelper-fastTriggerPool-" + r.hashCode());
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
|
|
||||||
slowTriggerPool = new ThreadPoolExecutor(
|
slowTriggerPool = new ThreadPoolExecutor(
|
||||||
10,
|
10,
|
||||||
@@ -46,17 +40,10 @@ public class JobTriggerPoolHelper {
|
|||||||
TimeUnit.SECONDS,
|
TimeUnit.SECONDS,
|
||||||
new LinkedBlockingQueue<>(2000),
|
new LinkedBlockingQueue<>(2000),
|
||||||
r-> new Thread(r, "xxl-job, admin JobTriggerPoolHelper-slowTriggerPool-" + r.hashCode()));
|
r-> new Thread(r, "xxl-job, admin JobTriggerPoolHelper-slowTriggerPool-" + r.hashCode()));
|
||||||
/*new ThreadFactory() {
|
|
||||||
@Override
|
|
||||||
public Thread newThread(Runnable r) {
|
|
||||||
return new Thread(r, "xxl-job, admin JobTriggerPoolHelper-slowTriggerPool-" + r.hashCode());
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
//triggerPool.shutdown();
|
|
||||||
fastTriggerPool.shutdownNow();
|
fastTriggerPool.shutdownNow();
|
||||||
slowTriggerPool.shutdownNow();
|
slowTriggerPool.shutdownNow();
|
||||||
logger.info(">>>>>>>>> xxl-job trigger thread pool shutdown success.");
|
logger.info(">>>>>>>>> xxl-job trigger thread pool shutdown success.");
|
||||||
@@ -65,7 +52,7 @@ public class JobTriggerPoolHelper {
|
|||||||
|
|
||||||
// job timeout count
|
// job timeout count
|
||||||
private volatile long minTim = System.currentTimeMillis()/60000; // ms > min
|
private volatile long minTim = System.currentTimeMillis()/60000; // ms > min
|
||||||
private volatile ConcurrentMap<Integer, AtomicInteger> jobTimeoutCountMap = new ConcurrentHashMap<>();
|
private ConcurrentMap<Integer, AtomicInteger> jobTimeoutCountMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+42
-22
@@ -71,14 +71,7 @@ public class XxlJobTrigger {
|
|||||||
|
|
||||||
// sharding param
|
// sharding param
|
||||||
int[] shardingParam = null;
|
int[] shardingParam = null;
|
||||||
if (executorShardingParam!=null){
|
shardingParam = getInts(executorShardingParam, shardingParam);
|
||||||
String[] shardingArr = executorShardingParam.split("/");
|
|
||||||
if (shardingArr.length==2 && isNumeric(shardingArr[0]) && isNumeric(shardingArr[1])) {
|
|
||||||
shardingParam = new int[2];
|
|
||||||
shardingParam[0] = Integer.valueOf(shardingArr[0]);
|
|
||||||
shardingParam[1] = Integer.valueOf(shardingArr[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ExecutorRouteStrategyEnum.SHARDING_BROADCAST==ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null)
|
if (ExecutorRouteStrategyEnum.SHARDING_BROADCAST==ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null)
|
||||||
&& group.getRegistryList()!=null && !group.getRegistryList().isEmpty()
|
&& group.getRegistryList()!=null && !group.getRegistryList().isEmpty()
|
||||||
&& shardingParam==null) {
|
&& shardingParam==null) {
|
||||||
@@ -94,6 +87,18 @@ public class XxlJobTrigger {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int[] getInts(String executorShardingParam, int[] shardingParam) {
|
||||||
|
if (executorShardingParam!=null){
|
||||||
|
String[] shardingArr = executorShardingParam.split("/");
|
||||||
|
if (shardingArr.length==2 && isNumeric(shardingArr[0]) && isNumeric(shardingArr[1])) {
|
||||||
|
shardingParam = new int[2];
|
||||||
|
shardingParam[0] = Integer.valueOf(shardingArr[0]);
|
||||||
|
shardingParam[1] = Integer.valueOf(shardingArr[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return shardingParam;
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean isNumeric(String str){
|
private static boolean isNumeric(String str){
|
||||||
try {
|
try {
|
||||||
Integer.valueOf(str);
|
Integer.valueOf(str);
|
||||||
@@ -146,11 +151,7 @@ public class XxlJobTrigger {
|
|||||||
ReturnT<String> routeAddressResult = null;
|
ReturnT<String> routeAddressResult = null;
|
||||||
if (group.getRegistryList()!=null && !group.getRegistryList().isEmpty()) {
|
if (group.getRegistryList()!=null && !group.getRegistryList().isEmpty()) {
|
||||||
if (ExecutorRouteStrategyEnum.SHARDING_BROADCAST == executorRouteStrategyEnum) {
|
if (ExecutorRouteStrategyEnum.SHARDING_BROADCAST == executorRouteStrategyEnum) {
|
||||||
if (index < group.getRegistryList().size()) {
|
address = getString(group, index);
|
||||||
address = group.getRegistryList().get(index);
|
|
||||||
} else {
|
|
||||||
address = group.getRegistryList().get(0);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
routeAddressResult = executorRouteStrategyEnum.getRouter().route(triggerParam, group.getRegistryList());
|
routeAddressResult = executorRouteStrategyEnum.getRouter().route(triggerParam, group.getRegistryList());
|
||||||
if (routeAddressResult.getCode() == ReturnT.SUCCESS_CODE) {
|
if (routeAddressResult.getCode() == ReturnT.SUCCESS_CODE) {
|
||||||
@@ -163,11 +164,7 @@ public class XxlJobTrigger {
|
|||||||
|
|
||||||
// 4、trigger remote executor
|
// 4、trigger remote executor
|
||||||
ReturnT<String> triggerResult = null;
|
ReturnT<String> triggerResult = null;
|
||||||
if (address != null) {
|
triggerResult = getTriggerResult(triggerParam, address);
|
||||||
triggerResult = runExecutor(triggerParam, address);
|
|
||||||
} else {
|
|
||||||
triggerResult = new ReturnT<>(ReturnT.FAIL_CODE, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5、collection trigger info
|
// 5、collection trigger info
|
||||||
StringBuilder triggerMsgSb = new StringBuilder();
|
StringBuilder triggerMsgSb = new StringBuilder();
|
||||||
@@ -177,9 +174,7 @@ public class XxlJobTrigger {
|
|||||||
.append( (group.getAddressType() == 0)?I18nUtil.getString("jobgroup_field_addressType_0"):I18nUtil.getString("jobgroup_field_addressType_1") );
|
.append( (group.getAddressType() == 0)?I18nUtil.getString("jobgroup_field_addressType_0"):I18nUtil.getString("jobgroup_field_addressType_1") );
|
||||||
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobconf_trigger_exe_regaddress")).append(":").append(group.getRegistryList());
|
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobconf_trigger_exe_regaddress")).append(":").append(group.getRegistryList());
|
||||||
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorRouteStrategy")).append(":").append(executorRouteStrategyEnum.getTitle());
|
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorRouteStrategy")).append(":").append(executorRouteStrategyEnum.getTitle());
|
||||||
if (shardingParam != null) {
|
triggerMsgSbAppend(shardingParam, triggerMsgSb);
|
||||||
triggerMsgSb.append("("+shardingParam+")");
|
|
||||||
}
|
|
||||||
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorBlockStrategy")).append(":").append(blockStrategy.getTitle());
|
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorBlockStrategy")).append(":").append(blockStrategy.getTitle());
|
||||||
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_timeout")).append(":").append(jobInfo.getExecutorTimeout());
|
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_timeout")).append(":").append(jobInfo.getExecutorTimeout());
|
||||||
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorFailRetryCount")).append(":").append(finalFailRetryCount);
|
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorFailRetryCount")).append(":").append(finalFailRetryCount);
|
||||||
@@ -193,7 +188,6 @@ public class XxlJobTrigger {
|
|||||||
jobLog.setExecutorParam(jobInfo.getExecutorParam());
|
jobLog.setExecutorParam(jobInfo.getExecutorParam());
|
||||||
jobLog.setExecutorShardingParam(shardingParam);
|
jobLog.setExecutorShardingParam(shardingParam);
|
||||||
jobLog.setExecutorFailRetryCount(finalFailRetryCount);
|
jobLog.setExecutorFailRetryCount(finalFailRetryCount);
|
||||||
//jobLog.setTriggerTime();
|
|
||||||
jobLog.setTriggerCode(triggerResult.getCode());
|
jobLog.setTriggerCode(triggerResult.getCode());
|
||||||
jobLog.setTriggerMsg(triggerMsgSb.toString());
|
jobLog.setTriggerMsg(triggerMsgSb.toString());
|
||||||
XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().updateTriggerInfo(jobLog);
|
XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().updateTriggerInfo(jobLog);
|
||||||
@@ -201,6 +195,32 @@ public class XxlJobTrigger {
|
|||||||
logger.debug(">>>>>>>>>>> xxl-job trigger end, jobId:{}", jobLog.getId());
|
logger.debug(">>>>>>>>>>> xxl-job trigger end, jobId:{}", jobLog.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ReturnT<String> getTriggerResult(TriggerParam triggerParam, String address) {
|
||||||
|
ReturnT<String> triggerResult;
|
||||||
|
if (address != null) {
|
||||||
|
triggerResult = runExecutor(triggerParam, address);
|
||||||
|
} else {
|
||||||
|
triggerResult = new ReturnT<>(ReturnT.FAIL_CODE, null);
|
||||||
|
}
|
||||||
|
return triggerResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getString(XxlJobGroup group, int index) {
|
||||||
|
String address;
|
||||||
|
if (index < group.getRegistryList().size()) {
|
||||||
|
address = group.getRegistryList().get(index);
|
||||||
|
} else {
|
||||||
|
address = group.getRegistryList().get(0);
|
||||||
|
}
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void triggerMsgSbAppend(String shardingParam, StringBuilder triggerMsgSb) {
|
||||||
|
if (shardingParam != null) {
|
||||||
|
triggerMsgSb.append("("+shardingParam+")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* run executor
|
* run executor
|
||||||
* @param triggerParam
|
* @param triggerParam
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ public class FtlUtil {
|
|||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(FtlUtil.class);
|
private static Logger logger = LoggerFactory.getLogger(FtlUtil.class);
|
||||||
|
|
||||||
private static BeansWrapper wrapper = new BeansWrapperBuilder(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS).build(); //BeansWrapper.getDefaultInstance();
|
private static BeansWrapper wrapper = new BeansWrapperBuilder(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS).build();
|
||||||
|
|
||||||
public static TemplateHashModel generateStaticModel(String packageName) {
|
public static TemplateHashModel generateStaticModel(String packageName) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
+6
-1
@@ -6,6 +6,7 @@ import com.xxl.job.admin.core.util.I18nUtil;
|
|||||||
import com.xxl.job.admin.core.util.JacksonUtil;
|
import com.xxl.job.admin.core.util.JacksonUtil;
|
||||||
import com.xxl.job.admin.dao.XxlJobUserDao;
|
import com.xxl.job.admin.dao.XxlJobUserDao;
|
||||||
import com.xxl.job.core.biz.model.ReturnT;
|
import com.xxl.job.core.biz.model.ReturnT;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.util.DigestUtils;
|
import org.springframework.util.DigestUtils;
|
||||||
|
|
||||||
@@ -13,10 +14,12 @@ import javax.annotation.Resource;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xuxueli 2019-05-04 22:13:264
|
* @author xuxueli 2019-05-04 22:13:264
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Configuration
|
@Configuration
|
||||||
public class LoginService {
|
public class LoginService {
|
||||||
|
|
||||||
@@ -41,7 +44,9 @@ public class LoginService {
|
|||||||
|
|
||||||
|
|
||||||
public ReturnT<String> login(HttpServletRequest request, HttpServletResponse response, String username, String password, boolean ifRemember){
|
public ReturnT<String> login(HttpServletRequest request, HttpServletResponse response, String username, String password, boolean ifRemember){
|
||||||
|
if(Objects.isNull(request)){
|
||||||
|
log.info("未使用参数");
|
||||||
|
}
|
||||||
// param
|
// param
|
||||||
if (username==null || username.trim().length()==0 || password==null || password.trim().length()==0){
|
if (username==null || username.trim().length()==0 || password==null || password.trim().length()==0){
|
||||||
return new ReturnT<>(500, I18nUtil.getString("login_param_empty"));
|
return new ReturnT<>(500, I18nUtil.getString("login_param_empty"));
|
||||||
|
|||||||
+32
-24
@@ -14,6 +14,7 @@ import com.xxl.job.core.biz.model.HandleCallbackParam;
|
|||||||
import com.xxl.job.core.biz.model.RegistryParam;
|
import com.xxl.job.core.biz.model.RegistryParam;
|
||||||
import com.xxl.job.core.biz.model.ReturnT;
|
import com.xxl.job.core.biz.model.ReturnT;
|
||||||
import com.xxl.job.core.handler.IJobHandler;
|
import com.xxl.job.core.handler.IJobHandler;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -23,10 +24,12 @@ import javax.annotation.Resource;
|
|||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xuxueli 2017-07-27 21:54:20
|
* @author xuxueli 2017-07-27 21:54:20
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class AdminBizImpl implements AdminBiz {
|
public class AdminBizImpl implements AdminBiz {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(AdminBizImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(AdminBizImpl.class);
|
||||||
@@ -68,30 +71,7 @@ public class AdminBizImpl implements AdminBiz {
|
|||||||
XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(log.getJobId());
|
XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(log.getJobId());
|
||||||
if (xxlJobInfo!=null && xxlJobInfo.getChildJobId()!=null && xxlJobInfo.getChildJobId().trim().length()>0) {
|
if (xxlJobInfo!=null && xxlJobInfo.getChildJobId()!=null && xxlJobInfo.getChildJobId().trim().length()>0) {
|
||||||
callbackMsg = new StringBuilder("<br><br><span style=\"color:#00c0ef;\" > >>>>>>>>>>>" + I18nUtil.getString("jobconf_trigger_child_run") + "<<<<<<<<<<< </span><br>");
|
callbackMsg = new StringBuilder("<br><br><span style=\"color:#00c0ef;\" > >>>>>>>>>>>" + I18nUtil.getString("jobconf_trigger_child_run") + "<<<<<<<<<<< </span><br>");
|
||||||
|
appendCallbackMsg(callbackMsg, xxlJobInfo);
|
||||||
String[] childJobIds = xxlJobInfo.getChildJobId().split(",");
|
|
||||||
for (int i = 0; i < childJobIds.length; i++) {
|
|
||||||
int childJobId = (childJobIds[i]!=null && childJobIds[i].trim().length()>0 && isNumeric(childJobIds[i]))?Integer.valueOf(childJobIds[i]):-1;
|
|
||||||
if (childJobId > 0) {
|
|
||||||
|
|
||||||
JobTriggerPoolHelper.trigger(childJobId, TriggerTypeEnum.PARENT, -1, null, null, null);
|
|
||||||
ReturnT<String> triggerChildResult = ReturnT.SUCCESS;
|
|
||||||
|
|
||||||
// add msg
|
|
||||||
callbackMsg.append(MessageFormat.format(I18nUtil.getString("jobconf_callback_child_msg1"),
|
|
||||||
(i + 1),
|
|
||||||
childJobIds.length,
|
|
||||||
childJobIds[i],
|
|
||||||
(triggerChildResult.getCode() == ReturnT.SUCCESS_CODE ? I18nUtil.getString("system_success") : I18nUtil.getString("system_fail")),
|
|
||||||
triggerChildResult.getMsg()));
|
|
||||||
} else {
|
|
||||||
callbackMsg.append(MessageFormat.format(I18nUtil.getString("jobconf_callback_child_msg2"),
|
|
||||||
(i + 1),
|
|
||||||
childJobIds.length,
|
|
||||||
childJobIds[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,6 +100,31 @@ public class AdminBizImpl implements AdminBiz {
|
|||||||
return ReturnT.SUCCESS;
|
return ReturnT.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void appendCallbackMsg(StringBuilder callbackMsg, XxlJobInfo xxlJobInfo) {
|
||||||
|
String[] childJobIds = xxlJobInfo.getChildJobId().split(",");
|
||||||
|
for (int i = 0; i < childJobIds.length; i++) {
|
||||||
|
int childJobId = (childJobIds[i]!=null && childJobIds[i].trim().length()>0 && isNumeric(childJobIds[i]))?Integer.valueOf(childJobIds[i]):-1;
|
||||||
|
if (childJobId > 0) {
|
||||||
|
|
||||||
|
JobTriggerPoolHelper.trigger(childJobId, TriggerTypeEnum.PARENT, -1, null, null, null);
|
||||||
|
ReturnT<String> triggerChildResult = ReturnT.SUCCESS;
|
||||||
|
|
||||||
|
// add msg
|
||||||
|
callbackMsg.append(MessageFormat.format(I18nUtil.getString("jobconf_callback_child_msg1"),
|
||||||
|
(i + 1),
|
||||||
|
childJobIds.length,
|
||||||
|
childJobIds[i],
|
||||||
|
(triggerChildResult.getCode() == ReturnT.SUCCESS_CODE ? I18nUtil.getString("system_success") : I18nUtil.getString("system_fail")),
|
||||||
|
triggerChildResult.getMsg()));
|
||||||
|
} else {
|
||||||
|
callbackMsg.append(MessageFormat.format(I18nUtil.getString("jobconf_callback_child_msg2"),
|
||||||
|
(i + 1),
|
||||||
|
childJobIds.length,
|
||||||
|
childJobIds[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isNumeric(String str){
|
private boolean isNumeric(String str){
|
||||||
try {
|
try {
|
||||||
Integer.valueOf(str);
|
Integer.valueOf(str);
|
||||||
@@ -169,6 +174,9 @@ public class AdminBizImpl implements AdminBiz {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void freshGroupRegistryInfo(RegistryParam registryParam){
|
private void freshGroupRegistryInfo(RegistryParam registryParam){
|
||||||
|
if(Objects.isNull(registryParam)){
|
||||||
|
log.info("未使用参数");
|
||||||
|
}
|
||||||
// Under consideration, prevent affecting core tables
|
// Under consideration, prevent affecting core tables
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+65
-41
@@ -91,14 +91,35 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|||||||
if (GlueTypeEnum.BEAN==GlueTypeEnum.match(jobInfo.getGlueType()) && (jobInfo.getExecutorHandler()==null || jobInfo.getExecutorHandler().trim().length()==0) ) {
|
if (GlueTypeEnum.BEAN==GlueTypeEnum.match(jobInfo.getGlueType()) && (jobInfo.getExecutorHandler()==null || jobInfo.getExecutorHandler().trim().length()==0) ) {
|
||||||
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString(systemPleaseInput)+"JobHandler") );
|
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString(systemPleaseInput)+"JobHandler") );
|
||||||
}
|
}
|
||||||
|
getGlueTypeEnum(jobInfo);
|
||||||
|
|
||||||
|
// ChildJobId valid
|
||||||
|
ReturnT<String> childJobIdItem = getChildJobId(jobInfo);
|
||||||
|
if (childJobIdItem != null) {
|
||||||
|
return childJobIdItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add in db
|
||||||
|
jobInfo.setAddTime(new Date());
|
||||||
|
jobInfo.setUpdateTime(new Date());
|
||||||
|
jobInfo.setGlueUpdatetime(new Date());
|
||||||
|
xxlJobInfoDao.save(jobInfo);
|
||||||
|
if (jobInfo.getId() < 1) {
|
||||||
|
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_add")+I18nUtil.getString("system_fail")) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ReturnT<>(String.valueOf(jobInfo.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getGlueTypeEnum(XxlJobInfo jobInfo) {
|
||||||
// fix "\r" in shell
|
// fix "\r" in shell
|
||||||
if (GlueTypeEnum.GLUE_SHELL==GlueTypeEnum.match(jobInfo.getGlueType()) && jobInfo.getGlueSource()!=null) {
|
if (GlueTypeEnum.GLUE_SHELL==GlueTypeEnum.match(jobInfo.getGlueType()) && jobInfo.getGlueSource()!=null) {
|
||||||
jobInfo.setGlueSource(jobInfo.getGlueSource().replace("\r", ""));
|
jobInfo.setGlueSource(jobInfo.getGlueSource().replace("\r", ""));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ChildJobId valid
|
private ReturnT<String> getChildJobId(XxlJobInfo jobInfo) {
|
||||||
if (jobInfo.getChildJobId()!=null && jobInfo.getChildJobId().trim().length()>0) {
|
if (jobInfo.getChildJobId()!=null && jobInfo.getChildJobId().trim().length()>0) {
|
||||||
String[] childJobIds = jobInfo.getChildJobId().split(",");
|
String[] childJobIds = jobInfo.getChildJobId().split(",");
|
||||||
for (String childJobIdItem: childJobIds) {
|
for (String childJobIdItem: childJobIds) {
|
||||||
if (childJobIdItem!=null && childJobIdItem.trim().length()>0 && isNumeric(childJobIdItem)) {
|
if (childJobIdItem!=null && childJobIdItem.trim().length()>0 && isNumeric(childJobIdItem)) {
|
||||||
@@ -122,17 +143,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|||||||
|
|
||||||
jobInfo.setChildJobId(temp.toString());
|
jobInfo.setChildJobId(temp.toString());
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
// add in db
|
|
||||||
jobInfo.setAddTime(new Date());
|
|
||||||
jobInfo.setUpdateTime(new Date());
|
|
||||||
jobInfo.setGlueUpdatetime(new Date());
|
|
||||||
xxlJobInfoDao.save(jobInfo);
|
|
||||||
if (jobInfo.getId() < 1) {
|
|
||||||
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_add")+I18nUtil.getString("system_fail")) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ReturnT<>(String.valueOf(jobInfo.getId()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isNumeric(String str){
|
private boolean isNumeric(String str){
|
||||||
@@ -146,39 +157,16 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReturnT<String> update(XxlJobInfo jobInfo) {
|
public ReturnT<String> update(XxlJobInfo jobInfo) {
|
||||||
|
ReturnT<String> x = getStringReturnT(jobInfo);
|
||||||
// valid
|
if (x != null) {
|
||||||
if (!CronExpression.isValidExpression(jobInfo.getJobCron())) {
|
return x;
|
||||||
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString(jobinfoFieldCronUnvalid) );
|
|
||||||
}
|
|
||||||
if (jobInfo.getJobDesc()==null || jobInfo.getJobDesc().trim().length()==0) {
|
|
||||||
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString(systemPleaseInput)+I18nUtil.getString("jobinfo_field_jobdesc")) );
|
|
||||||
}
|
|
||||||
if (jobInfo.getAuthor()==null || jobInfo.getAuthor().trim().length()==0) {
|
|
||||||
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString(systemPleaseInput)+I18nUtil.getString("jobinfo_field_author")) );
|
|
||||||
}
|
|
||||||
if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) {
|
|
||||||
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorRouteStrategy")+I18nUtil.getString(systemUnvalid)) );
|
|
||||||
}
|
|
||||||
if (ExecutorBlockStrategyEnum.match(jobInfo.getExecutorBlockStrategy(), null) == null) {
|
|
||||||
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorBlockStrategy")+I18nUtil.getString(systemUnvalid)) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChildJobId valid
|
// ChildJobId valid
|
||||||
if (jobInfo.getChildJobId()!=null && jobInfo.getChildJobId().trim().length()>0) {
|
if (jobInfo.getChildJobId()!=null && jobInfo.getChildJobId().trim().length()>0) {
|
||||||
String[] childJobIds = jobInfo.getChildJobId().split(",");
|
String[] childJobIds = jobInfo.getChildJobId().split(",");
|
||||||
for (String childJobIdItem: childJobIds) {
|
ReturnT<String> childJobIdItem = getStringReturnT(childJobIds);
|
||||||
if (childJobIdItem!=null && childJobIdItem.trim().length()>0 && isNumeric(childJobIdItem)) {
|
if (childJobIdItem != null) return childJobIdItem;
|
||||||
XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.parseInt(childJobIdItem));
|
|
||||||
if (childJobInfo==null) {
|
|
||||||
return new ReturnT<>(ReturnT.FAIL_CODE,
|
|
||||||
MessageFormat.format((I18nUtil.getString(jobinfoFieldChildJobId)+zero+I18nUtil.getString(systemNotFound)), childJobIdItem));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return new ReturnT<>(ReturnT.FAIL_CODE,
|
|
||||||
MessageFormat.format((I18nUtil.getString(jobinfoFieldChildJobId)+zero+I18nUtil.getString(systemUnvalid)), childJobIdItem));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// join , avoid "xxx,,"
|
// join , avoid "xxx,,"
|
||||||
StringBuilder temp = new StringBuilder();
|
StringBuilder temp = new StringBuilder();
|
||||||
@@ -238,6 +226,42 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|||||||
return ReturnT.SUCCESS;
|
return ReturnT.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ReturnT<String> getStringReturnT(String[] childJobIds) {
|
||||||
|
for (String childJobIdItem: childJobIds) {
|
||||||
|
if (childJobIdItem!=null && childJobIdItem.trim().length()>0 && isNumeric(childJobIdItem)) {
|
||||||
|
XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.parseInt(childJobIdItem));
|
||||||
|
if (childJobInfo==null) {
|
||||||
|
return new ReturnT<>(ReturnT.FAIL_CODE,
|
||||||
|
MessageFormat.format((I18nUtil.getString(jobinfoFieldChildJobId)+zero+I18nUtil.getString(systemNotFound)), childJobIdItem));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return new ReturnT<>(ReturnT.FAIL_CODE,
|
||||||
|
MessageFormat.format((I18nUtil.getString(jobinfoFieldChildJobId)+zero+I18nUtil.getString(systemUnvalid)), childJobIdItem));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ReturnT<String> getStringReturnT(XxlJobInfo jobInfo) {
|
||||||
|
// valid
|
||||||
|
if (!CronExpression.isValidExpression(jobInfo.getJobCron())) {
|
||||||
|
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString(jobinfoFieldCronUnvalid) );
|
||||||
|
}
|
||||||
|
if (jobInfo.getJobDesc()==null || jobInfo.getJobDesc().trim().length()==0) {
|
||||||
|
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString(systemPleaseInput)+I18nUtil.getString("jobinfo_field_jobdesc")) );
|
||||||
|
}
|
||||||
|
if (jobInfo.getAuthor()==null || jobInfo.getAuthor().trim().length()==0) {
|
||||||
|
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString(systemPleaseInput)+I18nUtil.getString("jobinfo_field_author")) );
|
||||||
|
}
|
||||||
|
if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) {
|
||||||
|
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorRouteStrategy")+I18nUtil.getString(systemUnvalid)) );
|
||||||
|
}
|
||||||
|
if (ExecutorBlockStrategyEnum.match(jobInfo.getExecutorBlockStrategy(), null) == null) {
|
||||||
|
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorBlockStrategy")+I18nUtil.getString(systemUnvalid)) );
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReturnT<String> remove(int id) {
|
public ReturnT<String> remove(int id) {
|
||||||
XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);
|
XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);
|
||||||
|
|||||||
Reference in New Issue
Block a user