Java Code Examples for com.xxl.job.admin.core.model.XxlJobLog#getTriggerCode()
The following examples show how to use
com.xxl.job.admin.core.model.XxlJobLog#getTriggerCode() .
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 open-capacity-platform with Apache License 2.0 | 5 votes |
@RequestMapping("/logKill") @ResponseBody public ReturnT<String> logKill(int 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 2
Source File: JobLogController.java From microservices-platform with Apache License 2.0 | 5 votes |
@RequestMapping("/logKill") @ResponseBody public ReturnT<String> logKill(int 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 3
Source File: JobLogController.java From zuihou-admin-boot 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 4
Source File: JobFailMonitorHelper.java From zuihou-admin-boot with Apache License 2.0 | 5 votes |
/** * fail alarm * * @param jobLog */ private void failAlarm(XxlJobInfo info, XxlJobLog jobLog) { // send monitor email if (info != null && info.getAlarmEmail() != null && info.getAlarmEmail().trim().length() > 0) { String alarmContent = "Alarm Job LogId=" + jobLog.getId(); if (jobLog.getTriggerCode() != ReturnT.SUCCESS_CODE) { alarmContent += "<br>TriggerMsg=" + jobLog.getTriggerMsg(); } if (jobLog.getHandleCode() > 0 && jobLog.getHandleCode() != ReturnT.SUCCESS_CODE) { alarmContent += "<br>HandleCode=" + jobLog.getHandleMsg(); } Set<String> emailSet = new HashSet<String>(Arrays.asList(info.getAlarmEmail().split(","))); for (String email : emailSet) { XxlJobGroup group = XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().load(Integer.valueOf(info.getJobGroup())); String title = I18nUtil.getString("jobconf_monitor"); String content = MessageFormat.format(MAIL_BODY_TEMPLATE, group != null ? group.getTitle() : "null", info.getId(), info.getJobDesc(), alarmContent); MailUtil.sendMail(email, title, content); } } // 自定义报警策略, 如短信 }
Example 5
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 6
Source File: JobFailMonitorHelper.java From zuihou-admin-cloud with Apache License 2.0 | 5 votes |
/** * fail alarm * * @param jobLog */ private void failAlarm(XxlJobInfo info, XxlJobLog jobLog) { // send monitor email if (info != null && info.getAlarmEmail() != null && info.getAlarmEmail().trim().length() > 0) { String alarmContent = "Alarm Job LogId=" + jobLog.getId(); if (jobLog.getTriggerCode() != ReturnT.SUCCESS_CODE) { alarmContent += "<br>TriggerMsg=" + jobLog.getTriggerMsg(); } if (jobLog.getHandleCode() > 0 && jobLog.getHandleCode() != ReturnT.SUCCESS_CODE) { alarmContent += "<br>HandleCode=" + jobLog.getHandleMsg(); } Set<String> emailSet = new HashSet<String>(Arrays.asList(info.getAlarmEmail().split(","))); for (String email : emailSet) { XxlJobGroup group = XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().load(Integer.valueOf(info.getJobGroup())); String title = I18nUtil.getString("jobconf_monitor"); String content = MessageFormat.format(MAIL_BODY_TEMPLATE, group != null ? group.getTitle() : "null", info.getId(), info.getJobDesc(), alarmContent); MailUtil.sendMail(email, title, content); } } // 自定义报警策略, 如短信 }
Example 7
Source File: JobLogController.java From xxl-job with GNU General Public License v3.0 | 5 votes |
@RequestMapping("/logKill") @ResponseBody public ReturnT<String> logKill(int 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 = XxlJobScheduler.getExecutorBiz(log.getExecutorAddress()); runResult = executorBiz.kill(new KillParam(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 8
Source File: JobFailMonitorHelper.java From microservices-platform with Apache License 2.0 | 4 votes |
/** * fail alarm * * @param jobLog */ private boolean failAlarm(XxlJobInfo info, XxlJobLog jobLog){ boolean alarmResult = true; // send monitor email if (info!=null && info.getAlarmEmail()!=null && info.getAlarmEmail().trim().length()>0) { String alarmContent = "Alarm Job LogId=" + jobLog.getId(); if (jobLog.getTriggerCode() != ReturnT.SUCCESS_CODE) { alarmContent += "<br>TriggerMsg=<br>" + jobLog.getTriggerMsg(); } if (jobLog.getHandleCode()>0 && jobLog.getHandleCode() != ReturnT.SUCCESS_CODE) { alarmContent += "<br>HandleCode=" + jobLog.getHandleMsg(); } Set<String> emailSet = new HashSet<String>(Arrays.asList(info.getAlarmEmail().split(","))); for (String email: emailSet) { XxlJobGroup group = XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().load(Integer.valueOf(info.getJobGroup())); String personal = I18nUtil.getString("admin_name_full"); String title = I18nUtil.getString("jobconf_monitor"); String content = MessageFormat.format(mailBodyTemplate, group!=null?group.getTitle():"null", info.getId(), info.getJobDesc(), alarmContent); // make mail try { MimeMessage mimeMessage = XxlJobAdminConfig.getAdminConfig().getMailSender().createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true); helper.setFrom(XxlJobAdminConfig.getAdminConfig().getEmailUserName(), personal); helper.setTo(email); helper.setSubject(title); helper.setText(content, true); XxlJobAdminConfig.getAdminConfig().getMailSender().send(mimeMessage); } catch (Exception e) { logger.error(">>>>>>>>>>> xxl-job, job fail alarm email send error, JobLogId:{}", jobLog.getId(), e); alarmResult = false; } } } // TODO, custom alarm strategy, such as sms return alarmResult; }
Example 9
Source File: EmailJobAlarm.java From xxl-job with GNU General Public License v3.0 | 4 votes |
/** * fail alarm * * @param jobLog */ public boolean doAlarm(XxlJobInfo info, XxlJobLog jobLog){ boolean alarmResult = true; // send monitor email if (info!=null && info.getAlarmEmail()!=null && info.getAlarmEmail().trim().length()>0) { // alarmContent String alarmContent = "Alarm Job LogId=" + jobLog.getId(); if (jobLog.getTriggerCode() != ReturnT.SUCCESS_CODE) { alarmContent += "<br>TriggerMsg=<br>" + jobLog.getTriggerMsg(); } if (jobLog.getHandleCode()>0 && jobLog.getHandleCode() != ReturnT.SUCCESS_CODE) { alarmContent += "<br>HandleCode=" + jobLog.getHandleMsg(); } // email info XxlJobGroup group = XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().load(Integer.valueOf(info.getJobGroup())); String personal = I18nUtil.getString("admin_name_full"); String title = I18nUtil.getString("jobconf_monitor"); String content = MessageFormat.format(loadEmailJobAlarmTemplate(), group!=null?group.getTitle():"null", info.getId(), info.getJobDesc(), alarmContent); Set<String> emailSet = new HashSet<String>(Arrays.asList(info.getAlarmEmail().split(","))); for (String email: emailSet) { // make mail try { MimeMessage mimeMessage = XxlJobAdminConfig.getAdminConfig().getMailSender().createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true); helper.setFrom(XxlJobAdminConfig.getAdminConfig().getEmailFrom(), personal); helper.setTo(email); helper.setSubject(title); helper.setText(content, true); XxlJobAdminConfig.getAdminConfig().getMailSender().send(mimeMessage); } catch (Exception e) { logger.error(">>>>>>>>>>> xxl-job, job fail alarm email send error, JobLogId:{}", jobLog.getId(), e); alarmResult = false; } } } return alarmResult; }