use of com.vip.saturn.job.SaturnJobReturn in project Saturn by vipshop.
the class SaturnScriptJob method innerHandleWithListener.
protected SaturnJobReturn innerHandleWithListener(String jobName, Integer item, String execParameter, SaturnExecutionContext shardingContext) {
ShardingItemCallable callable = createShardingItemCallable(jobName, item, execParameter, shardingContext);
shardingItemCallableList.add(callable);
beforeExecution(callable);
SaturnJobReturn saturnJobReturn = null;
try {
saturnJobReturn = innerHandle(callable);
} catch (Throwable t) {
LogUtils.error(log, jobName, t.getMessage(), t);
saturnJobReturn = new SaturnJobReturn(SaturnSystemReturnCode.USER_FAIL, t.getMessage(), SaturnSystemErrorGroup.FAIL);
}
callable.setSaturnJobReturn(saturnJobReturn);
afterExecution(callable);
LogUtils.debug(log, jobName, "job:{} item:{} finish execution, which takes {}ms", jobName, item, callable.getExecutionTime());
return saturnJobReturn;
}
use of com.vip.saturn.job.SaturnJobReturn in project Saturn by vipshop.
the class ExecutionService method registerJobCompletedReportInfoByItem.
/**
* 作业完成信息注册,此信息用于页面展现。注意,无论作业是否上报状态(对应/config/enabledReport/节点),都会注册此信息。
*/
public void registerJobCompletedReportInfoByItem(final JobExecutionMultipleShardingContext jobExecutionShardingContext, int item, Date nextFireTimePausePeriodEffected) {
ExecutionInfo info = reportService.getInfoByItem(item);
if (info == null) {
// old data has been flushed to zk.
info = new ExecutionInfo(item);
}
if (jobExecutionShardingContext instanceof SaturnExecutionContext) {
// 为了展现分片处理失败的状态
SaturnExecutionContext saturnContext = (SaturnExecutionContext) jobExecutionShardingContext;
if (saturnContext.isSaturnJob()) {
SaturnJobReturn jobRet = saturnContext.getShardingItemResults().get(item);
if (jobRet != null) {
int errorGroup = jobRet.getErrorGroup();
info.setJobMsg(jobRet.getReturnMsg());
// 如果作业执行成功且不展示日志,则不展现log
if (errorGroup == SaturnSystemErrorGroup.SUCCESS && !configService.showNormalLog()) {
info.setJobLog(null);
} else {
info.setJobLog(saturnContext.getJobLog(item));
}
} else {
info.setJobMsg(NO_RETURN_VALUE);
}
}
}
if (nextFireTimePausePeriodEffected != null) {
info.setNextFireTime(nextFireTimePausePeriodEffected.getTime());
}
info.setLastCompleteTime(System.currentTimeMillis());
reportService.fillInfoOnAfter(info);
}
use of com.vip.saturn.job.SaturnJobReturn in project Saturn by vipshop.
the class ExecutionService method updateErrorJobReturnIfPossible.
private void updateErrorJobReturnIfPossible(JobExecutionMultipleShardingContext jobExecutionShardingContext, int item) {
if (jobExecutionShardingContext instanceof SaturnExecutionContext) {
// 为了展现分片处理失败的状态
SaturnExecutionContext saturnContext = (SaturnExecutionContext) jobExecutionShardingContext;
if (!saturnContext.isSaturnJob()) {
return;
}
SaturnJobReturn jobRet = saturnContext.getShardingItemResults().get(item);
try {
if (jobRet != null) {
int errorGroup = jobRet.getErrorGroup();
if (errorGroup == SaturnSystemErrorGroup.TIMEOUT) {
getJobNodeStorage().createJobNodeIfNeeded(ExecutionNode.getTimeoutNode(item));
} else if (errorGroup != SaturnSystemErrorGroup.SUCCESS) {
getJobNodeStorage().createJobNodeIfNeeded(ExecutionNode.getFailedNode(item));
}
} else {
getJobNodeStorage().createJobNodeIfNeeded(ExecutionNode.getFailedNode(item));
}
} catch (RegException e) {
LogUtils.warn(log, jobName, "update job return fail.", e);
}
}
}
use of com.vip.saturn.job.SaturnJobReturn in project Saturn by vipshop.
the class ReturnParamJavaJob method handleJavaJob.
@Override
public SaturnJobReturn handleJavaJob(String jobName, Integer shardItem, String shardParam, SaturnJobExecutionContext shardingContext) {
String key = jobName + "_" + shardItem;
Integer status = statusMap.get(key);
int count = 0;
if (status != null) {
count = status;
}
count++;
statusMap.put(key, count);
System.out.println(new Date() + " running:" + jobName + "; " + shardItem + ";" + shardParam + "; count:" + count);
return new SaturnJobReturn(shardParam);
}
use of com.vip.saturn.job.SaturnJobReturn in project Saturn by vipshop.
the class SimpleJavaJob method handleJavaJob.
@Override
public SaturnJobReturn handleJavaJob(String jobName, Integer shardItem, String shardParam, SaturnJobExecutionContext shardingContext) {
String key = jobName + "_" + shardItem;
System.out.println(new Date() + " running:" + jobName + "; " + shardItem + ";" + shardParam);
countInc(key);
return new SaturnJobReturn(" result:" + jobName + "; " + shardItem + ";" + shardParam);
}
Aggregations