Commit 52f237d4 by huangfusuper

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

parents 9c9da3b6 a83d1383
......@@ -331,7 +331,7 @@ public class FlowServiceImpl implements FlowService {
ValidationUtil.isTrueValidation(!"0".equals(innerJobTaskRunLog.getRunCode()), "该任务已经运行结束!");
ValidationUtil.dataNotBank(innerJobTaskRunLog.getJobGroupIp(), "尚未分配执行机请稍后再试");
}
if (! killJob(innerJobTaskRunLog.getLogId(), innerJobTaskRunLog.getJobGroupIp())){
if (!killJob(innerJobTaskRunLog.getLogId(), innerJobTaskRunLog.getJobGroupIp())){
result = false;
}
}
......@@ -352,7 +352,7 @@ public class FlowServiceImpl implements FlowService {
@Override
public Boolean killFlow(String runId) throws InterruptedException {
ValidationUtil.dataNotBank(runId, "运行实例不允许3为空!");
ValidationUtil.dataNotBank(runId, "运行实例不允许为空!");
//杀死运行实例
List<RunRecording> runRecordings = runRecordingMapper.findUnFinishByRunId(runId);
ValidationUtil.dataNotNull(runRecordings, "该运行id未找到或已经运行完成无需杀死!");
......@@ -362,7 +362,7 @@ public class FlowServiceImpl implements FlowService {
//杀死所有的任务
List<JobTaskRunLog> jobTaskRunLogList = jobTaskRunLogMapper.findByRunId(runId);
for (JobTaskRunLog jobTaskRunLog : jobTaskRunLogList){
if (!"0".equals(jobTaskRunLog.getRunCode())){
if ("0".equals(jobTaskRunLog.getRunCode())){
if (StringUtils.isEmpty(jobTaskRunLog.getJobGroupIp())){
log.warn("已经调度成功但是还未返回具体的调用机器的ip地址");
Thread.sleep(3000);
......@@ -380,16 +380,15 @@ public class FlowServiceImpl implements FlowService {
private synchronized Boolean killJob(Integer logId, String exectUrl){
//具体访问的URL
String killUrl = exectUrl + "/processManager/killJob";
String killUrl = "http://" + exectUrl + "/myth-executor-server/processManager/killJob";
Map<String, Object> requestMap = new HashMap<>(2);
requestMap.put("logId", logId);
String killResult = HttpUtil.post(killUrl, requestMap);
log.info("请求结果{}", killResult);
ResponseResult responseResult = JSON.parseObject(killResult, ResponseResult.class);
if ("SUCCESS".equals(responseResult.getResult())){
return true;
}
return false;
ValidationUtil.isTrueValidation(!"SUCCESS".equals(responseResult.getResult()), "杀死job失败,错误信息为:" + responseResult.getResult());
return true;
}
}
\ No newline at end of file
......@@ -269,10 +269,8 @@ public class JobUtils {
* @return
*/
public static ResponseResult killFlow(String runId){
Map<String, Object> map = new HashMap<>(2);
map.put("runId", runId);
//发送请求 添加任务
String response = createHttpRequest(REQUEST_FLOW_KILL_FLOW, JSON.toJSONString(map));
String response = createHttpRequest(REQUEST_FLOW_KILL_FLOW, "runId=" + runId);
log.info("--------------------杀死工作流接口调用成功,结果为:{}------------------------",response);
return JSON.parseObject(response, ResponseResult.class);
}
......
......@@ -3,6 +3,7 @@ package com.byit.controller;
import com.byit.process.MythJobProcess;
import com.byit.utils.JobContentUtil;
import com.byit.utils.ValidationUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -14,14 +15,16 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
@RequestMapping("processManager")
@Slf4j
public class ProcessManagerController {
@PostMapping("killJob")
public String killJob(Integer logId){
ValidationUtil.dataNotNull(logId, "日志id不允许为空!");
log.info("请求杀死任务,对应logId:【{}】", logId);
MythJobProcess mythJobProcess = JobContentUtil.getJobThread(logId);
ValidationUtil.dataNotNull(mythJobProcess, logId + "已经运行结束或还未调用!");
mythJobProcess.hardKill();
return "SUCESS";
return "SUCCESS";
}
}
......@@ -224,6 +224,8 @@ public class MythJobProcess implements Callable<String>{
log.error("尝试杀死失败.", e);
}
}
//如果是杀死将退出值改为-100
exitCode = -100;
return false;
}else {
throw new IllegalStateException("程序不在运行中");
......@@ -234,6 +236,7 @@ public class MythJobProcess implements Callable<String>{
* 强制杀死这个过程
*/
public void hardKill() {
log.info("强制杀死这个过程");
//判断是否已经开始运行
checkStarted();
//判断是否正在执行
......@@ -254,6 +257,8 @@ public class MythJobProcess implements Callable<String>{
}
}
this.process.destroy();
//如果是杀死将退出值改为-100
exitCode = -100;
}else {
throw new IllegalStateException("程序不在运行中");
}
......
......@@ -24,3 +24,8 @@ spring:
port: 6379
password:
authentication:
user:
header-name: token
expire: 43200 # 外部token有效期为12小时
pub-key: client/pub.key # 解密
\ No newline at end of file
......@@ -25,4 +25,6 @@ spring:
password:
authentication:
user:
pub-key: "huangfu"
header-name: token
expire: 43200 # 外部token有效期为12小时
pub-key: client/pub.key # 解密
\ No newline at end of file
......@@ -24,3 +24,9 @@ spring:
host: ${Redis_IP}
port: ${Redis_port}
password:
authentication:
user:
header-name: token
expire: 43200 # 外部token有效期为12小时
pub-key: client/pub.key # 解密
\ No newline at end of file
......@@ -24,3 +24,9 @@ spring:
host: ${Redis_IP}
port: ${Redis_port}
password:
authentication:
user:
header-name: token
expire: 43200 # 外部token有效期为12小时
pub-key: client/pub.key # 解密
\ No newline at end of file
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