Commit 0a7eea16 by huangfusuper

脚本类数据

parent cae3413c
......@@ -9,6 +9,7 @@ public enum RedisKeyNameEnum {
* 调度中心公共参数
*/
REDIS_PUBLIC_PARAM_KEY("myth:param:public:%s%s"),
REDIS_FLOW_ERROR_MSG_KEY("myth:error:msg:%s:%s:"),
;
private final String keyName;
......
package com.byit.service.impl;
import com.byit.enums.EmailEnum;
import com.byit.enums.RedisKeyNameEnum;
import com.byit.enums.RunRecordingEnum;
import com.byit.enums.task.RunResultEnum;
import com.byit.enums.task.RunTypeEnum;
......@@ -8,8 +9,9 @@ import com.byit.model.JobTaskRunLogWithBLOBs;
import com.byit.model.JobTaskSchedule;
import com.byit.service.FastRunLogService;
import com.byit.service.JobTaskRunLogService;
import com.byit.util.SpringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.util.Date;
......@@ -22,9 +24,11 @@ import java.util.Date;
public class FastRunLogServiceImpl implements FastRunLogService {
private final JobTaskRunLogService jobTaskRunLogService;
public static final String LINE = "\n";
private final StringRedisTemplate stringRedisTemplate;
public FastRunLogServiceImpl(JobTaskRunLogService jobTaskRunLogService) {
public FastRunLogServiceImpl(JobTaskRunLogService jobTaskRunLogService, StringRedisTemplate stringRedisTemplate) {
this.jobTaskRunLogService = jobTaskRunLogService;
this.stringRedisTemplate = stringRedisTemplate;
}
@Override
......@@ -77,6 +81,12 @@ public class FastRunLogServiceImpl implements FastRunLogService {
}else{
jobTaskRunLog.setRunMsg(msg+ LINE);
}
String format = String.format(RedisKeyNameEnum.REDIS_FLOW_ERROR_MSG_KEY.getKeyName(), mythJobTaskSchedule.getRunId(), mythJobTaskSchedule.getFlowName());
String errorMsg = stringRedisTemplate.opsForValue().get(format);
if(StringUtils.isNoneBlank(errorMsg)) {
jobTaskRunLog.setRunMsg(errorMsg+ LINE);
stringRedisTemplate.delete(format);
}
jobTaskRunLog.setRunCount(jobTaskRunLogById.getRunCount()+1);
jobTaskRunLogService.updateJobTaskRunLogWithBLOBs(jobTaskRunLog);
log.info("-----------saveErrorLog--保存KILL脚本调度日志结束------------");
......
......@@ -2,11 +2,13 @@ package com.byit.service.impl;
import com.byit.dto.BeanStrategyPackage;
import com.byit.enums.NodeNameEnum;
import com.byit.enums.RedisKeyNameEnum;
import com.byit.enums.RunRecordingEnum;
import com.byit.enums.ScheduleTypeEnum;
import com.byit.enums.task.RunResultEnum;
import com.byit.event.FlowScanEndEvent;
import com.byit.job.utils.CronExpression;
import com.byit.job.utils.MythLogUtils;
import com.byit.model.Flow;
import com.byit.model.JobTask;
import com.byit.model.Node;
......@@ -22,6 +24,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
......@@ -40,6 +43,7 @@ public class RunNodeServiceImpl implements RunNodeServer, ApplicationEventPublis
private final JobTaskService jobTaskService;
private final FlowService flowService;
private ApplicationEventPublisher applicationEventPublisher;
private final StringRedisTemplate stringRedisTemplate;
@Value("${server.port}")
private Integer serverPort;
/**
......@@ -48,10 +52,11 @@ public class RunNodeServiceImpl implements RunNodeServer, ApplicationEventPublis
private final NodeDependencyService nodeDependencyService;
public RunNodeServiceImpl(RunRecordingService runRecordingService, JobTaskService jobTaskService,
FlowService flowService, NodeDependencyService nodeDependencyService) {
FlowService flowService, StringRedisTemplate stringRedisTemplate, NodeDependencyService nodeDependencyService) {
this.runRecordingService = runRecordingService;
this.jobTaskService = jobTaskService;
this.flowService = flowService;
this.stringRedisTemplate = stringRedisTemplate;
this.nodeDependencyService = nodeDependencyService;
}
......@@ -120,7 +125,8 @@ public class RunNodeServiceImpl implements RunNodeServer, ApplicationEventPublis
}
}
} catch (Exception e) {
e.printStackTrace();
String format = String.format(RedisKeyNameEnum.REDIS_FLOW_ERROR_MSG_KEY.getKeyName(), build.getRunId(), build.getFlowName());
stringRedisTemplate.opsForValue().set(format, MythLogUtils.getMessage(e));
build.setFlowStatus(RunRecordingEnum.FLOW_STATUS_IS_END.getCode());
build.setFlowRunResult(RunResultEnum.RUN_ERROR.getCode());
build.setFailFast(RunRecordingEnum.FAIL_FAST_YES.getCode());
......
......@@ -2,11 +2,10 @@ package com.byit.service.mapservice.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.byit.dto.BeanStrategyPackage;
import com.byit.dto.RunRecordingWrapped;
import com.byit.enums.*;
import com.byit.enums.task.RunResultEnum;
import com.byit.job.utils.CronExpression;
import com.byit.job.utils.DateUtil;
import com.byit.job.utils.MythLogUtils;
import com.byit.model.*;
import com.byit.service.*;
import com.byit.service.mapservice.RunRecordingAndJobTaskService;
......@@ -16,6 +15,7 @@ import com.byit.util.SpringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
......@@ -41,6 +41,7 @@ public class RunRecordingAndJobTaskServiceImpl implements RunRecordingAndJobTask
private final JobTaskService jobTaskService;
private final WaitingRecordService waitingRecordService;
private final WaitingTaskService taskService;
private final StringRedisTemplate stringRedisTemplate;
/**
* 节点依赖查询操作
*/
......@@ -48,7 +49,7 @@ public class RunRecordingAndJobTaskServiceImpl implements RunRecordingAndJobTask
public RunRecordingAndJobTaskServiceImpl(JobTaskRunLogService jobTaskRunLogService, NodeService nodeService,
FlowService flowService, RunRecordingService runRecordingService,
JobTaskService jobTaskService, WaitingRecordService waitingRecordService, WaitingTaskService taskService, NodeDependencyService nodeDependencyService) {
JobTaskService jobTaskService, WaitingRecordService waitingRecordService, WaitingTaskService taskService, StringRedisTemplate stringRedisTemplate, NodeDependencyService nodeDependencyService) {
this.jobTaskRunLogService = jobTaskRunLogService;
this.nodeService = nodeService;
this.flowService = flowService;
......@@ -56,6 +57,7 @@ public class RunRecordingAndJobTaskServiceImpl implements RunRecordingAndJobTask
this.jobTaskService = jobTaskService;
this.waitingRecordService = waitingRecordService;
this.taskService = taskService;
this.stringRedisTemplate = stringRedisTemplate;
this.nodeDependencyService = nodeDependencyService;
}
/**
......@@ -282,7 +284,8 @@ public class RunRecordingAndJobTaskServiceImpl implements RunRecordingAndJobTask
}
}
}catch (Exception e) {
e.printStackTrace();
String format = String.format(RedisKeyNameEnum.REDIS_FLOW_ERROR_MSG_KEY.getKeyName(), runRecording.getRunId(), runRecording.getFlowName());
stringRedisTemplate.opsForValue().set(format, MythLogUtils.getMessage(e));
runRecording.setFlowStatus(RunRecordingEnum.FLOW_STATUS_IS_END.getCode());
runRecording.setFlowRunResult(RunResultEnum.RUN_ERROR.getCode());
runRecording.setFailFast(RunRecordingEnum.FAIL_FAST_YES.getCode());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment