use of com.dtstack.taier.scheduler.vo.action.ActionRetryLogVO in project Taier by DTStack.
the class ScheduleActionService method retryLog.
/**
* 根据jobid 和 计算类型,查询job的重试retry日志
*/
public List<ActionRetryLogVO> retryLog(String jobId) {
if (StringUtils.isBlank(jobId)) {
throw new RdosDefineException("jobId is not allow null", ErrorCode.INVALID_PARAMETERS);
}
List<ActionRetryLogVO> logs = new ArrayList<>(5);
List<ScheduleEngineJobRetry> jobRetries = engineJobRetryMapper.selectList(Wrappers.lambdaQuery(ScheduleEngineJobRetry.class).eq(ScheduleEngineJobRetry::getJobId, jobId).last(" limit 5"));
if (CollectionUtils.isNotEmpty(jobRetries)) {
jobRetries.forEach(jobRetry -> {
ActionRetryLogVO vo = new ActionRetryLogVO();
vo.setRetryNum(jobRetry.getRetryNum());
vo.setLogInfo(jobRetry.getLogInfo());
vo.setRetryTaskParams(jobRetry.getRetryTaskParams());
logs.add(vo);
});
}
return logs;
}
use of com.dtstack.taier.scheduler.vo.action.ActionRetryLogVO in project Taier by DTStack.
the class ScheduleActionService method retryLogDetail.
/**
* 根据jobid 和 计算类型,查询job的重试retry日志
*/
public ActionRetryLogVO retryLogDetail(String jobId, Integer retryNum) {
if (StringUtils.isBlank(jobId)) {
throw new RdosDefineException("jobId is not allow null", ErrorCode.INVALID_PARAMETERS);
}
if (retryNum == null || retryNum <= 0) {
retryNum = 1;
}
ScheduleJob scheduleJob = scheduleJobService.getByJobId(jobId);
// 数组库中存储的retryNum为0开始的索引位置
ScheduleEngineJobRetry jobRetry = engineJobRetryMapper.selectOne(Wrappers.lambdaQuery(ScheduleEngineJobRetry.class).eq(ScheduleEngineJobRetry::getJobId, jobId).eq(ScheduleEngineJobRetry::getRetryNum, retryNum - 1));
ActionRetryLogVO vo = new ActionRetryLogVO();
if (jobRetry != null) {
vo.setRetryNum(jobRetry.getRetryNum());
vo.setLogInfo(jobRetry.getLogInfo());
String engineLog = jobRetry.getEngineLog();
if (StringUtils.isBlank(jobRetry.getEngineLog())) {
engineLog = jobDealer.getAndUpdateEngineLog(jobId, jobRetry.getEngineJobId(), jobRetry.getApplicationId(), scheduleJob.getTenantId());
if (engineLog != null) {
LOGGER.info("engineJobRetryDao.updateEngineLog id:{}, jobId:{}, engineLog:{}", jobRetry.getId(), jobRetry.getJobId(), engineLog);
jobRetry.setEngineLog(engineLog);
engineJobRetryMapper.updateById(jobRetry);
} else {
engineLog = "";
}
}
vo.setEngineLog(engineLog);
vo.setRetryTaskParams(jobRetry.getRetryTaskParams());
}
return vo;
}
use of com.dtstack.taier.scheduler.vo.action.ActionRetryLogVO in project Taier by DTStack.
the class BatchServerLogService method buildRetryLog.
/**
* 组装重试日志
*
* @param jobId
* @param pageInfo 第几次的重试日志 如果传入0 默认是最新的 -1 展示所有的(为了兼容内部调用)
* @param batchServerLogVO
* @return
*/
private String buildRetryLog(final String jobId, Integer pageInfo, final BatchServerLogVO batchServerLogVO) {
final Map<String, Object> retryParamsMap = Maps.newHashMap();
retryParamsMap.put("jobId", jobId);
retryParamsMap.put("computeType", ComputeType.BATCH.getType());
// 先获取engine的日志总数信息
List<ActionRetryLogVO> actionRetryLogVOs = actionService.retryLog(jobId);
if (CollectionUtils.isEmpty(actionRetryLogVOs)) {
return "";
}
batchServerLogVO.setPageSize(actionRetryLogVOs.size());
if (Objects.isNull(pageInfo)) {
pageInfo = 0;
}
// engine 的 retryNum 从1 开始
if (0 == pageInfo) {
pageInfo = actionRetryLogVOs.size();
}
if (pageInfo > actionRetryLogVOs.size()) {
throw new RdosDefineException(ErrorCode.INVALID_PARAMETERS);
}
retryParamsMap.put("retryNum", pageInfo);
// 获取对应的日志
ActionRetryLogVO retryLogContent = actionService.retryLogDetail(jobId, pageInfo);
StringBuilder builder = new StringBuilder();
if (Objects.isNull(retryLogContent)) {
return "";
}
Integer retryNumVal = retryLogContent.getRetryNum();
int retryNum = 0;
if (Objects.nonNull(retryNumVal)) {
retryNum = retryNumVal + 1;
}
String logInfo = retryLogContent.getLogInfo();
String engineInfo = retryLogContent.getEngineLog();
String retryTaskParams = retryLogContent.getRetryTaskParams();
builder.append("====================第 ").append(retryNum).append("次重试====================").append("\n");
if (!Strings.isNullOrEmpty(logInfo)) {
builder.append("====================LogInfo start====================").append("\n");
builder.append(logInfo).append("\n");
builder.append("=====================LogInfo end=====================").append("\n");
}
if (!Strings.isNullOrEmpty(engineInfo)) {
builder.append("==================EngineInfo start==================").append("\n");
builder.append(engineInfo).append("\n");
builder.append("===================EngineInfo end===================").append("\n");
}
if (!Strings.isNullOrEmpty(retryTaskParams)) {
builder.append("==================RetryTaskParams start==================").append("\n");
builder.append(retryTaskParams).append("\n");
builder.append("===================RetryTaskParams end===================").append("\n");
}
builder.append("==================第").append(retryNum).append("次重试结束==================").append("\n");
for (int j = 0; j < 10; j++) {
builder.append("==" + "\n");
}
return builder.toString();
}
Aggregations