Commit b5f4d2e2 by huangfusuper

JAVA节点支持 日志信息推送

parent a7f371ca
...@@ -208,7 +208,6 @@ public class ApiNodeServiceImpl implements ApiNodeService { ...@@ -208,7 +208,6 @@ public class ApiNodeServiceImpl implements ApiNodeService {
if (null != javaTask.getAlarmlAction() && "0".equals(javaTask.getRepeatCount())){ if (null != javaTask.getAlarmlAction() && "0".equals(javaTask.getRepeatCount())){
ValidationUtil.dataNotBank(javaTask.getAlarmEmail(), "设置为告警时告警邮箱不允许为空"); ValidationUtil.dataNotBank(javaTask.getAlarmEmail(), "设置为告警时告警邮箱不允许为空");
} }
TimerTask timerTask = new JavaTaskJobTask(javaTask); TimerTask timerTask = new JavaTaskJobTask(javaTask);
WorkRoulette.addJob(timerTask, System.currentTimeMillis()); WorkRoulette.addJob(timerTask, System.currentTimeMillis());
} }
......
package com.byit.task; package com.byit.task;
import com.alibaba.fastjson.JSON;
import com.byit.conf.MythJobAutoConfigure; import com.byit.conf.MythJobAutoConfigure;
import com.byit.dto.plugin.JavaTask; import com.byit.dto.plugin.JavaTask;
import com.byit.dto.plugin.RunLog;
import com.byit.enums.NodeRunStatusPropertyEnum; import com.byit.enums.NodeRunStatusPropertyEnum;
import com.byit.enums.ScheduleTypeEnum; import com.byit.enums.ScheduleTypeEnum;
import com.byit.enums.task.RunResultEnum; import com.byit.enums.task.RunResultEnum;
...@@ -15,9 +17,13 @@ import com.byit.util.ServiceInfoUtil; ...@@ -15,9 +17,13 @@ import com.byit.util.ServiceInfoUtil;
import com.byit.util.SpringUtil; import com.byit.util.SpringUtil;
import io.netty.util.Timeout; import io.netty.util.Timeout;
import io.netty.util.TimerTask; import io.netty.util.TimerTask;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.redis.core.StringRedisTemplate;
import java.util.Date; import java.util.Date;
import static com.alibaba.fastjson.serializer.SerializerFeature.WriteClassName;
/** /**
* java节点的执行器 * java节点的执行器
* @author huangfu * @author huangfu
...@@ -37,6 +43,7 @@ public class JavaTaskJobTask implements TimerTask { ...@@ -37,6 +43,7 @@ public class JavaTaskJobTask implements TimerTask {
} }
private void runJob(){ private void runJob(){
String noticeKey = javaTask.getNoticeKey();
RunJavaServiceImpl service = SpringUtil.getBean(RunJavaServiceImpl.class); RunJavaServiceImpl service = SpringUtil.getBean(RunJavaServiceImpl.class);
PluginRpcRequestPacket request = new PluginRpcRequestPacket(); PluginRpcRequestPacket request = new PluginRpcRequestPacket();
//保存到日志 //保存到日志
...@@ -49,6 +56,9 @@ public class JavaTaskJobTask implements TimerTask { ...@@ -49,6 +56,9 @@ public class JavaTaskJobTask implements TimerTask {
communicationParam.setLogId(logId+""); communicationParam.setLogId(logId+"");
communicationParam.setCallbackUrl(callbackUrl); communicationParam.setCallbackUrl(callbackUrl);
communicationParam.setBody(javaTask.getParam()); communicationParam.setBody(javaTask.getParam());
if(StringUtils.isNoneBlank(noticeKey)) {
communicationParam.setExpand1(noticeKey);
}
request.setParam(communicationParam); request.setParam(communicationParam);
request.setJobName(javaTask.getTaskName()); request.setJobName(javaTask.getTaskName());
...@@ -63,11 +73,26 @@ public class JavaTaskJobTask implements TimerTask { ...@@ -63,11 +73,26 @@ public class JavaTaskJobTask implements TimerTask {
} }
log.setTriggerMsg(pluginRpcResponsePacket.getMsg()); log.setTriggerMsg(pluginRpcResponsePacket.getMsg());
log.setJobGroupIp(pluginRpcResponsePacket.getRunIp()); log.setJobGroupIp(pluginRpcResponsePacket.getRunIp());
//如果需要通知redis
if(StringUtils.isNoneBlank(noticeKey)) {
StringRedisTemplate stringRedisTemplate = (StringRedisTemplate) SpringUtil.getBean("stringRedisTemplate");
RunLog runLog = RunLog.builder().isEnd(false).isSuccess(true).runLog("资源调用成功!").build();
stringRedisTemplate.opsForList().rightPush(noticeKey , JSON.toJSONString(runLog, WriteClassName));
}
}catch (Exception e){ }catch (Exception e){
log.setTriggerCode(RunResultEnum.TRIGGER_ERROR.getCode()); log.setTriggerCode(RunResultEnum.TRIGGER_ERROR.getCode());
log.setRunCode(RunResultEnum.RUN_ERROR.getCode()); log.setRunCode(RunResultEnum.RUN_ERROR.getCode());
log.setRunMsg(javaTask.getTaskName()+":"+e.getMessage()); log.setRunMsg(javaTask.getTaskName()+":"+e.getMessage());
log.setTriggerMsg(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); JobTaskRunLogServiceImpl jobTaskRunLogService = SpringUtil.getBean(JobTaskRunLogServiceImpl.class);
jobTaskRunLogService.updateJobTaskRunLogWithBLOBs(log); jobTaskRunLogService.updateJobTaskRunLogWithBLOBs(log);
......
...@@ -86,6 +86,11 @@ public class JavaTask implements Serializable { ...@@ -86,6 +86,11 @@ public class JavaTask implements Serializable {
private String jobType; private String jobType;
/** /**
* 通知主键
*/
private String noticeKey;
/**
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
...@@ -159,7 +159,7 @@ public class JobUtils { ...@@ -159,7 +159,7 @@ public class JobUtils {
*/ */
private static final String REQUEST_LOADSTATUS_JAVATASK = "/api/node/loadCurrentStatusByJobName"; private static final String REQUEST_LOADSTATUS_JAVATASK = "/api/node/loadCurrentStatusByJobName";
private static final String STOP_SCHEDULE_BY_RUNID = "/api/flow/stopScheduleByRunId"; private static final String STOP_SCHEDULE_BY_RUNID = "/api/flow/stopScheduleByRunId";
/** /*J*
* 当前项目运行环境 jar file * 当前项目运行环境 jar file
*/ */
private static final String OPERATING_ENVIRONMENT_JAR = "jar"; private static final String OPERATING_ENVIRONMENT_JAR = "jar";
......
...@@ -22,4 +22,20 @@ public class CommunicationParam implements Serializable { ...@@ -22,4 +22,20 @@ public class CommunicationParam implements Serializable {
* 服务端参数 * 服务端参数
*/ */
private String body; private String body;
/**
* 扩展字段1
*/
private String expand1;
/**
* 扩展字段2
*/
private String expand2;
/**
* 扩展字段3
*/
private String expand3;
/**
* 扩展字段4
*/
private String expand4;
} }
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