Commit 31c58003 by huangfusuper

Merge remote-tracking branch 'origin/developer' into developer

parents a27aab9e 35dda7b5
...@@ -280,7 +280,9 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -280,7 +280,9 @@ public class ApiFlowServiceImpl implements ApiFlowService {
//设置失败重试 //设置失败重试
if (null != ((PluginNode)pluginNode).getConfig().getFailedRetryCount()){ if (null != ((PluginNode)pluginNode).getConfig().getFailedRetryCount()){
node.setFailedRetryCount(((PluginNode)pluginNode).getConfig().getFailedRetryCount()); node.setFailedRetryCount(((PluginNode)pluginNode).getConfig().getFailedRetryCount());
node.setFailedRetryInterval(((PluginNode)pluginNode).getConfig().getFailedRetryInterval()); node.setFailedRetryInterval(null == ((PluginNode)pluginNode).getConfig().getFailedRetryInterval() ? 3000 : ((PluginNode)pluginNode).getConfig().getFailedRetryInterval());
}else {
node.setFailedRetryCount(0);
} }
//设置剩余执行次数 //设置剩余执行次数
if (null != ((PluginNode)pluginNode).getConfig().getRepeatCount() && !"-1".equals(((PluginNode)pluginNode).getConfig().getRepeatCount())){ if (null != ((PluginNode)pluginNode).getConfig().getRepeatCount() && !"-1".equals(((PluginNode)pluginNode).getConfig().getRepeatCount())){
......
...@@ -125,4 +125,12 @@ public interface JobTaskRunLogMapper { ...@@ -125,4 +125,12 @@ public interface JobTaskRunLogMapper {
@Param("flowIdList")List<Integer> flowIdList); @Param("flowIdList")List<Integer> flowIdList);
StatisticData findStatisticDataByRunIdAndFlowId(@Param("runId")String runId, @Param("flowId")Integer flowId); StatisticData findStatisticDataByRunIdAndFlowId(@Param("runId")String runId, @Param("flowId")Integer flowId);
/**
* 根据runid和flowidlist获取运行日志
* @param runId
* @param flowIdList
* @return
*/
List<JobTaskRunLog> findbyRunIdAndFlowIdList(@Param("runId")String runId, @Param("flowIdList")List<Integer> flowIdList);
} }
\ No newline at end of file
...@@ -137,7 +137,7 @@ public interface RunRecordingMapper { ...@@ -137,7 +137,7 @@ public interface RunRecordingMapper {
* @param runId * @param runId
* @return * @return
*/ */
RunRecording findUnFinishByRunId(@Param("runId")String runId, @Param("flowId")Integer flowId); List<RunRecording> findUnFinishByRunId(@Param("runId")String runId, @Param("flowIdList")List<Integer> flowIdList);
List<RunRecording> findByStartAndEndTime(@Param("startDate")Date startDate, List<RunRecording> findByStartAndEndTime(@Param("startDate")Date startDate,
@Param("endDate")Date endDate, @Param("endDate")Date endDate,
......
...@@ -364,27 +364,45 @@ public class FlowServiceImpl implements FlowService { ...@@ -364,27 +364,45 @@ public class FlowServiceImpl implements FlowService {
ValidationUtil.dataNotBank(flowName, "工作流名称不允许为空!"); ValidationUtil.dataNotBank(flowName, "工作流名称不允许为空!");
Flow flow = flowMapper.getByWorkSpaceAndName(workspace.getWorkspaceId(), flowName); Flow flow = flowMapper.getByWorkSpaceAndName(workspace.getWorkspaceId(), flowName);
ValidationUtil.dataNotNull(flow, flowName + "工作流不存在"); ValidationUtil.dataNotNull(flow, flowName + "工作流不存在");
List<Integer> flowIdList = new ArrayList<>();
Queue<Integer> queue = new LinkedList<>();
flowIdList.add(flow.getFlowId());
queue.offer(flow.getFlowId());
while(!queue.isEmpty()){
List<Node> innerFlowList = nodeMapper.findVirtualByFlowId(queue.poll());
if (null != innerFlowList && innerFlowList.size() > 0){
innerFlowList.forEach(node -> {
flowIdList.add(node.getMapFlowId());
queue.offer(node.getMapFlowId());
});
}
}
//杀死运行实例 //杀死运行实例
RunRecording runRecording = runRecordingMapper.findUnFinishByRunId(runId, flow.getFlowId()); List<RunRecording> runRecordingList = runRecordingMapper.findUnFinishByRunId(runId, flowIdList);
ValidationUtil.dataNotNull(runRecording, "该运行id未找到或已经运行完成无需杀死!"); ValidationUtil.dataNotNull(runRecordingList, "该运行id未找到或已经运行完成无需杀死!");
Boolean result = true; Boolean result = true;
//将未完成的运行实例设置为完成且杀死 runRecordingList.forEach(runRecording -> {
runRecording.setFlowStatus("4"); //将未完成的运行实例设置为完成且杀死
runRecording.setFlowRunResult("5"); runRecording.setFlowStatus("4");
runRecordingMapper.updateRunRecordingById(runRecording); runRecording.setFlowRunResult("5");
runRecordingMapper.updateRunRecordingById(runRecording);
});
//杀死所有的任务 //杀死所有的任务
List<JobTaskRunLogWithBLOBs> jobTaskRunLogList = jobTaskRunLogMapper.findJobTaskRunLogWithBLOBsByFlowIdAndRunId(flow.getFlowId(), runId); List<JobTaskRunLog> jobTaskRunLogList = jobTaskRunLogMapper.findbyRunIdAndFlowIdList(runId, flowIdList);
for (JobTaskRunLogWithBLOBs jobTaskRunLog : jobTaskRunLogList){ if (null != jobTaskRunLogList && jobTaskRunLogList.size() > 0){
if ("0".equals(jobTaskRunLog.getRunCode())){ for (JobTaskRunLog jobTaskRunLog : jobTaskRunLogList){
if (StringUtils.isEmpty(jobTaskRunLog.getJobGroupIp())){ if ("0".equals(jobTaskRunLog.getRunCode())){
log.warn("已经调度成功但是还未返回具体的调用机器的ip地址"); if (StringUtils.isEmpty(jobTaskRunLog.getJobGroupIp())){
Thread.sleep(3000); log.warn("已经调度成功但是还未返回具体的调用机器的ip地址");
jobTaskRunLog = jobTaskRunLogMapper.findJobTaskRunLogByLogId(jobTaskRunLog.getLogId()); Thread.sleep(3000);
ValidationUtil.isTrueValidation(!"0".equals(jobTaskRunLog.getRunCode()), "该任务已经运行结束!"); jobTaskRunLog = jobTaskRunLogMapper.findJobTaskRunLogByLogId(jobTaskRunLog.getLogId());
ValidationUtil.dataNotBank(jobTaskRunLog.getJobGroupIp(), "尚未分配执行机请稍后再试"); ValidationUtil.isTrueValidation(!"0".equals(jobTaskRunLog.getRunCode()), "该任务已经运行结束!");
} ValidationUtil.dataNotBank(jobTaskRunLog.getJobGroupIp(), "尚未分配执行机请稍后再试");
if (! killJob(jobTaskRunLog.getLogId(), jobTaskRunLog.getJobGroupIp())){ }
result = false; if (! killJob(jobTaskRunLog.getLogId(), jobTaskRunLog.getJobGroupIp())){
result = false;
}
} }
} }
} }
......
...@@ -217,7 +217,7 @@ ...@@ -217,7 +217,7 @@
<insert id="saveList" parameterType="com.byit.model.FlowStatusSnapshoot"> <insert id="saveList" parameterType="com.byit.model.FlowStatusSnapshoot">
INSERT INTO flow_status_snapshoot INSERT INTO flow_status_snapshoot
( (
status_id, workspace_id, flow_id, workspace_id, flow_id,
flow_name, `day`, `hour`, flow_name, `day`, `hour`,
flow_status, snapshoot_time, unstart_node, flow_status, snapshoot_time, unstart_node,
runing_node, success_node, fail_node, runing_node, success_node, fail_node,
...@@ -226,7 +226,6 @@ ...@@ -226,7 +226,6 @@
VALUES VALUES
<foreach collection="flowStatusSnapshootList" item="flowStatusSnapshoot" separator=","> <foreach collection="flowStatusSnapshootList" item="flowStatusSnapshoot" separator=",">
( (
#{flowStatusSnapshoot.statusId,jdbcType=INTEGER},
#{flowStatusSnapshoot.workspaceId,jdbcType=INTEGER}, #{flowStatusSnapshoot.workspaceId,jdbcType=INTEGER},
#{flowStatusSnapshoot.flowId,jdbcType=INTEGER}, #{flowStatusSnapshoot.flowId,jdbcType=INTEGER},
#{flowStatusSnapshoot.flowName,jdbcType=VARCHAR}, #{flowStatusSnapshoot.flowName,jdbcType=VARCHAR},
......
...@@ -148,8 +148,20 @@ ...@@ -148,8 +148,20 @@
where run_id = #{runId} where run_id = #{runId}
and flow_id = #{flowId} and flow_id = #{flowId}
</select> </select>
<select id="findbyRunIdAndFlowIdList" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from job_task_run_log
where run_id = #{runId}
<if test="flowIdList != null">
and flow_id in (
<foreach collection="flowIdList" item="flowId" separator=",">
#{flowId}
</foreach>
)
</if>
</select>
<delete id="deleteById" parameterType="java.lang.Integer"> <delete id="deleteById" parameterType="java.lang.Integer">
delete from job_task_run_log delete from job_task_run_log
where log_id = #{logId,jdbcType=INTEGER} where log_id = #{logId,jdbcType=INTEGER}
</delete> </delete>
......
...@@ -103,8 +103,14 @@ ...@@ -103,8 +103,14 @@
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from run_recording from run_recording
where run_id = #{runId,jdbcType=VARCHAR} where run_id = #{runId,jdbcType=VARCHAR}
and flow_id = #{flowId,jdbcType=INTEGER}
and flow_status != '4' and flow_status != '4'
<if test="flowIdList != null">
and flow_id in (
<foreach collection="flowIdList" item="flowId" separator=",">
#{flowId}
</foreach>
)
</if>
</select> </select>
<select id="findByStartAndEndTime" resultMap="BaseResultMap"> <select id="findByStartAndEndTime" resultMap="BaseResultMap">
select select
......
...@@ -268,9 +268,13 @@ public class JobUtils { ...@@ -268,9 +268,13 @@ public class JobUtils {
* @param runId * @param runId
* @return * @return
*/ */
public static ResponseResult killFlow(String runId){ public static ResponseResult killFlow(String runId, String flowName, String workspaceName){
Map<String,String> map = new HashMap<>(5);
map.put("runId", runId);
map.put("flowName", flowName);
map.put("workspaceName", workspaceName);
//发送请求 添加任务 //发送请求 添加任务
String response = createHttpRequest(REQUEST_FLOW_KILL_FLOW, "runId=" + runId); String response = createHttpRequest(REQUEST_FLOW_KILL_FLOW, "param="+JSON.toJSONString(map,WriteClassName));
log.info("--------------------杀死工作流接口调用成功,结果为:{}------------------------",response); log.info("--------------------杀死工作流接口调用成功,结果为:{}------------------------",response);
return JSON.parseObject(response, ResponseResult.class); return JSON.parseObject(response, ResponseResult.class);
} }
......
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