com.xxl.job.admin.core.model.XxlJobLog Java Examples

The following examples show how to use com.xxl.job.admin.core.model.XxlJobLog. 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 6 votes vote down vote up
@RequestMapping("/logDetailPage")
public String logDetailPage(int id, Model model){

	// base check
	ReturnT<String> logStatue = ReturnT.SUCCESS;
	XxlJobLog jobLog = xxlJobLogDao.load(id);
	if (jobLog == null) {
           throw new RuntimeException(I18nUtil.getString("joblog_logid_unvalid"));
	}

       model.addAttribute("triggerCode", jobLog.getTriggerCode());
       model.addAttribute("handleCode", jobLog.getHandleCode());
       model.addAttribute("executorAddress", jobLog.getExecutorAddress());
       model.addAttribute("triggerTime", jobLog.getTriggerTime().getTime());
       model.addAttribute("logId", jobLog.getId());
	return "joblog/joblog.detail";
}
 
Example #2
Source File: JobLogController.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
@RequestMapping("/logDetailPage")
public String logDetailPage(Integer id, Model model) {

    // base check
    ReturnT<String> logStatue = ReturnT.SUCCESS;
    XxlJobLog jobLog = xxlJobLogDao.load(id);
    if (jobLog == null) {
        throw new RuntimeException(I18nUtil.getString("joblog_logid_unvalid"));
    }

    model.addAttribute("triggerCode", jobLog.getTriggerCode());
    model.addAttribute("handleCode", jobLog.getHandleCode());
    model.addAttribute("executorAddress", jobLog.getExecutorAddress());
    model.addAttribute("triggerTime", jobLog.getTriggerTime().getTime());
    model.addAttribute("logId", jobLog.getId());
    return "joblog/joblog.detail";
}
 
Example #3
Source File: JobLogController.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
@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: JobLogController.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
@RequestMapping("/logDetailPage")
public String logDetailPage(Integer id, Model model) {

    // base check
    ReturnT<String> logStatue = ReturnT.SUCCESS;
    XxlJobLog jobLog = xxlJobLogDao.load(id);
    if (jobLog == null) {
        throw new RuntimeException(I18nUtil.getString("joblog_logid_unvalid"));
    }

    model.addAttribute("triggerCode", jobLog.getTriggerCode());
    model.addAttribute("handleCode", jobLog.getHandleCode());
    model.addAttribute("executorAddress", jobLog.getExecutorAddress());
    model.addAttribute("triggerTime", jobLog.getTriggerTime().getTime());
    model.addAttribute("logId", jobLog.getId());
    return "joblog/joblog.detail";
}
 
Example #5
Source File: JobLogController.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
@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 #6
Source File: JobLogController.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
@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 #7
Source File: JobLogController.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
@RequestMapping("/logDetailPage")
public String logDetailPage(int id, Model model){

	// base check
	ReturnT<String> logStatue = ReturnT.SUCCESS;
	XxlJobLog jobLog = xxlJobLogDao.load(id);
	if (jobLog == null) {
           throw new RuntimeException(I18nUtil.getString("joblog_logid_unvalid"));
	}

       model.addAttribute("triggerCode", jobLog.getTriggerCode());
       model.addAttribute("handleCode", jobLog.getHandleCode());
       model.addAttribute("executorAddress", jobLog.getExecutorAddress());
       model.addAttribute("triggerTime", jobLog.getTriggerTime().getTime());
       model.addAttribute("logId", jobLog.getId());
	return "joblog/joblog.detail";
}
 
Example #8
Source File: JobFailMonitorHelper.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #9
Source File: JobLogController.java    From xxl-job with GNU General Public License v3.0 6 votes vote down vote up
@RequestMapping("/logDetailPage")
public String logDetailPage(int id, Model model){

	// base check
	ReturnT<String> logStatue = ReturnT.SUCCESS;
	XxlJobLog jobLog = xxlJobLogDao.load(id);
	if (jobLog == null) {
           throw new RuntimeException(I18nUtil.getString("joblog_logid_unvalid"));
	}

       model.addAttribute("triggerCode", jobLog.getTriggerCode());
       model.addAttribute("handleCode", jobLog.getHandleCode());
       model.addAttribute("executorAddress", jobLog.getExecutorAddress());
       model.addAttribute("triggerTime", jobLog.getTriggerTime().getTime());
       model.addAttribute("logId", jobLog.getId());
	return "joblog/joblog.detail";
}
 
