use of com.xxl.job.admin.core.model.XxlJobInfo in project xxl-job by xuxueli.
the class XxlJobInfoDaoTest method save_load.
@Test
public void save_load() {
XxlJobInfo info = new XxlJobInfo();
info.setJobGroup(1);
info.setJobCron("jobCron");
info.setJobDesc("desc");
info.setAuthor("setAuthor");
info.setAlarmEmail("setAlarmEmail");
info.setExecutorRouteStrategy("setExecutorRouteStrategy");
info.setExecutorHandler("setExecutorHandler");
info.setExecutorParam("setExecutorParam");
info.setExecutorBlockStrategy("setExecutorBlockStrategy");
info.setExecutorFailStrategy("setExecutorFailStrategy");
info.setGlueType("setGlueType");
info.setGlueSource("setGlueSource");
info.setGlueRemark("setGlueRemark");
info.setChildJobId("1");
int count = xxlJobInfoDao.save(info);
XxlJobInfo info2 = xxlJobInfoDao.loadById(info.getId());
info2.setJobCron("jobCron2");
info2.setJobDesc("desc2");
info2.setAuthor("setAuthor2");
info2.setAlarmEmail("setAlarmEmail2");
info2.setExecutorRouteStrategy("setExecutorRouteStrategy2");
info2.setExecutorHandler("setExecutorHandler2");
info2.setExecutorParam("setExecutorParam2");
info2.setExecutorBlockStrategy("setExecutorBlockStrategy2");
info2.setExecutorFailStrategy("setExecutorFailStrategy2");
info2.setGlueType("setGlueType2");
info2.setGlueSource("setGlueSource2");
info2.setGlueRemark("setGlueRemark2");
info2.setGlueUpdatetime(new Date());
info2.setChildJobId("1");
int item2 = xxlJobInfoDao.update(info2);
xxlJobInfoDao.delete(info2.getId());
List<XxlJobInfo> list2 = xxlJobInfoDao.getJobsByGroup(1);
int ret3 = xxlJobInfoDao.findAllCount();
}
use of com.xxl.job.admin.core.model.XxlJobInfo in project xxl-job by xuxueli.
the class AdminBizImpl method callback.
private ReturnT<String> callback(HandleCallbackParam handleCallbackParam) {
// valid log item
XxlJobLog log = xxlJobLogDao.load(handleCallbackParam.getLogId());
if (log == null) {
return new ReturnT<String>(ReturnT.FAIL_CODE, "log item not found.");
}
if (log.getHandleCode() > 0) {
// avoid repeat callback, trigger child job etc
return new ReturnT<String>(ReturnT.FAIL_CODE, "log repeate callback.");
}
// trigger success, to trigger child job
String callbackMsg = null;
if (IJobHandler.SUCCESS.getCode() == handleCallbackParam.getExecuteResult().getCode()) {
XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(log.getJobId());
if (xxlJobInfo != null && StringUtils.isNotBlank(xxlJobInfo.getChildJobId())) {
callbackMsg = "<br><br><span style=\"color:#00c0ef;\" > >>>>>>>>>>>" + I18nUtil.getString("jobconf_trigger_child_run") + "<<<<<<<<<<< </span><br>";
String[] childJobIds = xxlJobInfo.getChildJobId().split(",");
for (int i = 0; i < childJobIds.length; i++) {
int childJobId = (StringUtils.isNotBlank(childJobIds[i]) && StringUtils.isNumeric(childJobIds[i])) ? Integer.valueOf(childJobIds[i]) : -1;
if (childJobId > 0) {
ReturnT<String> triggerChildResult = xxlJobService.triggerJob(childJobId);
// add msg
callbackMsg += MessageFormat.format(I18nUtil.getString("jobconf_callback_child_msg1"), (i + 1), childJobIds.length, childJobIds[i], (triggerChildResult.getCode() == ReturnT.SUCCESS_CODE ? I18nUtil.getString("system_success") : I18nUtil.getString("system_fail")), triggerChildResult.getMsg());
} else {
callbackMsg += MessageFormat.format(I18nUtil.getString("jobconf_callback_child_msg2"), (i + 1), childJobIds.length, childJobIds[i]);
}
}
}
} else if (IJobHandler.FAIL_RETRY.getCode() == handleCallbackParam.getExecuteResult().getCode()) {
ReturnT<String> retryTriggerResult = xxlJobService.triggerJob(log.getJobId());
callbackMsg = "<br><br><span style=\"color:#F39C12;\" > >>>>>>>>>>>" + I18nUtil.getString("jobconf_exe_fail_retry") + "<<<<<<<<<<< </span><br>";
callbackMsg += MessageFormat.format(I18nUtil.getString("jobconf_callback_msg1"), (retryTriggerResult.getCode() == ReturnT.SUCCESS_CODE ? I18nUtil.getString("system_success") : I18nUtil.getString("system_fail")), retryTriggerResult.getMsg());
}
// handle msg
StringBuffer handleMsg = new StringBuffer();
if (log.getHandleMsg() != null) {
handleMsg.append(log.getHandleMsg()).append("<br>");
}
if (handleCallbackParam.getExecuteResult().getMsg() != null) {
handleMsg.append(handleCallbackParam.getExecuteResult().getMsg());
}
if (callbackMsg != null) {
handleMsg.append(callbackMsg);
}
// success, save log
log.setHandleTime(new Date());
log.setHandleCode(handleCallbackParam.getExecuteResult().getCode());
log.setHandleMsg(handleMsg.toString());
xxlJobLogDao.updateHandleInfo(log);
return ReturnT.SUCCESS;
}
use of com.xxl.job.admin.core.model.XxlJobInfo in project xxl-job by xuxueli.
the class XxlJobServiceImpl method triggerJob.
@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());
}
}
use of com.xxl.job.admin.core.model.XxlJobInfo in project xxl-job by xuxueli.
the class XxlJobServiceImpl method pause.
@Override
public ReturnT<String> pause(int id) {
XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);
String group = String.valueOf(xxlJobInfo.getJobGroup());
String name = String.valueOf(xxlJobInfo.getId());
try {
// jobStatus do not store
boolean ret = XxlJobDynamicScheduler.pauseJob(name, group);
return ret ? ReturnT.SUCCESS : ReturnT.FAIL;
} catch (SchedulerException e) {
logger.error(e.getMessage(), e);
return ReturnT.FAIL;
}
}
use of com.xxl.job.admin.core.model.XxlJobInfo in project xxl-job by xuxueli.
the class XxlJobServiceImpl method resume.
@Override
public ReturnT<String> resume(int id) {
XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);
String group = String.valueOf(xxlJobInfo.getJobGroup());
String name = String.valueOf(xxlJobInfo.getId());
try {
boolean ret = XxlJobDynamicScheduler.resumeJob(name, group);
return ret ? ReturnT.SUCCESS : ReturnT.FAIL;
} catch (SchedulerException e) {
logger.error(e.getMessage(), e);
return ReturnT.FAIL;
}
}
Aggregations