Commit d50d5567 by huangfusuper

修改立即运行的方式

parent 611892f1
......@@ -70,7 +70,7 @@ public class ApiNodeServiceImpl implements ApiNodeService {
ValidationUtil.dataNotBank(runNode.getNodeId(), "节点id不允许为空!");
String runId = "REAL:EXEC:" + runNode.getNodeId();
ValidationUtil.dataNotBank(runNode.getNodeName(), "节点名称不允许为空!");
ValidationUtil.dataNotBank(runNode.getRunCmd(), "运行命令不允许为空!");
//ValidationUtil.dataNotBank(runNode.getRunCmd(), "运行命令不允许为空!");
ValidationUtil.dataNotBank(runNode.getJobType(), "节点类型不允许为空!");
Long triggerTime = System.currentTimeMillis();
......
......@@ -43,7 +43,6 @@ public class JavaTaskJobTask implements TimerTask {
}
private void runJob(){
String noticeKey = javaTask.getNoticeKey();
RunJavaServiceImpl service = SpringUtil.getBean(RunJavaServiceImpl.class);
PluginRpcRequestPacket request = new PluginRpcRequestPacket();
//保存到日志
......@@ -56,21 +55,12 @@ public class JavaTaskJobTask implements TimerTask {
communicationParam.setLogId(logId+"");
communicationParam.setCallbackUrl(callbackUrl);
communicationParam.setBody(javaTask.getParam());
if(StringUtils.isNoneBlank(noticeKey)) {
communicationParam.setExpand1(noticeKey);
}
request.setParam(communicationParam);
request.setJobName(javaTask.getTaskName());
JobTaskRunLogWithBLOBs log = new JobTaskRunLogWithBLOBs();
log.setLogId(logId);
try {
StringRedisTemplate stringRedisTemplate = (StringRedisTemplate) SpringUtil.getBean("stringRedisTemplate");
if(StringUtils.isNoneBlank(noticeKey)) {
RunLog runLog = RunLog.builder().isEnd(false).runLog("等待服务器分配资源").build();
stringRedisTemplate.opsForList().rightPush(noticeKey , JSON.toJSONString(runLog, WriteClassName));
}
PluginRpcResponsePacket pluginRpcResponsePacket = service.runJava(request);
if(pluginRpcResponsePacket.isStatus()){
log.setTriggerCode(RunResultEnum.TRIGGER_SUCCESS.getCode());
......@@ -79,25 +69,12 @@ public class JavaTaskJobTask implements TimerTask {
}
log.setTriggerMsg(pluginRpcResponsePacket.getMsg());
log.setJobGroupIp(pluginRpcResponsePacket.getRunIp());
//如果需要通知redis
if(StringUtils.isNoneBlank(noticeKey)) {
RunLog runLog = RunLog.builder().isEnd(false).isSuccess(true).runLog("资源分配成功!").build();
stringRedisTemplate.opsForList().rightPush(noticeKey , JSON.toJSONString(runLog, WriteClassName));
}
}catch (Exception e){
log.setTriggerCode(RunResultEnum.TRIGGER_ERROR.getCode());
log.setRunCode(RunResultEnum.RUN_ERROR.getCode());
log.setRunMsg(javaTask.getTaskName()+":"+e.getMessage());
log.setTriggerMsg(javaTask.getTaskName()+":"+e.getMessage());
//如果需要通知redis
if(StringUtils.isNoneBlank(noticeKey)) {
StringRedisTemplate stringRedisTemplate = (StringRedisTemplate) SpringUtil.getBean("stringRedisTemplate");
RunLog runLog = RunLog.builder().isEnd(true).isSuccess(false).runLog("执行资源异常" + javaTask.getTaskName()+":"+e.getMessage()).build();
stringRedisTemplate.opsForList().rightPush(noticeKey , JSON.toJSONString(runLog, WriteClassName));
}
}
JobTaskRunLogServiceImpl jobTaskRunLogService = SpringUtil.getBean(JobTaskRunLogServiceImpl.class);
jobTaskRunLogService.updateJobTaskRunLogWithBLOBs(log);
......@@ -114,7 +91,7 @@ public class JavaTaskJobTask implements TimerTask {
log.setTriggerTime(new Date());
log.setJobType(JAVA_SYNC);
JobTaskRunLogServiceImpl jobTaskRunLogService = SpringUtil.getBean(JobTaskRunLogServiceImpl.class);
int i = jobTaskRunLogService.saveJobTaskRunLog(log);
jobTaskRunLogService.saveJobTaskRunLog(log);
return log.getLogId();
}
}
......@@ -85,10 +85,6 @@ public class JavaTask implements Serializable {
*/
private String jobType;
/**
* 通知主键
*/
private String noticeKey;
/**
*/
......
......@@ -200,11 +200,15 @@ public class JobUtils {
public static void main(String[] args) {
JobUtils.setTOKEN("qqq");
JobUtils.setRequestUrl("http://127.0.0.1:8998/myth-job-admin");
JobStatusDto jobStatusDto = new JobStatusDto();
jobStatusDto.setJobName("sadsasdsa");
JobUtils.findFlowResult(Arrays.asList(jobStatusDto));
JobUtils.setRequestUrl("http://10.0.120.208:8998/myth-job-admin");
JavaTask javaTask = new JavaTask();
javaTask.setTaskName("BaseLineWarnJob");
javaTask.setJobName("BaseLineWarnJob");
t t = new t();
t.setId("0000");
t.setTenant("");
javaTask.setParam(JSON.toJSONString(t));
System.out.println(JobUtils.runTask(javaTask));
}
/**
......@@ -683,6 +687,7 @@ public class JobUtils {
return JSON.parseObject(response, ResponseResult.class);
}
/**
* 获取当前的运行状态
* @param jobNames
......@@ -733,3 +738,23 @@ public class JobUtils {
}
}
class t{
private String tenant;
private String id;
public String getTenant() {
return tenant;
}
public void setTenant(String tenant) {
this.tenant = tenant;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
\ 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