Example #10
Source File: JobLogController.java    From xxl-job with GNU General Public License v3.0 6 votes vote down vote up
@RequestMapping("/logDetailCat")
@ResponseBody
public ReturnT<LogResult> logDetailCat(String executorAddress, long triggerTime, long logId, int fromLineNum){
	try {
		ExecutorBiz executorBiz = XxlJobScheduler.getExecutorBiz(executorAddress);
		ReturnT<LogResult> logResult = executorBiz.log(new LogParam(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: JobLogController.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
@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 #12
Source File: XxlJobLogDao.java    From zuihou-admin-boot with Apache License 2.0 5 votes vote down vote up
public List<XxlJobLog> pageList(@Param("offset") Integer offset,
@Param("pagesize") Integer pagesize,
@Param("jobGroup") Integer jobGroup,
@Param("jobId") Integer jobId,
@Param("triggerTimeStart") Date triggerTimeStart,
@Param("triggerTimeEnd") Date triggerTimeEnd,
@Param("logStatus") Integer logStatus);
 
Example #13
Source File: JobLogController.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@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 #14
Source File: JobLogController.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/pageList")
@ResponseBody
public Map<String, Object> pageList(@RequestParam(required = false, defaultValue = "0") int start,  
		@RequestParam(required = false, defaultValue = "10") int length,
		int jobGroup, int jobId, int logStatus, String filterTime) {
	
	// parse param
	Date triggerTimeStart = null;
	Date triggerTimeEnd = null;
	if (StringUtils.isNotBlank(filterTime)) {
		String[] temp = filterTime.split(" - ");
		if (temp!=null && temp.length == 2) {
			try {
				triggerTimeStart = DateUtils.parseDate(temp[0], new String[]{"yyyy-MM-dd HH:mm:ss"});
				triggerTimeEnd = DateUtils.parseDate(temp[1], new String[]{"yyyy-MM-dd HH:mm:ss"});
			} catch (ParseException e) {	}
		}
	}
	
	// page query
	List<XxlJobLog> list = xxlJobLogDao.pageList(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);
	int list_count = xxlJobLogDao.pageListCount(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);
	
	// 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 #15
Source File: JobLogController.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
@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 #16
Source File: XxlJobLogDao.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
public List<XxlJobLog> pageList(@Param("offset") int offset,
@Param("pagesize") int pagesize,
@Param("jobGroup") int jobGroup,
@Param("jobId") int jobId,
@Param("triggerTimeStart") Date triggerTimeStart,
@Param("triggerTimeEnd") Date triggerTimeEnd,
@Param("logStatus") int logStatus);
 
Example #17
Source File: XxlJobLogDao.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
public List<XxlJobLog> pageList(@Param("offset") int offset,
@Param("pagesize") int pagesize,
@Param("jobGroup") int jobGroup,
@Param("jobId") int jobId,
@Param("triggerTimeStart") Date triggerTimeStart,
@Param("triggerTimeEnd") Date triggerTimeEnd,
@Param("logStatus") int logStatus);
 
Example #18
Source File: XxlJobLogDaoTest.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void test(){
    List<XxlJobLog> list = xxlJobLogDao.pageList(0, 10, 1, 1, null, null, 1);
    int list_count = xxlJobLogDao.pageListCount(0, 10, 1, 1, null, null, 1);

    XxlJobLog log = new XxlJobLog();
    log.setJobGroup(1);
    log.setJobId(1);

    int ret1 = xxlJobLogDao.save(log);
    XxlJobLog dto = xxlJobLogDao.load(log.getId());

    log.setTriggerTime(new Date());
    log.setTriggerCode(1);
    log.setTriggerMsg("1");
    log.setExecutorAddress("1");
    log.setExecutorHandler("1");
    log.setExecutorParam("1");
    ret1 = xxlJobLogDao.updateTriggerInfo(log);
    dto = xxlJobLogDao.load(log.getId());


    log.setHandleTime(new Date());
    log.setHandleCode(2);
    log.setHandleMsg("2");
    ret1 = xxlJobLogDao.updateHandleInfo(log);
    dto = xxlJobLogDao.load(log.getId());


    List<Map<String, Object>> list2 = xxlJobLogDao.triggerCountByDay(DateUtils.addDays(new Date(), 30), new Date());

    int ret4 = xxlJobLogDao.clearLog(1, 1, new Date(), 100);

    int ret2 = xxlJobLogDao.delete(log.getJobId());

    int ret3 = xxlJobLogDao.triggerCountByHandleCode(-1);
}
 
Example #19
Source File: JobLogController.java    From zuihou-admin-boot with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/pageList")
@ResponseBody
public Map<String, Object> pageList(@RequestParam(required = false, defaultValue = "0") Integer start,
                                    @RequestParam(required = false, defaultValue = "10") Integer length,
                                    Integer jobGroup, Integer jobId, Integer logStatus, String filterTime) {

    // parse param
    Date triggerTimeStart = null;
    Date triggerTimeEnd = null;
    if (StringUtils.isNotBlank(filterTime)) {
        String[] temp = filterTime.split(" - ");
        if (temp != null && temp.length == 2) {
            try {
                triggerTimeStart = DateUtils.parseDate(temp[0], new String[]{"yyyy-MM-dd HH:mm:ss"});
                triggerTimeEnd = DateUtils.parseDate(temp[1], new String[]{"yyyy-MM-dd HH:mm:ss"});
            } catch (ParseException e) {
            }
        }
    }

    // page query
    List<XxlJobLog> list = xxlJobLogDao.pageList(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);
    int listCount = xxlJobLogDao.pageListCount(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);

    // 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 #20
Source File: XxlJobLogDaoTest.java    From xxl-job with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void test(){
    List<XxlJobLog> list = xxlJobLogDao.pageList(0, 10, 1, 1, null, null, 1);
    int list_count = xxlJobLogDao.pageListCount(0, 10, 1, 1, null, null, 1);

    XxlJobLog log = new XxlJobLog();
    log.setJobGroup(1);
    log.setJobId(1);

    long ret1 = xxlJobLogDao.save(log);
    XxlJobLog dto = xxlJobLogDao.load(log.getId());

    log.setTriggerTime(new Date());
    log.setTriggerCode(1);
    log.setTriggerMsg("1");
    log.setExecutorAddress("1");
    log.setExecutorHandler("1");
    log.setExecutorParam("1");
    ret1 = xxlJobLogDao.updateTriggerInfo(log);
    dto = xxlJobLogDao.load(log.getId());


    log.setHandleTime(new Date());
    log.setHandleCode(2);
    log.setHandleMsg("2");
    ret1 = xxlJobLogDao.updateHandleInfo(log);
    dto = xxlJobLogDao.load(log.getId());


    List<Long> ret4 = xxlJobLogDao.findClearLogIds(1, 1, new Date(), 100, 100);

    int ret2 = xxlJobLogDao.delete(log.getJobId());

}
 
Example #21
Source File: JobLogController.java    From zuihou-admin-boot with Apache License 2.0 5 votes vote down vote up
@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 #22
Source File: JobLogController.java    From xxl-job with GNU General Public License v3.0 5 votes vote down vote up
@RequestMapping("/pageList")
@ResponseBody
public Map<String, Object> pageList(HttpServletRequest request,
									@RequestParam(required = false, defaultValue = "0") int start,
									@RequestParam(required = false, defaultValue = "10") int length,
									int jobGroup, int jobId, int logStatus, String filterTime) {

	// valid permission
	JobInfoController.validPermission(request, jobGroup);	// 仅管理员支持查询全部;普通用户仅支持查询有权限的 jobGroup
	
	// parse param
	Date triggerTimeStart = null;
	Date triggerTimeEnd = null;
	if (filterTime!=null && filterTime.trim().length()>0) {
		String[] temp = filterTime.split(" - ");
		if (temp.length == 2) {
			triggerTimeStart = DateUtil.parseDateTime(temp[0]);
			triggerTimeEnd = DateUtil.parseDateTime(temp[1]);
		}
	}
	
	// page query
	List<XxlJobLog> list = xxlJobLogDao.pageList(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);
	int list_count = xxlJobLogDao.pageListCount(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);
	
	// 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 #23
Source File: JobFailMonitorHelper.java    From zuihou-admin-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #24
Source File: JobLogController.java    From zuihou-admin-cloud with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/pageList")
@ResponseBody
public Map<String, Object> pageList(@RequestParam(required = false, defaultValue = "0") Integer start,
                                    @RequestParam(required = false, defaultValue = "10") Integer length,
                                    Integer jobGroup, Integer jobId, Integer logStatus, String filterTime) {

    // parse param
    Date triggerTimeStart = null;
    Date triggerTimeEnd = null;
    if (StringUtils.isNotBlank(filterTime)) {
        String[] temp = filterTime.split(" - ");
        if (temp != null && temp.length == 2) {
            try {
                triggerTimeStart = DateUtils.parseDate(temp[0], new String[]{"yyyy-MM-dd HH:mm:ss"});
                triggerTimeEnd = DateUtils.parseDate(temp[1], new String[]{"yyyy-MM-dd HH:mm:ss"});
            } catch (ParseException e) {
            }
        }
    }

    // page query
    List<XxlJobLog> list = xxlJobLogDao.pageList(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);
    int listCount = xxlJobLogDao.pageListCount(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);

    // 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 #25
Source File: JobLogController.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/pageList")
@ResponseBody
public Map<String, Object> pageList(@RequestParam(required = false, defaultValue = "0") int start,  
		@RequestParam(required = false, defaultValue = "10") int length,
		int jobGroup, int jobId, int logStatus, String filterTime) {
	
	// parse param
	Date triggerTimeStart = null;
	Date triggerTimeEnd = null;
	if (StringUtils.isNotBlank(filterTime)) {
		String[] temp = filterTime.split(" - ");
		if (temp!=null && temp.length == 2) {
			try {
				triggerTimeStart = DateUtils.parseDate(temp[0], new String[]{"yyyy-MM-dd HH:mm:ss"});
				triggerTimeEnd = DateUtils.parseDate(temp[1], new String[]{"yyyy-MM-dd HH:mm:ss"});
			} catch (ParseException e) {	}
		}
	}
	
	// page query
	List<XxlJobLog> list = xxlJobLogDao.pageList(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);
	int list_count = xxlJobLogDao.pageListCount(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);
	
	// 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 #26
Source File: XxlJobLogDao.java    From xxl-job with GNU General Public License v3.0 5 votes vote down vote up
public List<XxlJobLog> pageList(@Param("offset") int offset,
@Param("pagesize") int pagesize,
@Param("jobGroup") int jobGroup,
@Param("jobId") int jobId,
@Param("triggerTimeStart") Date triggerTimeStart,
@Param("triggerTimeEnd") Date triggerTimeEnd,
@Param("logStatus") int logStatus);
 
Example #27
Source File: JobLogController.java    From xxl-job with GNU General Public License v3.0 5 votes vote down vote up
@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 #28
Source File: JobLogController.java    From zuihou-admin-cloud with Apache License 2.0 5 votes vote down vote up
@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 #29
Source File: XxlJobLogDao.java    From zuihou-admin-cloud with Apache License 2.0 5 votes vote down vote up
public List<XxlJobLog> pageList(@Param("offset") Integer offset,
@Param("pagesize") Integer pagesize,
@Param("jobGroup") Integer jobGroup,
@Param("jobId") Integer jobId,
@Param("triggerTimeStart") Date triggerTimeStart,
@Param("triggerTimeEnd") Date triggerTimeEnd,
@Param("logStatus") Integer logStatus);
 
Example #30
Source File: JobFailMonitorHelper.java    From zuihou-admin-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
        }
    }

    //  自定义报警策略, 如短信

}