Java Code Examples for com.xxl.job.admin.core.model.XxlJobInfo#setTriggerLastTime()

The following examples show how to use com.xxl.job.admin.core.model.XxlJobInfo#setTriggerLastTime() . 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: XxlJobServiceImpl.java    From xxl-job with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ReturnT<String> start(int id) {
	XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);

	// next trigger time (5s后生效,避开预读周期)
	long nextTriggerTime = 0;
	try {
		Date nextValidTime = new CronExpression(xxlJobInfo.getJobCron()).getNextValidTimeAfter(new Date(System.currentTimeMillis() + JobScheduleHelper.PRE_READ_MS));
		if (nextValidTime == null) {
			return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_never_fire"));
		}
		nextTriggerTime = nextValidTime.getTime();
	} catch (ParseException e) {
		logger.error(e.getMessage(), e);
		return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_unvalid")+" | "+ e.getMessage());
	}

	xxlJobInfo.setTriggerStatus(1);
	xxlJobInfo.setTriggerLastTime(0);
	xxlJobInfo.setTriggerNextTime(nextTriggerTime);

	xxlJobInfo.setUpdateTime(new Date());
	xxlJobInfoDao.update(xxlJobInfo);
	return ReturnT.SUCCESS;
}
 
Example 2
Source File: XxlJobServiceImpl.java    From xxl-job with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ReturnT<String> stop(int id) {
       XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);

	xxlJobInfo.setTriggerStatus(0);
	xxlJobInfo.setTriggerLastTime(0);
	xxlJobInfo.setTriggerNextTime(0);

	xxlJobInfo.setUpdateTime(new Date());
	xxlJobInfoDao.update(xxlJobInfo);
	return ReturnT.SUCCESS;
}
 
Example 3
Source File: JobScheduleHelper.java    From xxl-job with GNU General Public License v3.0 5 votes vote down vote up
private void refreshNextValidTime(XxlJobInfo jobInfo, Date fromTime) throws ParseException {
    Date nextValidTime = new CronExpression(jobInfo.getJobCron()).getNextValidTimeAfter(fromTime);
    if (nextValidTime != null) {
        jobInfo.setTriggerLastTime(jobInfo.getTriggerNextTime());
        jobInfo.setTriggerNextTime(nextValidTime.getTime());
    } else {
        jobInfo.setTriggerStatus(0);
        jobInfo.setTriggerLastTime(0);
        jobInfo.setTriggerNextTime(0);
    }
}