com.xxl.job.admin.core.util.I18nUtil Java Examples

The following examples show how to use com.xxl.job.admin.core.util.I18nUtil. 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: JobGroupController.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
@RequestMapping("/remove")
@ResponseBody
public ReturnT<String> remove(Integer id, Integer type) {

    // valid
    int count = xxlJobInfoDao.pageListCount(0, 10, id, null, null, type);
    if (count > 0) {
        return new ReturnT<String>(500, I18nUtil.getString("jobgroup_del_limit_0"));
    }

    List<XxlJobGroup> allList = xxlJobGroupDao.findAll();
    if (allList.size() == 1) {
        return new ReturnT<String>(500, I18nUtil.getString("jobgroup_del_limit_1"));
    }

    int ret = xxlJobGroupDao.remove(id);
    return (ret > 0) ? ReturnT.SUCCESS : ReturnT.FAIL;
}
 
Example #2
Source File: XxlJobTrigger.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #3
Source File: CookieInterceptor.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
		ModelAndView modelAndView) throws Exception {

	// cookie
	if (modelAndView!=null && ArrayUtils.isNotEmpty(request.getCookies())) {
		HashMap<String, Cookie> cookieMap = new HashMap<String, Cookie>();
		for (Cookie ck : request.getCookies()) {
			cookieMap.put(ck.getName(), ck);
		}
		modelAndView.addObject("cookieMap", cookieMap);
	}

	// static method
	if (modelAndView != null) {
		modelAndView.addObject("I18nUtil", FtlUtil.generateStaticModel(I18nUtil.class.getName()));
	}
	
	super.postHandle(request, response, handler, modelAndView);
}
 
Example #4
Source File: IndexController.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value="login", method=RequestMethod.POST)
@ResponseBody
@PermessionLimit(limit=false)
public ReturnT<String> loginDo(HttpServletRequest request, HttpServletResponse response, String userName, String password, String ifRemember){
	// valid
	if (PermissionInterceptor.ifLogin(request)) {
		return ReturnT.SUCCESS;
	}

	// param
	if (StringUtils.isBlank(userName) || StringUtils.isBlank(password)){
		return new ReturnT<String>(500, I18nUtil.getString("login_param_empty"));
	}
	boolean ifRem = (StringUtils.isNotBlank(ifRemember) && "on".equals(ifRemember))?true:false;

	// do login
	boolean loginRet = PermissionInterceptor.login(response, userName, password, ifRem);
	if (!loginRet) {
		return new ReturnT<String>(500, I18nUtil.getString("login_param_unvalid"));
	}
	return ReturnT.SUCCESS;
}
 
Example #5
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 #6
Source File: IndexController.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "login", method = RequestMethod.POST)
@ResponseBody
@PermessionLimit(limit = false)
public ReturnT<String> loginDo(HttpServletRequest request, HttpServletResponse response, String userName, String password, String ifRemember) {
	// valid
	if (PermissionInterceptor.ifLogin(request)) {
		return ReturnT.SUCCESS;
	}

	// param
	if (StrUtil.isBlank(userName) || StrUtil.isBlank(password)) {
		return new ReturnT<String>(500, I18nUtil.getString("login_param_empty"));
	}
	boolean ifRem = (StrUtil.isNotBlank(ifRemember) && "on".equals(ifRemember)) ? true : false;

	// do login
	boolean loginRet = PermissionInterceptor.login(response, userName, password, ifRem);
	if (!loginRet) {
		return new ReturnT<String>(500, I18nUtil.getString("login_param_unvalid"));
	}
	return ReturnT.SUCCESS;
}
 
