com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler Java Examples
The following examples show how to use
com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JobLogController.java From zuihou-admin-cloud with Apache License 2.0 | 6 votes |
@RequestMapping("/logDetailCat") @ResponseBody public ReturnT<LogResult> logDetailCat(String executorAddress, long triggerTime, Integer logId, Integer fromLineNum) { try { ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(executorAddress); ReturnT<LogResult> logResult = executorBiz.log(triggerTime, logId, fromLineNum); // is end if (logResult.getContent() != null && logResult.getContent().getFromLineNum() > logResult.getContent().getToLineNum()) { XxlJobLog jobLog = xxlJobLogDao.load(logId); if (jobLog.getHandleCode() > 0) { logResult.getContent().setEnd(true); } } return logResult; } catch (Exception e) { logger.error(e.getMessage(), e); return new ReturnT<LogResult>(ReturnT.FAIL_CODE, e.getMessage()); } }
Example #2
Source File: XxlJobServiceImpl.java From zuihou-admin-boot with Apache License 2.0 | 6 votes |
@Override public Map<String, Object> pageList(Integer start, Integer length, Integer jobGroup, String jobDesc, String executorHandler, String filterTime, Integer type) { // page list List<XxlJobInfo> list = xxlJobInfoDao.pageList(start, length, jobGroup, jobDesc, executorHandler, type); int listCount = xxlJobInfoDao.pageListCount(start, length, jobGroup, jobDesc, executorHandler, type); // fill job info if (list != null && list.size() > 0) { for (XxlJobInfo jobInfo : list) { XxlJobDynamicScheduler.fillJobInfo(jobInfo); } } // package result Map<String, Object> maps = new HashMap<String, Object>(); maps.put("recordsTotal", listCount); // 总记录数 maps.put("recordsFiltered", listCount); // 过滤后的总记录数 maps.put("data", list); // 分页列表 return maps; }
Example #3
Source File: JobLogController.java From zuihou-admin-boot with Apache License 2.0 | 6 votes |
@RequestMapping("/logDetailCat") @ResponseBody public ReturnT<LogResult> logDetailCat(String executorAddress, long triggerTime, Integer logId, Integer fromLineNum) { try { ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(executorAddress); ReturnT<LogResult> logResult = executorBiz.log(triggerTime, logId, fromLineNum); // is end if (logResult.getContent() != null && logResult.getContent().getFromLineNum() > logResult.getContent().getToLineNum()) { XxlJobLog jobLog = xxlJobLogDao.load(logId); if (jobLog.getHandleCode() > 0) { logResult.getContent().setEnd(true); } } return logResult; } catch (Exception e) { logger.error(e.getMessage(), e); return new ReturnT<LogResult>(ReturnT.FAIL_CODE, e.getMessage()); } }
Example #4
Source File: XxlJobServiceImpl.java From zuihou-admin-boot with Apache License 2.0 | 6 votes |
@Override public ReturnT<String> remove(Integer id) { XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id); String group = String.valueOf(xxlJobInfo.getJobGroup()); String name = String.valueOf(xxlJobInfo.getId()); try { // unbind quartz XxlJobDynamicScheduler.removeJob(name, group); xxlJobInfoDao.delete(id); xxlJobLogDao.delete(id); xxlJobLogGlueDao.deleteByJobId(id); return ReturnT.SUCCESS; } catch (SchedulerException e) { logger.error(e.getMessage(), e); return ReturnT.FAIL; } }
Example #5
Source File: JobLogController.java From open-capacity-platform with Apache License 2.0 | 6 votes |
@RequestMapping("/logDetailCat") @ResponseBody public ReturnT<LogResult> logDetailCat(String executorAddress, long triggerTime, int logId, int fromLineNum){ try { ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(executorAddress); ReturnT<LogResult> logResult = executorBiz.log(triggerTime, logId, fromLineNum); // is end if (logResult.getContent()!=null && logResult.getContent().getFromLineNum() > logResult.getContent().getToLineNum()) { XxlJobLog jobLog = xxlJobLogDao.load(logId); if (jobLog.getHandleCode() > 0) { logResult.getContent().setEnd(true); } } return logResult; } catch (Exception e) { logger.error(e.getMessage(), e); return new ReturnT<LogResult>(ReturnT.FAIL_CODE, e.getMessage()); } }
Example #6
Source File: XxlJobTrigger.java From microservices-platform with Apache License 2.0 | 6 votes |
/** * run executor * @param triggerParam * @param address * @return */ public static ReturnT<String> runExecutor(TriggerParam triggerParam, String address){ ReturnT<String> runResult = null; try { ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(address); runResult = executorBiz.run(triggerParam); } catch (Exception e) { logger.error(">>>>>>>>>>> xxl-job trigger error, please check if the executor[{}] is running.", address, e); runResult = new ReturnT<String>(ReturnT.FAIL_CODE, ThrowableUtil.toString(e)); } StringBuffer runResultSB = new StringBuffer(I18nUtil.getString("jobconf_trigger_run") + ":"); runResultSB.append("<br>address:").append(address); runResultSB.append("<br>code:").append(runResult.getCode()); runResultSB.append("<br>msg:").append(runResult.getMsg()); runResult.setMsg(runResultSB.toString()); return runResult; }
Example #7
Source File: XxlJobTrigger.java From zuihou-admin-boot with Apache License 2.0 | 6 votes |
/** * run executor * * @param triggerParam * @param address * @return */ public static ReturnT<String> runExecutor(TriggerParam triggerParam, String address) { ReturnT<String> runResult = null; try { ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(address); runResult = executorBiz.run(triggerParam); } catch (Exception e) { logger.error(">>>>>>>>>>> xxl-job trigger error, please check if the executor[{}] is running.", address, e); runResult = new ReturnT<String>(ReturnT.FAIL_CODE, ThrowableUtil.toString(e)); } StringBuffer runResultSB = new StringBuffer(I18nUtil.getString("jobconf_trigger_run") + ":"); runResultSB.append("<br>address:").append(address); runResultSB.append("<br>code:").append(runResult.getCode()); runResultSB.append("<br>msg:").append(runResult.getMsg()); runResult.setMsg(runResultSB.toString()); return runResult; }
Example #8
Source File: XxlJobServiceImpl.java From microservices-platform with Apache License 2.0 | 6 votes |
@Override public ReturnT<String> remove(int id) { XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id); String group = String.valueOf(xxlJobInfo.getJobGroup()); String name = String.valueOf(xxlJobInfo.getId()); try { // unbind quartz XxlJobDynamicScheduler.removeJob(name, group); xxlJobInfoDao.delete(id); xxlJobLogDao.delete(id); xxlJobLogGlueDao.deleteByJobId(id); return ReturnT.SUCCESS; } catch (SchedulerException e) { logger.error(e.getMessage(), e); return ReturnT.FAIL; } }
Example #9
Source File: XxlJobServiceImpl.java From microservices-platform with Apache License 2.0 | 6 votes |
@Override public Map<String, Object> pageList(int start, int length, int jobGroup, String jobDesc, String executorHandler, String filterTime) { // page list List<XxlJobInfo> list = xxlJobInfoDao.pageList(start, length, jobGroup, jobDesc, executorHandler); int list_count = xxlJobInfoDao.pageListCount(start, length, jobGroup, jobDesc, executorHandler); // fill job info if (list!=null && list.size()>0) { for (XxlJobInfo jobInfo : list) { XxlJobDynamicScheduler.fillJobInfo(jobInfo); } } // package result Map<String, Object> maps = new HashMap<String, Object>(); maps.put("recordsTotal", list_count); // 总记录数 maps.put("recordsFiltered", list_count); // 过滤后的总记录数 maps.put("data", list); // 分页列表 return maps; }
Example #10
Source File: JobLogController.java From microservices-platform with Apache License 2.0 | 6 votes |
@RequestMapping("/logDetailCat") @ResponseBody public ReturnT<LogResult> logDetailCat(String executorAddress, long triggerTime, int logId, int fromLineNum){ try { ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(executorAddress); ReturnT<LogResult> logResult = executorBiz.log(triggerTime, logId, fromLineNum); // is end if (logResult.getContent()!=null && logResult.getContent().getFromLineNum() > logResult.getContent().getToLineNum()) { XxlJobLog jobLog = xxlJobLogDao.load(logId); if (jobLog.getHandleCode() > 0) { logResult.getContent().setEnd(true); } } return logResult; } catch (Exception e) { logger.error(e.getMessage(), e); return new ReturnT<LogResult>(ReturnT.FAIL_CODE, e.getMessage()); } }
Example #11
Source File: XxlJobServiceImpl.java From zuihou-admin-cloud with Apache License 2.0 | 6 votes |
@Override public Map<String, Object> pageList(Integer start, Integer length, Integer jobGroup, String jobDesc, String executorHandler, String filterTime, Integer type) { // page list List<XxlJobInfo> list = xxlJobInfoDao.pageList(start, length, jobGroup, jobDesc, executorHandler, type); int listCount = xxlJobInfoDao.pageListCount(start, length, jobGroup, jobDesc, executorHandler, type); // fill job info if (list != null && list.size() > 0) { for (XxlJobInfo jobInfo : list) { XxlJobDynamicScheduler.fillJobInfo(jobInfo); } } // package result Map<String, Object> maps = new HashMap<String, Object>(); maps.put("recordsTotal", listCount); // 总记录数 maps.put("recordsFiltered", listCount); // 过滤后的总记录数 maps.put("data", list); // 分页列表 return maps; }
Example #12
Source File: XxlJobServiceImpl.java From zuihou-admin-cloud with Apache License 2.0 | 6 votes |
@Override public ReturnT<String> remove(Integer id) { XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id); String group = String.valueOf(xxlJobInfo.getJobGroup()); String name = String.valueOf(xxlJobInfo.getId()); try { // unbind quartz XxlJobDynamicScheduler.removeJob(name, group); xxlJobInfoDao.delete(id); xxlJobLogDao.delete(id); xxlJobLogGlueDao.deleteByJobId(id); return ReturnT.SUCCESS; } catch (SchedulerException e) { logger.error(e.getMessage(), e); return ReturnT.FAIL; } }
Example #13
Source File: XxlJobServiceImpl.java From open-capacity-platform with Apache License 2.0 | 6 votes |
@Override public Map<String, Object> pageList(int start, int length, int jobGroup, String jobDesc, String executorHandler, String filterTime) { // page list List<XxlJobInfo> list = xxlJobInfoDao.pageList(start, length, jobGroup, jobDesc, executorHandler); int list_count = xxlJobInfoDao.pageListCount(start, length, jobGroup, jobDesc, executorHandler); // fill job info if (list!=null && list.size()>0) { for (XxlJobInfo jobInfo : list) { XxlJobDynamicScheduler.fillJobInfo(jobInfo); } } // package result Map<String, Object> maps = new HashMap<String, Object>(); maps.put("recordsTotal", list_count); // 总记录数 maps.put("recordsFiltered", list_count); // 过滤后的总记录数 maps.put("data", list); // 分页列表 return maps; }
Example #14
Source File: XxlJobTrigger.java From open-capacity-platform with Apache License 2.0 | 6 votes |
/** * run executor 向执行器发送指令都是从这个方法中执行的 * @param triggerParam * @param address * @return ReturnT.content: final address */ public static ReturnT<String> runExecutor(TriggerParam triggerParam, String address){ ReturnT<String> runResult = null; try { //创建一个ExcutorBiz 的对象,重点在这个方法里面 ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(address); // 这个run 方法不会最终执行,仅仅只是为了触发 proxy object 的 invoke方法,同时将目标的类型传送给服务端, 因为在代理对象的invoke的方法里面没有执行目标对象的方法 runResult = executorBiz.run(triggerParam); } catch (Exception e) { logger.error(">>>>>>>>>>> xxl-job trigger error, please check if the executor[{}] is running.", address, e); runResult = new ReturnT<String>(ReturnT.FAIL_CODE, ""+e ); } StringBuffer runResultSB = new StringBuffer(I18nUtil.getString("jobconf_trigger_run") + ":"); runResultSB.append("<br>address:").append(address); runResultSB.append("<br>code:").append(runResult.getCode()); runResultSB.append("<br>msg:").append(runResult.getMsg()); runResult.setMsg(runResultSB.toString()); runResult.setContent(address); return runResult; }
Example #15
Source File: XxlJobServiceImpl.java From open-capacity-platform with Apache License 2.0 | 6 votes |
@Override public ReturnT<String> triggerJob(int id) { XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id); if (xxlJobInfo == null) { return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_id")+I18nUtil.getString("system_unvalid")) ); } String group = String.valueOf(xxlJobInfo.getJobGroup()); String name = String.valueOf(xxlJobInfo.getId()); try { XxlJobDynamicScheduler.triggerJob(name, group); return ReturnT.SUCCESS; } catch (SchedulerException e) { logger.error(e.getMessage(), e); return new ReturnT<String>(ReturnT.FAIL_CODE, e.getMessage()); } }
Example #16
Source File: JobFailMonitorHelper.java From open-capacity-platform with Apache License 2.0 | 6 votes |
/** * fail alarm * * @param jobLog */ private void failAlarm(XxlJobLog jobLog){ // 发送监控的邮件 XxlJobInfo info = XxlJobDynamicScheduler.xxlJobInfoDao.loadById(jobLog.getJobId()); if (info!=null && info.getAlarmEmail()!=null && info.getAlarmEmail().trim().length()>0) { Set<String> emailSet = new HashSet<String>(Arrays.asList(info.getAlarmEmail().split(","))); for (String email: emailSet) { XxlJobGroup group = XxlJobDynamicScheduler.xxlJobGroupDao.load(Integer.valueOf(info.getJobGroup())); String title = I18nUtil.getString("jobconf_monitor"); String content = MessageFormat.format(mailBodyTemplate, group!=null?group.getTitle():"null", info.getId(), info.getJobDesc()); MailUtil.sendMail(email, title, content); } } // TODO, custom alarm strategy, such as sms }
Example #17
Source File: XxlJobTrigger.java From zuihou-admin-cloud with Apache License 2.0 | 6 votes |
/** * run executor * * @param triggerParam * @param address * @return */ public static ReturnT<String> runExecutor(TriggerParam triggerParam, String address) { ReturnT<String> runResult = null; try { ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(address); runResult = executorBiz.run(triggerParam); } catch (Exception e) { logger.error(">>>>>>>>>>> xxl-job trigger error, please check if the executor[{}] is running.", address, e); runResult = new ReturnT<String>(ReturnT.FAIL_CODE, ThrowableUtil.toString(e)); } StringBuffer runResultSB = new StringBuffer(I18nUtil.getString("jobconf_trigger_run") + ":"); runResultSB.append("<br>address:").append(address); runResultSB.append("<br>code:").append(runResult.getCode()); runResultSB.append("<br>msg:").append(runResult.getMsg()); runResult.setMsg(runResultSB.toString()); return runResult; }
Example #18
Source File: XxlJobServiceImpl.java From open-capacity-platform with Apache License 2.0 | 6 votes |
@Override public ReturnT<String> remove(int id) { XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id); String group = String.valueOf(xxlJobInfo.getJobGroup()); String name = String.valueOf(xxlJobInfo.getId()); try { XxlJobDynamicScheduler.removeJob(name, group); xxlJobInfoDao.delete(id); xxlJobLogDao.delete(id); xxlJobLogGlueDao.deleteByJobId(id); return ReturnT.SUCCESS; } catch (SchedulerException e) { logger.error(e.getMessage(), e); } return ReturnT.FAIL; }
Example #19
Source File: XxlJobDynamicSchedulerConfig.java From zuihou-admin-boot with Apache License 2.0 | 5 votes |
/** * 项目启动时,首先创建【SchedulerFactoryBean】, 然后注入 XxlJobDynamicScheduler, * 并执行初始化方法,将【JobRegistryMonitorHelper】、【JobFailMonitorHelper】、【initRpcProvider】初始化 * JobRegistryMonitorHelper: 注册监控工具类,间隔30秒, * JobFailMonitorHelper: 失败监控工具类, 用一个守护线程监控任务执行情况,发生失败时,启动重试机制。 间隔10秒 * * @param schedulerFactory * @return */ @Bean(initMethod = "start", destroyMethod = "destroy") public XxlJobDynamicScheduler getXxlJobDynamicScheduler(SchedulerFactoryBean schedulerFactory) { Scheduler scheduler = schedulerFactory.getScheduler(); XxlJobDynamicScheduler xxlJobDynamicScheduler = new XxlJobDynamicScheduler(); xxlJobDynamicScheduler.setScheduler(scheduler); return xxlJobDynamicScheduler; }
Example #20
Source File: ExecutorRouteBusyover.java From zuihou-admin-cloud with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) { StringBuffer idleBeatResultSB = new StringBuffer(); for (String address : addressList) { // beat ReturnT<String> idleBeatResult = null; try { // ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(address); idleBeatResult = executorBiz.idleBeat(triggerParam.getJobId()); } catch (Exception e) { logger.error(e.getMessage(), e); idleBeatResult = new ReturnT<String>(ReturnT.FAIL_CODE, "" + e); } //空闲检测: //address: //code: //msg: idleBeatResultSB.append((idleBeatResultSB.length() > 0) ? "<br><br>" : "") .append(I18nUtil.getString("jobconf_idleBeat") + ":") .append("<br>address:").append(address) .append("<br>code:").append(idleBeatResult.getCode()) .append("<br>msg:").append(idleBeatResult.getMsg()); // beat success if (idleBeatResult.getCode() == ReturnT.SUCCESS_CODE) { idleBeatResult.setMsg(idleBeatResultSB.toString()); idleBeatResult.setContent(address); return idleBeatResult; } } return new ReturnT<String>(ReturnT.FAIL_CODE, idleBeatResultSB.toString()); }
Example #21
Source File: ExecutorRouteFailover.java From zuihou-admin-cloud with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) { StringBuffer beatResultSB = new StringBuffer(); for (String address : addressList) { // beat ReturnT<String> beatResult = null; try { ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(address); beatResult = executorBiz.beat(); } catch (Exception e) { logger.error(e.getMessage(), e); beatResult = new ReturnT<String>(ReturnT.FAIL_CODE, "" + e); } beatResultSB.append((beatResultSB.length() > 0) ? "<br><br>" : "") .append(I18nUtil.getString("jobconf_beat") + ":") .append("<br>address:").append(address) .append("<br>code:").append(beatResult.getCode()) .append("<br>msg:").append(beatResult.getMsg()); // beat success if (beatResult.getCode() == ReturnT.SUCCESS_CODE) { beatResult.setMsg(beatResultSB.toString()); beatResult.setContent(address); return beatResult; } } return new ReturnT<String>(ReturnT.FAIL_CODE, beatResultSB.toString()); }
Example #22
Source File: XxlJobServiceImpl.java From zuihou-admin-boot with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> start(Integer id) { XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id); if (JobTypeEnum.CRON.eq(xxlJobInfo.getType())) { if (!CronExpression.isValidExpression(xxlJobInfo.getJobCron())) { return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_unvalid")); } } else { //表单校验 String msg = validate(xxlJobInfo.getIntervalSeconds(), xxlJobInfo.getRepeatCount(), xxlJobInfo.getStartExecuteTime(), xxlJobInfo.getEndExecuteTime()); if (!StringUtils.isEmpty(msg)) { return new ReturnT<String>(ReturnT.FAIL_CODE, msg); } } String group = String.valueOf(xxlJobInfo.getJobGroup()); String name = String.valueOf(xxlJobInfo.getId()); String cronExpression = xxlJobInfo.getJobCron(); boolean ret = false; try { //判断定时类型 if (JobTypeEnum.CRON.eq(xxlJobInfo.getType())) { ret = XxlJobDynamicScheduler.addJob(name, group, cronExpression); } else { /*if (!DateUtil.isMatch(xxlJobInfo.get())) { return new ReturnT<>(ReturnT.START_JOB_FAI, "触发时间不能小于当前时间."); }*/ ret = XxlJobDynamicScheduler.addJob(name, group, xxlJobInfo.getStartExecuteTime(), xxlJobInfo.getEndExecuteTime(), xxlJobInfo.getIntervalSeconds(), xxlJobInfo.getRepeatCount()); } return ret ? ReturnT.SUCCESS : ReturnT.FAIL; } catch (SchedulerException e) { logger.error(e.getMessage(), e); return ReturnT.FAIL; } }
Example #23
Source File: XxlJobDynamicSchedulerConfig.java From zuihou-admin-cloud with Apache License 2.0 | 5 votes |
/** * 项目启动时,首先创建【SchedulerFactoryBean】, 然后注入 XxlJobDynamicScheduler, * 并执行初始化方法,将【JobRegistryMonitorHelper】、【JobFailMonitorHelper】、【initRpcProvider】初始化 * JobRegistryMonitorHelper: 注册监控工具类,间隔30秒, * JobFailMonitorHelper: 失败监控工具类, 用一个守护线程监控任务执行情况,发生失败时,启动重试机制。 间隔10秒 * * @param schedulerFactory * @return */ @Bean(initMethod = "start", destroyMethod = "destroy") public XxlJobDynamicScheduler getXxlJobDynamicScheduler(SchedulerFactoryBean schedulerFactory) { Scheduler scheduler = schedulerFactory.getScheduler(); XxlJobDynamicScheduler xxlJobDynamicScheduler = new XxlJobDynamicScheduler(); xxlJobDynamicScheduler.setScheduler(scheduler); return xxlJobDynamicScheduler; }
Example #24
Source File: XxlJobServiceImpl.java From zuihou-admin-boot with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> stop(Integer id) { XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id); String group = String.valueOf(xxlJobInfo.getJobGroup()); String name = String.valueOf(xxlJobInfo.getId()); try { // bind quartz boolean ret = XxlJobDynamicScheduler.removeJob(name, group); return ret ? ReturnT.SUCCESS : ReturnT.FAIL; } catch (SchedulerException e) { logger.error(e.getMessage(), e); return ReturnT.FAIL; } }
Example #25
Source File: XxlJobServiceImpl.java From zuihou-admin-cloud with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> stop(Integer id) { XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id); String group = String.valueOf(xxlJobInfo.getJobGroup()); String name = String.valueOf(xxlJobInfo.getId()); try { // bind quartz boolean ret = XxlJobDynamicScheduler.removeJob(name, group); return ret ? ReturnT.SUCCESS : ReturnT.FAIL; } catch (SchedulerException e) { logger.error(e.getMessage(), e); return ReturnT.FAIL; } }
Example #26
Source File: ExecutorRouteFailover.java From zuihou-admin-boot with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) { StringBuffer beatResultSB = new StringBuffer(); for (String address : addressList) { // beat ReturnT<String> beatResult = null; try { ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(address); beatResult = executorBiz.beat(); } catch (Exception e) { logger.error(e.getMessage(), e); beatResult = new ReturnT<String>(ReturnT.FAIL_CODE, "" + e); } beatResultSB.append((beatResultSB.length() > 0) ? "<br><br>" : "") .append(I18nUtil.getString("jobconf_beat") + ":") .append("<br>address:").append(address) .append("<br>code:").append(beatResult.getCode()) .append("<br>msg:").append(beatResult.getMsg()); // beat success if (beatResult.getCode() == ReturnT.SUCCESS_CODE) { beatResult.setMsg(beatResultSB.toString()); beatResult.setContent(address); return beatResult; } } return new ReturnT<String>(ReturnT.FAIL_CODE, beatResultSB.toString()); }
Example #27
Source File: ExecutorRouteBusyover.java From zuihou-admin-boot with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) { StringBuffer idleBeatResultSB = new StringBuffer(); for (String address : addressList) { // beat ReturnT<String> idleBeatResult = null; try { // ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(address); idleBeatResult = executorBiz.idleBeat(triggerParam.getJobId()); } catch (Exception e) { logger.error(e.getMessage(), e); idleBeatResult = new ReturnT<String>(ReturnT.FAIL_CODE, "" + e); } //空闲检测: //address: //code: //msg: idleBeatResultSB.append((idleBeatResultSB.length() > 0) ? "<br><br>" : "") .append(I18nUtil.getString("jobconf_idleBeat") + ":") .append("<br>address:").append(address) .append("<br>code:").append(idleBeatResult.getCode()) .append("<br>msg:").append(idleBeatResult.getMsg()); // beat success if (idleBeatResult.getCode() == ReturnT.SUCCESS_CODE) { idleBeatResult.setMsg(idleBeatResultSB.toString()); idleBeatResult.setContent(address); return idleBeatResult; } } return new ReturnT<String>(ReturnT.FAIL_CODE, idleBeatResultSB.toString()); }
Example #28
Source File: ExecutorRouteFailover.java From microservices-platform with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) { StringBuffer beatResultSB = new StringBuffer(); for (String address : addressList) { // beat ReturnT<String> beatResult = null; try { ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(address); beatResult = executorBiz.beat(); } catch (Exception e) { logger.error(e.getMessage(), e); beatResult = new ReturnT<String>(ReturnT.FAIL_CODE, ""+e ); } beatResultSB.append( (beatResultSB.length()>0)?"<br><br>":"") .append(I18nUtil.getString("jobconf_beat") + ":") .append("<br>address:").append(address) .append("<br>code:").append(beatResult.getCode()) .append("<br>msg:").append(beatResult.getMsg()); // beat success if (beatResult.getCode() == ReturnT.SUCCESS_CODE) { beatResult.setMsg(beatResultSB.toString()); beatResult.setContent(address); return beatResult; } } return new ReturnT<String>(ReturnT.FAIL_CODE, beatResultSB.toString()); }
Example #29
Source File: JobLogController.java From zuihou-admin-cloud with Apache License 2.0 | 5 votes |
@RequestMapping("/logKill") @ResponseBody public ReturnT<String> logKill(Integer id) { // base check XxlJobLog log = xxlJobLogDao.load(id); XxlJobInfo jobInfo = xxlJobInfoDao.loadById(log.getJobId()); if (jobInfo == null) { return new ReturnT<String>(500, I18nUtil.getString("jobinfo_glue_jobid_unvalid")); } if (ReturnT.SUCCESS_CODE != log.getTriggerCode()) { return new ReturnT<String>(500, I18nUtil.getString("joblog_kill_log_limit")); } // request of kill ReturnT<String> runResult = null; try { ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(log.getExecutorAddress()); runResult = executorBiz.kill(jobInfo.getId()); } catch (Exception e) { logger.error(e.getMessage(), e); runResult = new ReturnT<String>(500, e.getMessage()); } if (ReturnT.SUCCESS_CODE == runResult.getCode()) { log.setHandleCode(ReturnT.FAIL_CODE); log.setHandleMsg(I18nUtil.getString("joblog_kill_log_byman") + ":" + (runResult.getMsg() != null ? runResult.getMsg() : "")); log.setHandleTime(new Date()); xxlJobLogDao.updateHandleInfo(log); return new ReturnT<String>(runResult.getMsg()); } else { return new ReturnT<String>(500, runResult.getMsg()); } }
Example #30
Source File: XxlJobServiceImpl.java From zuihou-admin-cloud with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> start(Integer id) { XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id); if (JobTypeEnum.CRON.eq(xxlJobInfo.getType())) { if (!CronExpression.isValidExpression(xxlJobInfo.getJobCron())) { return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_unvalid")); } } else { //表单校验 String msg = validate(xxlJobInfo.getIntervalSeconds(), xxlJobInfo.getRepeatCount(), xxlJobInfo.getStartExecuteTime(), xxlJobInfo.getEndExecuteTime()); if (!StringUtils.isEmpty(msg)) { return new ReturnT<String>(ReturnT.FAIL_CODE, msg); } } String group = String.valueOf(xxlJobInfo.getJobGroup()); String name = String.valueOf(xxlJobInfo.getId()); String cronExpression = xxlJobInfo.getJobCron(); boolean ret = false; try { //判断定时类型 if (JobTypeEnum.CRON.eq(xxlJobInfo.getType())) { ret = XxlJobDynamicScheduler.addJob(name, group, cronExpression); } else { /*if (!DateUtil.isMatch(xxlJobInfo.get())) { return new ReturnT<>(ReturnT.START_JOB_FAI, "触发时间不能小于当前时间."); }*/ ret = XxlJobDynamicScheduler.addJob(name, group, xxlJobInfo.getStartExecuteTime(), xxlJobInfo.getEndExecuteTime(), xxlJobInfo.getIntervalSeconds(), xxlJobInfo.getRepeatCount()); } return ret ? ReturnT.SUCCESS : ReturnT.FAIL; } catch (SchedulerException e) { logger.error(e.getMessage(), e); return ReturnT.FAIL; } }