Commit 9523847c by guominglei

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

parents c08ea1a1 394fd8af
package com.byit.api;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.byit.service.ApiFlowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -52,16 +54,21 @@ public class ApiFlowController {
}
@PostMapping("killSchedule")
@ApiOperation("杀死本次调度")
public String killSchedule(String flowName, String workspaceName){
public String killSchedule(String param){
JSONObject jsonObject = JSON.parseObject(param);
String flowName = jsonObject.getString("flowName");
String workspaceName = jsonObject.getString("workspaceName");
apiFlowService.killSchedule(flowName, workspaceName);
return "SUCCESS";
}
@PostMapping("stopSchedule")
@ApiOperation("暂停本次调度")
public String stopSchedule(String flowName, String workspaceName){
String runId = apiFlowService.stopSchedule(flowName, workspaceName);
return runId;
public String stopSchedule(String param){
JSONObject jsonObject = JSON.parseObject(param);
String flowName = jsonObject.getString("flowName");
String workspaceName = jsonObject.getString("workspaceName");
return apiFlowService.stopSchedule(flowName, workspaceName);
}
@PostMapping("reStartSchedule")
......
......@@ -21,6 +21,7 @@ public enum FlowPropertyEnum {
FAIL_ALARML("3", "失败时告警"),
IS_CURRENTVERSION("0", "版本表是当前版本的工作流"),
ISNOT_CURRENTVERSION("1", "版本表不是当前版本的工作流"),
FLOW_RUN_ING("2","工作流运行中"),
;
private String code;
......
package com.byit.thread;
import cn.hutool.core.collection.CollectionUtil;
import com.byit.enums.FlowPropertyEnum;
import com.byit.enums.JobTriggerStatusEnums;
import com.byit.job.WorkRoulette;
import com.byit.model.*;
......@@ -43,6 +44,7 @@ public class JobScheduleHelper{
private final NodeDependencyService nodeDependencyService;
private final JobTaskRunLogService jobTaskRunLogService;
private final TaskAndLogServer taskAndLogServer;
private final RunRecordingService runRecordingService;
/**
......@@ -72,13 +74,14 @@ public class JobScheduleHelper{
private volatile boolean scheduleThreadToStop = false;
@Autowired
public JobScheduleHelper(RunRecordingAndJobTaskService runRecordingAndJobTaskService, JobTaskScheduleService jobTaskScheduleService, JobTaskService jobTaskService, NodeDependencyService nodeDependencyService, JobTaskRunLogService jobTaskRunLogService, TaskAndLogServer taskAndLogServer) {
public JobScheduleHelper(RunRecordingAndJobTaskService runRecordingAndJobTaskService, JobTaskScheduleService jobTaskScheduleService, JobTaskService jobTaskService, NodeDependencyService nodeDependencyService, JobTaskRunLogService jobTaskRunLogService, TaskAndLogServer taskAndLogServer, RunRecordingService runRecordingService) {
this.runRecordingAndJobTaskService = runRecordingAndJobTaskService;
this.jobTaskScheduleService = jobTaskScheduleService;
this.jobTaskService = jobTaskService;
this.nodeDependencyService = nodeDependencyService;
this.jobTaskRunLogService = jobTaskRunLogService;
this.taskAndLogServer = taskAndLogServer;
this.runRecordingService = runRecordingService;
}
/**
......@@ -150,6 +153,12 @@ public class JobScheduleHelper{
JobTaskSchedule jobTaskSchedule = new JobTaskSchedule();
BeanUtils.copyProperties(jobTask,jobTaskSchedule);
jobTaskSchedules.add(jobTaskSchedule);
//更改运行记录为运行中
String runId = jobTask.getRunId();
Integer flowId = jobTask.getFlowId();
RunRecording runRecordingByFlowIdAndRunId = runRecordingService.findRunRecordingByFlowIdAndRunId(flowId, runId);
runRecordingByFlowIdAndRunId.setFlowStatus(FlowPropertyEnum.FLOW_RUN_ING.getCode());
runRecordingService.updateRunRecordingById(runRecordingByFlowIdAndRunId);
}else {
//查询该节点的依赖节点
List<Integer> dependIdByNodeId = nodeDependencyService.findDependIdByNodeId(jobTask.getNodeId());
......
......@@ -200,10 +200,6 @@ public class RunRecordingScanHelper {
private void saveEmailAlarms(RunRecording runRecording) {
//这一步是根据flowId和RunId查询对应的节点信息
/**
* 但是现在疑惑的是 为什么根据工作流id和运行标识就能查询出虚节点的信息呢?
* 理想情况下 主分支工作流上的flowid和runID应该与虚节点一致
*/
List<JobTaskRunLogWithBLOBs> jobTaskRunLogByFlowIdAndRunId = jobTaskRunLogService.findJobTaskRunLogWithBLOBsByFlowIdAndRunId(runRecording.getFlowId(), runRecording.getRunId());
String flowName = runRecording.getFlowName();
String senContentHtml = runMsgHtml(jobTaskRunLogByFlowIdAndRunId, flowName);
......
......@@ -12,6 +12,7 @@ import org.apache.commons.lang3.StringUtils;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
......@@ -31,9 +32,15 @@ public class JobUtils {
* 发布工作流
*/
private static final String REQUEST_FLOW_PUBLISH = "/api/flow/publish";
//创建工作空间
/**
* 创建工作空间
*/
private static final String REQUEST_WORKSPACE_ADD = "/api/workspace/add";
/**
* 暂停工作流
*/
private static final String REQUEST_FLOW_STOP = "/api/flow/stopSchedule";
/**
* 当前项目运行环境 jar file
*/
private static final String OPERATING_ENVIRONMENT_JAR = "jar";
......@@ -64,7 +71,11 @@ public class JobUtils {
return addRequestResult;
}
/**
* 发布一个工作流
* @param pluginPackage
* @return
*/
public static String publish(PluginPackage pluginPackage){
log.info("---------------开始发布工作流,flowName:{}---------------------", pluginPackage.getFlow().getName());
......@@ -72,11 +83,35 @@ public class JobUtils {
String requestUrl = REQUEST_PREFIX + "127.0.0.1" + ":" + "8080" + REQUEST_FLOW_PUBLISH;
//发送请求 添加任务
String addRequestResult = HttpUtil.post(requestUrl, "param=" + JSON.toJSONString(pluginPackage, WriteClassName));
// String addRequestResult = HttpUtil.post(requestUrl, JSON.toJSONString(pluginPackage, WriteClassName));
//String addRequestResult = HttpUtil.post(requestUrl, JSON.toJSONString(pluginPackage, WriteClassName))
log.info("--------------------添加任务完成,添加结果为:{}------------------------",addRequestResult);
return addRequestResult;
}
/**
* 暂停工作流
* @param flowName
* @param workspaceName
* @return
*/
public static String stopFlow(String flowName, String workspaceName){
//请求的路径
String requestUrl = REQUEST_PREFIX + "127.0.0.1" + ":" + "8080" + REQUEST_FLOW_STOP;
Map<String,String> map = new HashMap<>(5);
map.put("flowName",flowName);
map.put("workspaceName",workspaceName);
//发送请求 添加任务
String addRequestResult = HttpUtil.post(requestUrl,"param="+JSON.toJSONString(map,WriteClassName));
//String addRequestResult = HttpUtil.post(requestUrl, JSON.toJSONString(pluginPackage, WriteClassName))
log.info("--------------------暂停成功,结果为:{}------------------------",addRequestResult);
return addRequestResult;
}
/**
* 创建工作空间
* @param workspaceName
* @return
*/
public static String addWorkspace(String workspaceName){
log.info("---------------开始创建工作空间,workspaceName:{}---------------------", workspaceName);
......
package com.byit.job;
import com.byit.utils.JobUtils;
/**
* 暂停工作流的测试
* @author Administrator
*/
public class StopFlowTest {
public static void main(String[] args) {
System.out.println(JobUtils.stopFlow("自动化测试原子弹", "test"));
}
}
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