Example #7
Source File: XxlJobServiceImpl.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
@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 #8
Source File: JobCodeController.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
@RequestMapping
public String index(Model model, int jobId) {
	XxlJobInfo jobInfo = xxlJobInfoDao.loadById(jobId);
	List<XxlJobLogGlue> jobLogGlues = xxlJobLogGlueDao.findByJobId(jobId);

	if (jobInfo == null) {
		throw new RuntimeException(I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
	}
	if (GlueTypeEnum.BEAN == GlueTypeEnum.match(jobInfo.getGlueType())) {
		throw new RuntimeException(I18nUtil.getString("jobinfo_glue_gluetype_unvalid"));
	}

	// Glue类型-字典
	model.addAttribute("GlueTypeEnum", GlueTypeEnum.values());

	model.addAttribute("jobInfo", jobInfo);
	model.addAttribute("jobLogGlues", jobLogGlues);
	return "jobcode/jobcode.index";
}
 
Example #9
Source File: JobGroupController.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
@RequestMapping("/remove")
@ResponseBody
public ReturnT<String> remove(int id){

	// valid
	int count = xxlJobInfoDao.pageListCount(0, 10, id, null, null);
	if (count > 0) {
		return new ReturnT<String>(500, I18nUtil.getString("jobgroup_del_limit_0") );
	}

	List<XxlJobGroup> allList = xxlJobGroupDao.findAll();
	if (allList.size() == 1) {
		return new ReturnT<String>(500, I18nUtil.getString("jobgroup_del_limit_1") );
	}

	int ret = xxlJobGroupDao.remove(id);
	return (ret>0)?ReturnT.SUCCESS:ReturnT.FAIL;
}
 
Example #10
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 #11
Source File: XxlJobTrigger.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #12
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 #13
Source File: CookieInterceptor.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
                       ModelAndView modelAndView) throws Exception {

    // cookie
    if (modelAndView != null && ArrayUtils.isNotEmpty(request.getCookies())) {
        HashMap<String, Cookie> cookieMap = new HashMap<String, Cookie>();
        for (Cookie ck : request.getCookies()) {
            cookieMap.put(ck.getName(), ck);
        }
        modelAndView.addObject("cookieMap", cookieMap);
    }

    // static method
    if (modelAndView != null) {
        modelAndView.addObject("I18nUtil", FtlUtil.generateStaticModel(I18nUtil.class.getName()));
    }

    super.postHandle(request, response, handler, modelAndView);
}
 
