use of com.dtstack.taier.dao.domain.ScheduleJobExpand in project Taier by DTStack.
the class ActionService method queryJobLog.
/**
* 查看周期实例日志
*
* @param jobId 实例id
* @param pageInfo 第几次重试日志
* @return 日志信息
*/
public ReturnJobLogVO queryJobLog(String jobId, Integer pageInfo) {
if (pageInfo == null) {
pageInfo = 1;
}
// 查询周期实例
ScheduleJob scheduleJob = jobService.lambdaQuery().eq(ScheduleJob::getJobId, jobId).eq(ScheduleJob::getIsDeleted, Deleted.NORMAL.getStatus()).one();
if (scheduleJob == null) {
throw new RdosDefineException("not find job,please contact the administrator");
}
// 取最新
if (0 == pageInfo) {
pageInfo = scheduleJob.getRetryNum();
}
ReturnJobLogVO jobLogVO = new ReturnJobLogVO();
jobLogVO.setPageIndex(pageInfo);
jobLogVO.setPageSize(scheduleJob.getRetryNum());
// 如果RetryNum>1 说明实例已经进行了一次重试,所以取查询重试日志
if (scheduleJob.getRetryNum() > 1) {
// 查询重试日志
ScheduleEngineJobRetry scheduleEngineJobRetry = jobRetryService.lambdaQuery().eq(ScheduleEngineJobRetry::getJobId, jobId).eq(ScheduleEngineJobRetry::getRetryNum, pageInfo).eq(ScheduleEngineJobRetry::getIsDeleted, Deleted.NORMAL.getStatus()).orderBy(true, false, ScheduleEngineJobRetry::getId).one();
if (scheduleEngineJobRetry != null) {
jobLogVO.setLogInfo(scheduleEngineJobRetry.getLogInfo());
jobLogVO.setEngineLog(scheduleEngineJobRetry.getEngineLog());
}
jobLogVO.setPageIndex(pageInfo);
jobLogVO.setPageSize(scheduleJob.getMaxRetryNum());
} else {
// 查询当前日志
ScheduleJobExpand scheduleJobExpand = jobExpandService.lambdaQuery().eq(ScheduleJobExpand::getIsDeleted, Deleted.NORMAL.getStatus()).eq(ScheduleJobExpand::getJobId, jobId).one();
if (scheduleJobExpand != null) {
jobLogVO.setLogInfo(scheduleJobExpand.getLogInfo());
jobLogVO.setEngineLog(scheduleJobExpand.getEngineLog());
}
}
// 封装sql信息
ScheduleTaskShade scheduleTaskShade = taskService.lambdaQuery().eq(ScheduleTaskShade::getTaskId, scheduleJob.getTaskId()).eq(ScheduleTaskShade::getIsDeleted, Deleted.NORMAL.getStatus()).one();
if (null != scheduleTaskShade) {
JSONObject shadeInfo = scheduleTaskShadeInfoService.getInfoJSON(scheduleTaskShade.getTaskId());
String taskParams = shadeInfo.getString("taskParamsToReplace");
List<ScheduleTaskParamShade> taskParamsToReplace = JSONObject.parseArray(taskParams, ScheduleTaskParamShade.class);
String sqlText = scheduleTaskShade.getSqlText();
if (EScheduleJobType.SYNC.getType().equals(scheduleTaskShade.getTaskType())) {
sqlText = Base64Util.baseDecode(sqlText);
}
sqlText = JobParamReplace.paramReplace(sqlText, taskParamsToReplace, scheduleJob.getCycTime());
jobLogVO.setSqlText(sqlText);
Timestamp execStartTime = scheduleJob.getExecStartTime();
Timestamp execEndTime = scheduleJob.getExecEndTime();
if (EScheduleJobType.SYNC.getType().equals(scheduleTaskShade.getTaskType())) {
String syncLog = null;
try {
syncLog = batchServerLogService.formatPerfLogInfo(scheduleJob.getEngineJobId(), scheduleJob.getJobId(), Optional.ofNullable(execStartTime).orElse(Timestamp.valueOf(LocalDateTime.now())).getTime(), Optional.ofNullable(execEndTime).orElse(Timestamp.valueOf(LocalDateTime.now())).getTime(), scheduleJob.getTenantId());
} catch (Exception e) {
LOGGER.error("queryJobLog {} sync log error", jobId, e);
}
jobLogVO.setSyncLog(syncLog);
}
if (EScheduleJobType.SPARK_SQL.getType().equals(scheduleTaskShade.getTaskType())) {
jobLogVO.setDownLoadUrl(String.format(CommonConstant.DOWNLOAD_LOG, scheduleJob.getJobId(), scheduleJob.getTaskType(), scheduleJob.getTenantId()));
}
}
return jobLogVO;
}
use of com.dtstack.taier.dao.domain.ScheduleJobExpand in project Taier by DTStack.
the class ScheduleActionService method log.
/**
* 根据jobid 和 计算类型,查询job的日志
*/
public ActionLogVO log(String jobId) {
if (StringUtils.isBlank(jobId)) {
throw new RdosDefineException("jobId is not allow null", ErrorCode.INVALID_PARAMETERS);
}
ActionLogVO vo = new ActionLogVO();
ScheduleJobExpand scheduleJobExpand = scheduleJobExpandService.getByJobId(jobId);
if (scheduleJobExpand != null) {
vo.setEngineLog(scheduleJobExpand.getEngineLog());
vo.setLogInfo(scheduleJobExpand.getLogInfo());
if (StringUtils.isBlank(scheduleJobExpand.getEngineLog())) {
ScheduleJob scheduleJob = scheduleJobService.getByJobId(jobId);
vo.setEngineLog(getEngineLog(jobId, scheduleJob));
}
}
return vo;
}
use of com.dtstack.taier.dao.domain.ScheduleJobExpand in project Taier by DTStack.
the class ScheduleJobExpandService method updateEngineLog.
public void updateEngineLog(String jobId, String engineLog) {
ScheduleJobExpand scheduleJobExpand = new ScheduleJobExpand();
scheduleJobExpand.setJobId(jobId);
scheduleJobExpand.setEngineLog(engineLog);
getBaseMapper().update(scheduleJobExpand, Wrappers.lambdaQuery(ScheduleJobExpand.class).eq(ScheduleJobExpand::getJobId, jobId));
}
use of com.dtstack.taier.dao.domain.ScheduleJobExpand in project Taier by DTStack.
the class BatchDownloadService method getLog.
/**
* 获取log
*
* @param jobId
*/
private String getLog(String jobId) {
StringBuilder log = new StringBuilder();
// hdfs没有日志就下载engine里的日志
if (StringUtils.isNotBlank(jobId)) {
ScheduleJobExpand scheduleJobExpand = jobExpandService.selectOneByJobId(jobId);
if (Objects.nonNull(scheduleJobExpand)) {
log.append("=====================提交日志========================\n");
if (StringUtils.isNotBlank(scheduleJobExpand.getLogInfo())) {
log.append(scheduleJobExpand.getLogInfo().replace("\\n", "\n").replace("\\t", " "));
}
log.append("\n\n\n");
if (StringUtils.isNotBlank(scheduleJobExpand.getEngineLog())) {
log.append("=====================运行日志========================\n");
log.append(scheduleJobExpand.getEngineLog().replace("\\n", "\n").replace("\\t", " "));
log.append("\n\n\n");
}
}
}
return log.toString();
}
Aggregations