Example #14
Source File: JobCodeController.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
@RequestMapping
public String index(Model model, int jobId) {
	XxlJobInfo jobInfo = xxlJobInfoDao.loadById(jobId);
	List<XxlJobLogGlue> jobLogGlues = xxlJobLogGlueDao.findByJobId(jobId);

	if (jobInfo == null) {
		throw new RuntimeException(I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
	}
	if (GlueTypeEnum.BEAN == GlueTypeEnum.match(jobInfo.getGlueType())) {
		throw new RuntimeException(I18nUtil.getString("jobinfo_glue_gluetype_unvalid"));
	}

	// Glue类型-字典
	model.addAttribute("GlueTypeEnum", GlueTypeEnum.values());

	model.addAttribute("jobInfo", jobInfo);
	model.addAttribute("jobLogGlues", jobLogGlues);
	return "jobcode/jobcode.index";
}
 
Example #15
Source File: JobGroupController.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
@RequestMapping("/remove")
@ResponseBody
public ReturnT<String> remove(int id){

	// valid
	int count = xxlJobInfoDao.pageListCount(0, 10, id, null, null);
	if (count > 0) {
		return new ReturnT<String>(500, I18nUtil.getString("jobgroup_del_limit_0") );
	}

	List<XxlJobGroup> allList = xxlJobGroupDao.findAll();
	if (allList.size() == 1) {
		return new ReturnT<String>(500, I18nUtil.getString("jobgroup_del_limit_1") );
	}

	int ret = xxlJobGroupDao.remove(id);
	return (ret>0)?ReturnT.SUCCESS:ReturnT.FAIL;
}
 
Example #16
Source File: JobCodeController.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
@RequestMapping
public String index(Model model, Integer jobId) {
    XxlJobInfo jobInfo = xxlJobInfoDao.loadById(jobId);
    List<XxlJobLogGlue> jobLogGlues = xxlJobLogGlueDao.findByJobId(jobId);

    if (jobInfo == null) {
        throw new RuntimeException(I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
    }
    if (GlueTypeEnum.BEAN == GlueTypeEnum.match(jobInfo.getGlueType())) {
        throw new RuntimeException(I18nUtil.getString("jobinfo_glue_gluetype_unvalid"));
    }

    // Glue类型-字典
    model.addAttribute("GlueTypeEnum", GlueTypeEnum.values());

    model.addAttribute("jobInfo", jobInfo);
    model.addAttribute("jobLogGlues", jobLogGlues);
    return "jobcode/jobcode.index";
}
 
Example #17
Source File: CookieInterceptor.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
                       ModelAndView modelAndView) throws Exception {

    // cookie
    if (modelAndView != null && ArrayUtils.isNotEmpty(request.getCookies())) {
        HashMap<String, Cookie> cookieMap = new HashMap<String, Cookie>();
        for (Cookie ck : request.getCookies()) {
            cookieMap.put(ck.getName(), ck);
        }
        modelAndView.addObject("cookieMap", cookieMap);
    }

    // static method
    if (modelAndView != null) {
        modelAndView.addObject("I18nUtil", FtlUtil.generateStaticModel(I18nUtil.class.getName()));
    }

    super.postHandle(request, response, handler, modelAndView);
}
 
Example #18
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 #19
Source File: IndexController.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "login", method = RequestMethod.POST)
@ResponseBody
@PermessionLimit(limit = false)
public ReturnT<String> loginDo(HttpServletRequest request, HttpServletResponse response, String userName, String password, String ifRemember) {
    // valid
    if (PermissionInterceptor.ifLogin(request)) {
        return ReturnT.SUCCESS;
    }

    // param
    if (StrUtil.isBlank(userName) || StrUtil.isBlank(password)) {
        return new ReturnT<String>(500, I18nUtil.getString("login_param_empty"));
    }
    boolean ifRem = (StrUtil.isNotBlank(ifRemember) && "on".equals(ifRemember)) ? true : false;

    // do login
    boolean loginRet = PermissionInterceptor.login(response, userName, password, ifRem);
    if (!loginRet) {
        return new ReturnT<String>(500, I18nUtil.getString("login_param_unvalid"));
    }
    return ReturnT.SUCCESS;
}
 
Example #20
Source File: XxlJobTrigger.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #21
Source File: XxlJobTrigger.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #22
Source File: IndexController.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value="login", method=RequestMethod.POST)
@ResponseBody
@PermessionLimit(limit=false)
public ReturnT<String> loginDo(HttpServletRequest request, HttpServletResponse response, String userName, String password, String ifRemember){
	// valid
	if (PermissionInterceptor.ifLogin(request)) {
		return ReturnT.SUCCESS;
	}

	// param
	if (StringUtils.isBlank(userName) || StringUtils.isBlank(password)){
		return new ReturnT<String>(500, I18nUtil.getString("login_param_empty"));
	}
	boolean ifRem = (StringUtils.isNotBlank(ifRemember) && "on".equals(ifRemember))?true:false;

	// do login
	boolean loginRet = PermissionInterceptor.login(response, userName, password, ifRem);
	if (!loginRet) {
		return new ReturnT<String>(500, I18nUtil.getString("login_param_unvalid"));
	}
	return ReturnT.SUCCESS;
}
 
Example #23
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 #24
Source File: CookieInterceptor.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
		ModelAndView modelAndView) throws Exception {

	// cookie
	if (modelAndView!=null && ArrayUtils.isNotEmpty(request.getCookies())) {
		HashMap<String, Cookie> cookieMap = new HashMap<String, Cookie>();
		for (Cookie ck : request.getCookies()) {
			cookieMap.put(ck.getName(), ck);
		}
		modelAndView.addObject("cookieMap", cookieMap);
	}

	// static method
	if (modelAndView != null) {
		modelAndView.addObject("I18nUtil", FtlUtil.generateStaticModel(I18nUtil.class.getName()));
	}
	
	super.postHandle(request, response, handler, modelAndView);
}
 
Example #25
Source File: JobGroupController.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
@RequestMapping("/remove")
@ResponseBody
public ReturnT<String> remove(Integer id, Integer type) {

    // valid
    int count = xxlJobInfoDao.pageListCount(0, 10, id, null, null, type);
    if (count > 0) {
        return new ReturnT<String>(500, I18nUtil.getString("jobgroup_del_limit_0"));
    }

    List<XxlJobGroup> allList = xxlJobGroupDao.findAll();
    if (allList.size() == 1) {
        return new ReturnT<String>(500, I18nUtil.getString("jobgroup_del_limit_1"));
    }

    int ret = xxlJobGroupDao.remove(id);
    return (ret > 0) ? ReturnT.SUCCESS : ReturnT.FAIL;
}
 
Example #26
Source File: JobCodeController.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
@RequestMapping
public String index(Model model, Integer jobId) {
    XxlJobInfo jobInfo = xxlJobInfoDao.loadById(jobId);
    List<XxlJobLogGlue> jobLogGlues = xxlJobLogGlueDao.findByJobId(jobId);

    if (jobInfo == null) {
        throw new RuntimeException(I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
    }
    if (GlueTypeEnum.BEAN == GlueTypeEnum.match(jobInfo.getGlueType())) {
        throw new RuntimeException(I18nUtil.getString("jobinfo_glue_gluetype_unvalid"));
    }

    // Glue类型-字典
    model.addAttribute("GlueTypeEnum", GlueTypeEnum.values());

    model.addAttribute("jobInfo", jobInfo);
    model.addAttribute("jobLogGlues", jobLogGlues);
    return "jobcode/jobcode.index";
}
 
Example #27
Source File: ExecutorRouteBusyover.java    From zuihou-admin-cloud with Apache License 2.0 5 votes vote down vote up
@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: XxlJobServiceImpl.java    From zuihou-admin-boot with Apache License 2.0 5 votes vote down vote up
@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 #29
Source File: ExecutorRouteFailover.java    From zuihou-admin-cloud with Apache License 2.0 5 votes vote down vote up
@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 #30
Source File: JobCodeController.java    From zuihou-admin-boot with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/save")
@ResponseBody
public ReturnT<String> save(Model model, Integer id, String glueSource, String glueRemark) {
    // valid
    if (glueRemark == null) {
        return new ReturnT<String>(500, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobinfo_glue_remark")));
    }
    if (glueRemark.length() < 4 || glueRemark.length() > 100) {
        return new ReturnT<String>(500, I18nUtil.getString("jobinfo_glue_remark_limit"));
    }
    XxlJobInfo existsJobinfo = xxlJobInfoDao.loadById(id);
    if (existsJobinfo == null) {
        return new ReturnT<String>(500, I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
    }

    // update new code
    existsJobinfo.setGlueSource(glueSource);
    existsJobinfo.setGlueRemark(glueRemark);
    existsJobinfo.setGlueUpdatetime(new Date());
    xxlJobInfoDao.update(existsJobinfo);

    // log old code
    XxlJobLogGlue xxlJobLogGlue = new XxlJobLogGlue();
    xxlJobLogGlue.setJobId(existsJobinfo.getId());
    xxlJobLogGlue.setGlueType(existsJobinfo.getGlueType());
    xxlJobLogGlue.setGlueSource(glueSource);
    xxlJobLogGlue.setGlueRemark(glueRemark);
    xxlJobLogGlueDao.save(xxlJobLogGlue);

    // remove code backup more than 30
    xxlJobLogGlueDao.removeOld(existsJobinfo.getId(), 30);

    return ReturnT.SUCCESS;
}