Commit 3406bf80 by guominglei

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

parents d9c55ff7 250d9109
...@@ -138,7 +138,6 @@ ...@@ -138,7 +138,6 @@
<overwrite>true</overwrite> <overwrite>true</overwrite>
<skip>false</skip> <skip>false</skip>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
......
...@@ -2,8 +2,13 @@ package com.byit; ...@@ -2,8 +2,13 @@ package com.byit;
import com.byit.annotations.EnablePluginClient; import com.byit.annotations.EnablePluginClient;
import com.byit.rpc.remoting.provider.annotation.RpcService; import com.byit.rpc.remoting.provider.annotation.RpcService;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
/** /**
* @program: byit-myth-job->AdminApplication * @program: byit-myth-job->AdminApplication
...@@ -18,4 +23,21 @@ public class AdminApplication { ...@@ -18,4 +23,21 @@ public class AdminApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(AdminApplication.class,args); SpringApplication.run(AdminApplication.class,args);
} }
private CorsConfiguration corsConfiguration(){
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin("*");
corsConfiguration.addAllowedHeader("*");
corsConfiguration.addAllowedMethod("*");
corsConfiguration.setAllowCredentials(true);
corsConfiguration.setMaxAge(3600L);
return corsConfiguration;
}
@Bean
public CorsFilter corsFilter(){
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**",corsConfiguration());
return new CorsFilter(source);
}
} }
...@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.ParseException; import java.text.ParseException;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @description: 工作流操作的API接口 * @description: 工作流操作的API接口
...@@ -185,4 +186,11 @@ public class ApiFlowController { ...@@ -185,4 +186,11 @@ public class ApiFlowController {
return ResponseResult.ok(collectData); return ResponseResult.ok(collectData);
} }
@PostMapping("/loadCurrentStatus")
@ApiOperation("获取当前的工作流运行状态")
public ResponseResult loadCurrentStatus(String param){
Map<String, RunRecording> statusMap = apiFlowService.loadCurrentStatus(param);
return ResponseResult.ok(statusMap);
}
} }
...@@ -30,6 +30,7 @@ public class ApiNodeController { ...@@ -30,6 +30,7 @@ public class ApiNodeController {
return monitorKey; return monitorKey;
} }
@PostMapping("runHistory") @PostMapping("runHistory")
public ResponseResult runHistory(String nodeId){ public ResponseResult runHistory(String nodeId){
List<JobTaskRunLog> jobTaskRunLogList = apiNodeService.runHistory(nodeId); List<JobTaskRunLog> jobTaskRunLogList = apiNodeService.runHistory(nodeId);
...@@ -84,6 +85,12 @@ public class ApiNodeController { ...@@ -84,6 +85,12 @@ public class ApiNodeController {
return ResponseResult.ok("SUCCESS"); return ResponseResult.ok("SUCCESS");
} }
@PostMapping("runTask")
public ResponseResult runTask(String param){
apiNodeService.runTask(param);
return ResponseResult.ok("SUCCESS");
}
@PostMapping("loadCurrentStatusByJobName") @PostMapping("loadCurrentStatusByJobName")
public ResponseResult loadCurrentStatusByJobName(String jobNames){ public ResponseResult loadCurrentStatusByJobName(String jobNames){
Map<String, JobTaskRunLog> jobTaskRunLogMap = apiNodeService.loadCurrentStatusByJobName(jobNames); Map<String, JobTaskRunLog> jobTaskRunLogMap = apiNodeService.loadCurrentStatusByJobName(jobNames);
......
...@@ -8,7 +8,6 @@ import com.byit.model.JobTask; ...@@ -8,7 +8,6 @@ import com.byit.model.JobTask;
import com.byit.service.JobTaskService; import com.byit.service.JobTaskService;
import com.byit.service.RunScriptService; import com.byit.service.RunScriptService;
import com.byit.thread.LogCallbackThread; import com.byit.thread.LogCallbackThread;
import com.byit.thread.RunRecordingScanHelper;
import com.byit.util.SourceObj2TargetObjUtil; import com.byit.util.SourceObj2TargetObjUtil;
import com.byit.utils.ValidationUtil; import com.byit.utils.ValidationUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -55,8 +54,6 @@ public class JobController { ...@@ -55,8 +54,6 @@ public class JobController {
return jobTaskService.findJobTaskByTriggerNextTimeLessThanEqual(11); return jobTaskService.findJobTaskByTriggerNextTimeLessThanEqual(11);
} }
@Autowired
private RunRecordingScanHelper runRecordingScanThread;
@GetMapping("test") @GetMapping("test")
public DispatchResponseDto test(){ public DispatchResponseDto test(){
DispatchResponseDto dispatchResponseDto = runScriptService.runScript(null); DispatchResponseDto dispatchResponseDto = runScriptService.runScript(null);
......
...@@ -7,6 +7,7 @@ import com.byit.model.vo.RunRecordingVo; ...@@ -7,6 +7,7 @@ import com.byit.model.vo.RunRecordingVo;
import java.text.ParseException; import java.text.ParseException;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @description: 工作流的api请求业务处理接口 * @description: 工作流的api请求业务处理接口
...@@ -95,4 +96,11 @@ public interface ApiFlowService { ...@@ -95,4 +96,11 @@ public interface ApiFlowService {
* @return * @return
*/ */
CollectData loadNodeStatisticData(String param); CollectData loadNodeStatisticData(String param);
/**
* 获取工作流的当前状态
* @param param
* @return
*/
Map<String, RunRecording> loadCurrentStatus(String param);
} }
...@@ -17,6 +17,8 @@ public interface ApiNodeService { ...@@ -17,6 +17,8 @@ public interface ApiNodeService {
*/ */
String runNode(String param); String runNode(String param);
/** /**
* 根据nodeid查询运行历史 * 根据nodeid查询运行历史
* @param nodeId * @param nodeId
...@@ -43,6 +45,13 @@ public interface ApiNodeService { ...@@ -43,6 +45,13 @@ public interface ApiNodeService {
void addJavaTask(String param) throws Exception; void addJavaTask(String param) throws Exception;
/** /**
* 立即运行任务不需要验证是否存在
* @param param
* @throws Exception
*/
void runTask(String param) ;
/**
* 功能描述 更新任务配置信息 * 功能描述 更新任务配置信息
* @author gml * @author gml
* @date 2020-04-14 11:28 * @date 2020-04-14 11:28
......
...@@ -13,6 +13,6 @@ public class TestServiceImpl { ...@@ -13,6 +13,6 @@ public class TestServiceImpl {
public DispatchResponseDto test(){ public DispatchResponseDto test(){
return scriptExecutorService.runPythonScript(null); return scriptExecutorService.runScript(null);
} }
} }
...@@ -137,7 +137,7 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -137,7 +137,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
flow.setWorkspaceId(workspaceId); flow.setWorkspaceId(workspaceId);
flow.setStartUp(FlowPropertyEnum.IS_START.getCode()); flow.setStartUp(FlowPropertyEnum.IS_START.getCode());
flow.setExecType(pluginFlow.getConfig().getExecType()); flow.setExecType(pluginFlow.getConfig().getExecType());
flow.setPriority(pluginFlow.getConfig().getPriority()); flow.setPriority(StringUtils.isEmpty(pluginFlow.getConfig().getPriority()) || !"2".equals(pluginFlow.getConfig().getPriority()) ? "1" : pluginFlow.getConfig().getPriority());
flow.setAlarmlAction(pluginFlow.getConfig().getAlarmlAction()); flow.setAlarmlAction(pluginFlow.getConfig().getAlarmlAction());
flow.setAlarmEmail(pluginFlow.getConfig().getAlarmEmail()); flow.setAlarmEmail(pluginFlow.getConfig().getAlarmEmail());
//设置可执行次数 //设置可执行次数
...@@ -275,7 +275,7 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -275,7 +275,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
node.setTriggerNextTime(StringUtils.isEmpty(((PluginNode)pluginNode).getConfig().getNodeCron()) ? null : new CronExpression(((PluginNode)pluginNode).getConfig().getNodeCron()).getNextValidTimeAfter(new Date()).getTime()); node.setTriggerNextTime(StringUtils.isEmpty(((PluginNode)pluginNode).getConfig().getNodeCron()) ? null : new CronExpression(((PluginNode)pluginNode).getConfig().getNodeCron()).getNextValidTimeAfter(new Date()).getTime());
node.setPluginUrls(((PluginNode)pluginNode).getConfig().getPluginUrls()); node.setPluginUrls(((PluginNode)pluginNode).getConfig().getPluginUrls());
node.setRoutingStrategy(StringUtils.isEmpty(((PluginNode)pluginNode).getConfig().getRoutingStrategy()) ? "RANDOM" : ((PluginNode)pluginNode).getConfig().getRoutingStrategy()); node.setRoutingStrategy(StringUtils.isEmpty(((PluginNode)pluginNode).getConfig().getRoutingStrategy()) ? "RANDOM" : ((PluginNode)pluginNode).getConfig().getRoutingStrategy());
node.setPriority(StringUtils.isEmpty(((PluginNode)pluginNode).getConfig().getPriority()) ? "1" : ((PluginNode)pluginNode).getConfig().getPriority()); node.setPriority(StringUtils.isEmpty(((PluginNode)pluginNode).getConfig().getPriority()) || !"2".equals(((PluginNode)pluginNode).getConfig().getPriority()) ? "1" : ((PluginNode)pluginNode).getConfig().getPriority());
node.setScriptUrls(((PluginNode)pluginNode).getScriptUrls()); node.setScriptUrls(((PluginNode)pluginNode).getScriptUrls());
//设置失败重试 //设置失败重试
if (null != ((PluginNode)pluginNode).getConfig().getFailedRetryCount()){ if (null != ((PluginNode)pluginNode).getConfig().getFailedRetryCount()){
...@@ -893,6 +893,36 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -893,6 +893,36 @@ public class ApiFlowServiceImpl implements ApiFlowService {
return collectData; return collectData;
} }
@Override
public Map<String, RunRecording> loadCurrentStatus(String param) {
ValidationUtil.dataNotBank(param, "请求参数不允许为空!");
JSONObject jsonObject = JSON.parseObject(param);
//获取工作空间名称
String workspaceName = jsonObject.getString("workspaceName");
ValidationUtil.dataNotBank(workspaceName, "工作空间名称不允许为空!");
Workspace workspace = workspaceMapper.getByName(workspaceName);
ValidationUtil.dataNotNull(workspace, workspaceName + "工作空间不存在");
//获取工作流名称
String flowNames = jsonObject.getString("flowNames");
ValidationUtil.dataNotBank(flowNames, "工作流名称不允许为空!");
List<String> flowNameList = Arrays.asList(flowNames.split(","));
List<Flow> flowList = new ArrayList<>();
flowNameList.forEach(flowName->{
Flow flow = flowMapper.getByWorkSpaceAndName(workspace.getWorkspaceId(), flowName);
ValidationUtil.dataNotNull(flow, flowName + "工作流不存在");
flowList.add(flow);
});
Map<String, RunRecording> statusMap = new HashMap<>();
flowList.forEach(flow -> {
RunRecording runRecording = runRecordingMapper.findNewStatus(flow.getFlowId());
statusMap.put(flow.getFlowName(), runRecording);
});
return statusMap;
}
/** /**
* runState 补批机制 1 补批当前节点 2 补批当前节点及以下节点 * runState 补批机制 1 补批当前节点 2 补批当前节点及以下节点
* @param param * @param param
......
...@@ -21,6 +21,7 @@ import com.byit.task.JavaTaskJobTask; ...@@ -21,6 +21,7 @@ import com.byit.task.JavaTaskJobTask;
import com.byit.task.ScriptExecutorJobTask; import com.byit.task.ScriptExecutorJobTask;
import com.byit.utils.ValidationUtil; import com.byit.utils.ValidationUtil;
import io.netty.util.TimerTask; import io.netty.util.TimerTask;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -143,6 +144,23 @@ public class ApiNodeServiceImpl implements ApiNodeService { ...@@ -143,6 +144,23 @@ public class ApiNodeServiceImpl implements ApiNodeService {
} }
@Override @Override
public void runTask(String param) {
ValidationUtil.dataNotBank(param, "请求参数不允许为空!");
JavaTask javaTask = JSON.parseObject(param, JavaTask.class);
ValidationUtil.dataNotBank(javaTask.getTaskName(), "任务实现类的名称不允许为空!");
if(StringUtils.isBlank(javaTask.getJobName())){
javaTask.setJobName(javaTask.getTaskName());
}
javaTask.setTriggerTime(0L);
if (null != javaTask.getAlarmlAction() && "0".equals(javaTask.getRepeatCount())){
ValidationUtil.dataNotBank(javaTask.getAlarmEmail(), "设置为告警时告警邮箱不允许为空");
}
TimerTask timerTask = new JavaTaskJobTask(javaTask);
WorkRoulette.addJob(timerTask, System.currentTimeMillis());
}
@Override
public void updateJavaTask(String param) throws Exception { public void updateJavaTask(String param) throws Exception {
JavaTask javaTask = validate(param); JavaTask javaTask = validate(param);
ValidationUtil.dataNotBank(javaTask.getJobName(), "jobName不允许为空"); ValidationUtil.dataNotBank(javaTask.getJobName(), "jobName不允许为空");
......
package com.byit.view;
import com.byit.model.vo.FlowImportantAllVo;
import com.byit.model.vo.FlowVersionDetailedVo;
import com.byit.model.vo.FlowVersionVo;
import com.byit.service.FlowVersionService;
import com.byit.model.vo.FlowVersionVoDep;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 工作流视图界面
* @author huangfu
*/
@RestController
@RequestMapping("view/flow/version")
public class FlowVersionViewController {
private final FlowVersionService flowVersionService;
public FlowVersionViewController(FlowVersionService flowVersionService) {
this.flowVersionService = flowVersionService;
}
@PostMapping("getAllFlowVersion")
public List<FlowVersionVoDep> getAllFlowVersion(){
return flowVersionService.findAllFlow();
}
@PostMapping("findAllVersion")
public List<FlowVersionVo> findAllVersion(){
return flowVersionService.findAllVersion();
}
@RequestMapping("findAllByFlowId")
public List<FlowVersionDetailedVo> findAllByFlowId(Integer flowId) {
return flowVersionService.findAllByFlowId(flowId);
}
}
package com.byit.view;
import com.byit.model.Flow;
import com.byit.model.vo.FlowImportantAllVo;
import com.byit.model.vo.FlowViewVo;
import com.byit.service.FlowService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 当前运行工作流
* @author huangfu
*/
@RestController
@RequestMapping("view/flow/")
public class FlowViewController {
private final FlowService flowService;
public FlowViewController(FlowService flowService) {
this.flowService = flowService;
}
@PostMapping("findAllThisVersionFlow")
public List<Flow> findAllThisVersionFlow(){
return flowService.findAllFlow();
}
@PostMapping("findAllFlowViewVo")
public List<FlowViewVo> findAllFlowViewVo(){
return flowService.findAllFlowViewVo();
}
/**
* 查询工作流摘要
* @return
*/
@PostMapping("findAllFlowImportant")
public List<FlowImportantAllVo> findAllFlowImportant() {
return flowService.findAllFlowImportant();
}
}
package com.byit.view;
import com.byit.model.NodeVersion;
import com.byit.model.vo.FlowNodeVersionVo;
import com.byit.service.NodeVersionService;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author huangfu
*/
@RestController
@RequestMapping("view/node")
public class NodeVersionViewController {
private final NodeVersionService nodeVersionService;
public NodeVersionViewController(NodeVersionService nodeVersionService) {
this.nodeVersionService = nodeVersionService;
}
@RequestMapping("/getFlowNodeVersionVo")
public List<FlowNodeVersionVo> getFlowNodeVersionVo(){
return nodeVersionService.findAll();
}
@RequestMapping("/findAllNodeVersionByFlowId")
public List<NodeVersion> findAllNodeVersionByFlowId(Integer id){
return nodeVersionService.findAllByFlowId(id);
}
}
package com.byit.view;
import com.byit.model.Node;
import com.byit.service.FlowService;
import com.byit.service.NodeService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author huangfu
*/
@RestController
@RequestMapping("view/node")
public class NodeViewController {
private final NodeService nodeService;
public NodeViewController(NodeService nodeService) {
this.nodeService = nodeService;
}
@RequestMapping("findNodes")
public List<Node> findNodes(Integer flowId){
return nodeService.findNodeByFlowIdAndVersionName(flowId);
}
}
package com.byit.view;
import com.byit.model.vo.RunLogVo;
import com.byit.service.JobTaskRunLogService;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author huangfu
*/
@RestController
@RequestMapping("view/log")
public class RunLogViewController {
private final JobTaskRunLogService jobTaskRunLogService;
public RunLogViewController(JobTaskRunLogService jobTaskRunLogService) {
this.jobTaskRunLogService = jobTaskRunLogService;
}
@RequestMapping("findAllRunLog")
public List<RunLogVo> findAllRunLogIdByFlowIdAndRunId(@Param("flowId") Integer flowId, @Param("runId") String runId){
return jobTaskRunLogService.findAllRunLogIdByFlowIdAndRunId(flowId,runId);
}
}
package com.byit.view;
import com.byit.model.RunRecording;
import com.byit.model.vo.RunRecordingViewVo;
import com.byit.service.RunRecordingService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 运行记录视图查询
* @author huangfu
*/
@RestController
@RequestMapping("view/runRecording")
public class RunRecordingViewController {
private final RunRecordingService runRecordingService;
public RunRecordingViewController(RunRecordingService runRecordingService) {
this.runRecordingService = runRecordingService;
}
@RequestMapping("findAll")
public List<RunRecording> findAll(){
return runRecordingService.findAll();
}
@RequestMapping("findAllRunIng")
public List<RunRecording> findAllRunIng() {
return runRecordingService.findAllRunIng();
}
@RequestMapping("findAllRunRecordingViewVo")
public List<RunRecordingViewVo> findAllRunRecordingViewVo(){
return runRecordingService.findAllRunRecordingViewVo();
}
@RequestMapping("findAllError")
public List<RunRecordingViewVo> findAllError(){
return runRecordingService.findAllError();
}
}
...@@ -32,7 +32,7 @@ mybatis: ...@@ -32,7 +32,7 @@ mybatis:
myth-rpc: myth-rpc:
registry: registry:
address: http://localhost:8080/myth-register address: http://10.0.120.208:8080/myth-register
env: dev env: dev
biz: byit-myth-job biz: byit-myth-job
logging: logging:
...@@ -54,6 +54,14 @@ myth-job: ...@@ -54,6 +54,14 @@ myth-job:
filestystem: FASTDFS filestystem: FASTDFS
snapshoot-date: 60 #快照的保存时间 单位天 snapshoot-date: 60 #快照的保存时间 单位天
fdfs:
so-timeout: 1500
connect-timeout: 600
pool:
jmx-enabled: false
tracker-list:
- 10.0.120.2:22122
myth: myth:
plugin: plugin:
env: ${myth-rpc.registry.env} env: ${myth-rpc.registry.env}
......
...@@ -57,6 +57,13 @@ file: ...@@ -57,6 +57,13 @@ file:
myth-job: myth-job:
filestystem: FASTDFS filestystem: FASTDFS
snapshoot-date: 60 #快照的保存时间 单位天 snapshoot-date: 60 #快照的保存时间 单位天
fdfs:
so-timeout: 1500
connect-timeout: 600
pool:
jmx-enabled: false
tracker-list:
- 10.0.120.2:22122
myth: myth:
plugin: plugin:
......
spring: spring:
datasource: datasource:
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://${CM_IP}/myth-job?Unicode=true&characterEncoding=UTF-8&useSSL=true url: jdbc:mysql://10.0.120.30:3307/myth-job?Unicode=true&characterEncoding=UTF-8&useSSL=true
username: ${CM_USER} username: root
password: ${CM_PWD} password: root
redis: redis:
database: 0 database: 0
host: ${Redis_IP} host: 10.0.120.208
port: ${Redis_port} port: 6379
password: password:
timeout: 3000 timeout: 3000
pool: pool:
...@@ -31,7 +31,7 @@ mybatis: ...@@ -31,7 +31,7 @@ mybatis:
myth-rpc: myth-rpc:
registry: registry:
address: http://${Eureka_IP}/myth-register address: http://10.0.120.208:8080/myth-register
env: pro env: pro
biz: byit-myth-job biz: byit-myth-job
logging: logging:
...@@ -51,4 +51,14 @@ file: ...@@ -51,4 +51,14 @@ file:
myth-job: myth-job:
filestystem: FASTDFS filestystem: FASTDFS
snapshoot-date: 60 #快照的保存时间 单位天 snapshoot-date: 60 #快照的保存时间 单位天
\ No newline at end of file
fdfs:
so-timeout: 1500
connect-timeout: 600
pool:
jmx-enabled: false
tracker-list:
- 10.0.120.216:22122
- 10.0.120.217:22122
- 10.0.120.218:22122
\ No newline at end of file
...@@ -52,4 +52,20 @@ file: ...@@ -52,4 +52,20 @@ file:
myth-job: myth-job:
filestystem: FASTDFS filestystem: FASTDFS
snapshoot-date: 60 #快照的保存时间 单位天 snapshoot-date: 60 #快照的保存时间 单位天
\ No newline at end of file
fdfs:
so-timeout: 1500
connect-timeout: 600
pool:
jmx-enabled: false
tracker-list:
- 10.0.120.216:22122
- 10.0.120.217:22122
- 10.0.120.218:22122
myth:
plugin:
env: ${myth-rpc.registry.env}
biz: ${myth-rpc.registry.biz}
register:
url: ${myth-rpc.registry.address}
\ No newline at end of file
...@@ -21,15 +21,6 @@ import java.util.Map; ...@@ -21,15 +21,6 @@ import java.util.Map;
@Slf4j @Slf4j
public class MythJobScheduler implements InitializingBean, DisposableBean { public class MythJobScheduler implements InitializingBean, DisposableBean {
/**
* private final JobScheduleHelper jobScheduleHelper
* private final EmailScanHelper emailScanHelper
* private final FlowScanHelper flowScanHelper
* private final LogScanHelper logScanHelper
* private final RunRecordingScanHelper runRecordingScanHelper
*/
private final ApplicationContext applicationContext; private final ApplicationContext applicationContext;
......
...@@ -5,8 +5,8 @@ package com.byit.enums; ...@@ -5,8 +5,8 @@ package com.byit.enums;
*/ */
public enum EmailEnum { public enum EmailEnum {
IS_ALARM_YES("0","已经告警"), IS_ALARM_YES("1","已经告警"),
IS_ALARM_NO("1","没有告警") IS_ALARM_NO("0","没有告警")
; ;
private String code; private String code;
private String msg; private String msg;
......
...@@ -27,7 +27,7 @@ public class WorkRoulette { ...@@ -27,7 +27,7 @@ public class WorkRoulette {
public static void addJob(TimerTask timerTask,long triggerNextTime) { public static void addJob(TimerTask timerTask,long triggerNextTime) {
log.info("-----添加任务{}-------",((JavaTaskJobTask)timerTask).getJavaTask().getTaskName()); //log.info("-----添加任务{}-------",((JavaTaskJobTask)timerTask).getJavaTask().getTaskName());
HASHED_WHEEL_TIMER.newTimeout(timerTask, TimeUnit.MILLISECONDS.toNanos(triggerNextTime-System.currentTimeMillis()), TimeUnit.NANOSECONDS); HASHED_WHEEL_TIMER.newTimeout(timerTask, TimeUnit.MILLISECONDS.toNanos(triggerNextTime-System.currentTimeMillis()), TimeUnit.NANOSECONDS);
} }
......
...@@ -6,7 +6,11 @@ import org.apache.ibatis.annotations.Param; ...@@ -6,7 +6,11 @@ import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
public interface FlowMapper { public interface FlowMapper {
/**
* 查询全部的任务流数据
* @return
*/
List<Flow> findAllFlow();
/** /**
* 根据ID查询 * 根据ID查询
* @param id * @param id
...@@ -54,4 +58,5 @@ public interface FlowMapper { ...@@ -54,4 +58,5 @@ public interface FlowMapper {
* @return * @return
*/ */
List<Flow> findAll(); List<Flow> findAll();
} }
\ No newline at end of file
package com.byit.mapper; package com.byit.mapper;
import com.byit.model.FlowVersion; import com.byit.model.FlowVersion;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface FlowVersionMapper { public interface FlowVersionMapper {
List<FlowVersion> findAllByFlowId(Integer flowId);
/**
* 查询全部的工作流
* @return
*/
List<FlowVersion> findAllFlow();
int deleteById(Integer flowVersionId); int deleteById(Integer flowVersionId);
int insertSelective(FlowVersion record); int insertSelective(FlowVersion record);
......
package com.byit.mapper; package com.byit.mapper;
import com.byit.model.NodeVersion; import com.byit.model.NodeVersion;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface NodeVersionMapper { public interface NodeVersionMapper {
/**
* 查询全部数据 根据工作里ID
* @param flowId
* @return
*/
List<NodeVersion> findAllByFlowId(Integer flowId);
/**
* 查询全部的节点版本
* @return
*/
List<NodeVersion> findAll();
int deleteById(Integer nodeVersionId); int deleteById(Integer nodeVersionId);
int insertSelective(NodeVersion record); int insertSelective(NodeVersion record);
......
...@@ -15,6 +15,23 @@ import java.util.List; ...@@ -15,6 +15,23 @@ import java.util.List;
@Repository @Repository
public interface RunRecordingMapper { public interface RunRecordingMapper {
/** /**
* 查询全部的数据
* @return
*/
List<RunRecording> findAll();
/**
* 查询全部错误的节点
* @return
*/
List<RunRecording> findAllError();
/**
* 查询运行中的数据
* @return
*/
List<RunRecording> findAllRunIng();
/**
* 查询已经完结的,并且没有告警的任务流 * 查询已经完结的,并且没有告警的任务流
* @return * @return
*/ */
...@@ -180,4 +197,11 @@ public interface RunRecordingMapper { ...@@ -180,4 +197,11 @@ public interface RunRecordingMapper {
* @return * @return
*/ */
List<RunRecording> findByPreTime(@Param("preHourDate")Date preHourDate, @Param("flowId")Integer flowId); List<RunRecording> findByPreTime(@Param("preHourDate")Date preHourDate, @Param("flowId")Integer flowId);
/**
* 根据flowid获取最新的运行实例
* @param flowId
* @return
*/
RunRecording findNewStatus(Integer flowId);
} }
\ No newline at end of file
...@@ -124,7 +124,7 @@ public class RunRecording implements Serializable { ...@@ -124,7 +124,7 @@ public class RunRecording implements Serializable {
/** /**
* 是否是内嵌工作流 0 否, 1 是 * 是否是内嵌工作流 0 否, 1 是
*/ */
@ApiModelProperty("是否是内嵌工作流 0 否, 1 是") @ApiModelProperty("是否是内嵌工作流 1 否, 0 是")
private String isInner; private String isInner;
/** /**
......
package com.byit.model.vo;
import lombok.Data;
/**
* 版本管理 使用的vo
* @author huangfu
*/
@Data
public class FlowImportantAllVo {
private String rowKey;
private String flowName;
private Integer flowId;
private boolean hasChildren;
}
package com.byit.model.vo;
import com.byit.model.NodeVersion;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 工作流对应节点版本的工作流
* @author huangfu
*/
@Data
@ApiModel("工作流对应节点版本的工作流")
@Deprecated
public class FlowNodeVersionVo {
@ApiModelProperty("工作流名称")
private String flowName;
@ApiModelProperty("版本名称")
private String versionName;
@ApiModelProperty("对应的节点的集合")
private List<NodeVersion> nodeVersions;
}
package com.byit.model.vo;
import com.byit.model.FlowVersion;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
*
* @author huangfu
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class FlowVersionDetailedVo extends FlowVersion {
private String rowKey;
}
package com.byit.model.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 工作流版本名称
* @author huangfu
*/
@Data
@ApiModel("工作流版本名称")
public class FlowVersionVo {
@ApiModelProperty("ROW-KEY VUE使用")
private String nodeId;
@ApiModelProperty("工作流版本呢的id")
private Integer flowVersionId;
@ApiModelProperty("工作流名称")
private String flowName;
@ApiModelProperty("工作流版本名称")
private String versionName;
@ApiModelProperty("是否存在节点")
private boolean hasChildren;
}
package com.byit.model.vo;
import com.byit.model.FlowVersion;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 工作流版本的视图载体
* @author huangfu
* Search {@link FlowVersionVo}
*/
@ApiModel("工作流版本的视图载体")
@Data
@Deprecated
public class FlowVersionVoDep implements Serializable {
/**
* 工作流名字
*/
@ApiModelProperty("工作流的名字")
private String flowName;
/**
* 对应的版本
*/
@ApiModelProperty("对应的工作流的所由版本")
private List<FlowVersion> children;
}
package com.byit.model.vo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 工作流视图的试图映射
* @author huangfu
*/
@Data
@ApiModel("工作流视图的试图映射")
public class FlowViewVo {
@ApiModelProperty("row-key vue使用")
private String nodeId;
@ApiModelProperty("工作流id")
private Integer flowId;
@ApiModelProperty("工作流名字")
private String flowName;
@ApiModelProperty("版本名称")
private String versionName;
@ApiModelProperty("是否存在节点")
private boolean hasChildren;
}
package com.byit.model.vo;
import lombok.Data;
import java.util.Date;
/**
* @author huangfu
*/
@Data
public class RunLogVo {
private String rowKey;
private String nodeName;
private String jobType;
private Integer failedRemainingCount;
private String isVirtual;
private Integer mapFlowId;
private String triggerCode;
private String triggerMsg;
private String runCode;
private String runMsg;
private Date triggerTime;
private String jobGroupIp;
private Date startTime;
private Date endTime;
private String logRemotelyPath;
private String scriptUrls;
private Integer scheduleType;
private String operator;
private boolean hasTrigger;
}
package com.byit.model.vo;
import lombok.Data;
/**
* 运行实例
* @author huangfu
*/
@Data
public class RunRecordingViewVo {
private String rowKey;
private Integer flowId;
private String runId;
private String flowName;
private String flowVersionName;
private String flowStatus;
private String flowRunResult;
private boolean hasChildren;
}
package com.byit.service; package com.byit.service;
import com.byit.model.Flow; import com.byit.model.Flow;
import com.byit.model.vo.FlowImportantAllVo;
import com.byit.model.vo.FlowViewVo;
import com.byit.model.vo.FlowVo; import com.byit.model.vo.FlowVo;
import com.byit.model.vo.NodeVo; import com.byit.model.vo.NodeVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -13,6 +15,19 @@ import java.util.List; ...@@ -13,6 +15,19 @@ import java.util.List;
* @create: 2019-12-23 17:33 * @create: 2019-12-23 17:33
*/ */
public interface FlowService { public interface FlowService {
/**
* 查询全部的任务流数据
* @return
*/
List<FlowViewVo> findAllFlowViewVo();
List<FlowImportantAllVo> findAllFlowImportant();
/**
* 查询全部的任务流数据
* @return
*/
List<Flow> findAllFlow();
/** /**
* 根据ID查询 * 根据ID查询
* @param id * @param id
......
package com.byit.service;
import com.byit.model.FlowVersion;
import com.byit.model.vo.FlowImportantAllVo;
import com.byit.model.vo.FlowVersionDetailedVo;
import com.byit.model.vo.FlowVersionVo;
import com.byit.model.vo.FlowVersionVoDep;
import java.util.List;
/**
* @author huangfu
*/
public interface FlowVersionService {
/**
* 查询全部的工作流
* @return
*/
List<FlowVersionVoDep> findAllFlow();
/**
* 查询全部的工作流
* @return
*/
List<FlowVersionVo> findAllVersion();
List<FlowVersionDetailedVo> findAllByFlowId(Integer flowId);
}
...@@ -2,6 +2,7 @@ package com.byit.service; ...@@ -2,6 +2,7 @@ package com.byit.service;
import com.byit.model.JobTaskRunLog; import com.byit.model.JobTaskRunLog;
import com.byit.model.JobTaskRunLogWithBLOBs; import com.byit.model.JobTaskRunLogWithBLOBs;
import com.byit.model.vo.RunLogVo;
import java.util.List; import java.util.List;
...@@ -13,6 +14,8 @@ import java.util.List; ...@@ -13,6 +14,8 @@ import java.util.List;
**/ **/
public interface JobTaskRunLogService { public interface JobTaskRunLogService {
/** /**
* 查询没有结束的节点 * 查询没有结束的节点
* @param nodIds * @param nodIds
...@@ -33,6 +36,15 @@ public interface JobTaskRunLogService { ...@@ -33,6 +36,15 @@ public interface JobTaskRunLogService {
* @return * @return
*/ */
List<JobTaskRunLogWithBLOBs> findJobTaskRunLogWithBLOBsByFlowIdAndRunId(Integer flowId,String runId); List<JobTaskRunLogWithBLOBs> findJobTaskRunLogWithBLOBsByFlowIdAndRunId(Integer flowId,String runId);
/**
* 根据工作流id和日志ID
* @param flowId
* @param runId
* @return
*/
List<RunLogVo> findAllRunLogIdByFlowIdAndRunId(Integer flowId,String runId);
/** /**
* 查询已经结束或者失败的节点 * 查询已经结束或者失败的节点
* @return * @return
......
package com.byit.service;
import com.byit.model.NodeVersion;
import com.byit.model.vo.FlowNodeVersionVo;
import java.util.List;
/**
* 节点版本的业务
* @author huangfu
*/
public interface NodeVersionService {
/**
* 查询全部的节点版本
* @return 全部
*/
List<FlowNodeVersionVo> findAll();
/**
* 查询全部数据 根据工作里ID
* @param flowId
* @return
*/
List<NodeVersion> findAllByFlowId(Integer flowId);
}
package com.byit.service; package com.byit.service;
import com.byit.model.RunRecording; import com.byit.model.RunRecording;
import com.byit.model.vo.RunRecordingViewVo;
import java.util.List; import java.util.List;
...@@ -10,6 +11,28 @@ import java.util.List; ...@@ -10,6 +11,28 @@ import java.util.List;
*/ */
public interface RunRecordingService { public interface RunRecordingService {
/** /**
* 查询全部数据 映射成VO
* @return
*/
List<RunRecordingViewVo> findAllRunRecordingViewVo();
/**
* 查询全部的数据
* @return
*/
List<RunRecording> findAll();
/**
* 查询全部错误的节点
* @return
*/
List<RunRecordingViewVo> findAllError();
/**
* 查询运行中的数据
* @return
*/
List<RunRecording> findAllRunIng();
/**
* 查询已经完结的,并且没有告警的任务流 * 查询已经完结的,并且没有告警的任务流
* @return * @return
*/ */
......
...@@ -10,6 +10,8 @@ import com.byit.enums.NodePropertyEnum; ...@@ -10,6 +10,8 @@ import com.byit.enums.NodePropertyEnum;
import com.byit.job.utils.CronExpression; import com.byit.job.utils.CronExpression;
import com.byit.mapper.*; import com.byit.mapper.*;
import com.byit.model.*; import com.byit.model.*;
import com.byit.model.vo.FlowImportantAllVo;
import com.byit.model.vo.FlowViewVo;
import com.byit.model.vo.FlowVo; import com.byit.model.vo.FlowVo;
import com.byit.model.vo.NodeVo; import com.byit.model.vo.NodeVo;
import com.byit.service.FlowService; import com.byit.service.FlowService;
...@@ -23,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -23,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* @description: 工作流业务逻辑实现类 * @description: 工作流业务逻辑实现类
...@@ -49,6 +52,39 @@ public class FlowServiceImpl implements FlowService { ...@@ -49,6 +52,39 @@ public class FlowServiceImpl implements FlowService {
@Resource @Resource
private WorkspaceMapper workspaceMapper; private WorkspaceMapper workspaceMapper;
@Override
public List<FlowViewVo> findAllFlowViewVo() {
List<Flow> allFlow = findAllFlow();
return allFlow.stream().map(flow -> {
FlowViewVo flowViewVo = new FlowViewVo();
flowViewVo.setFlowId(flow.getFlowId());
flowViewVo.setFlowName(flow.getFlowName());
flowViewVo.setNodeId(UUID.randomUUID().toString().replace("", "-"));
flowViewVo.setVersionName(flow.getVersionName());
flowViewVo.setHasChildren(true);
return flowViewVo;
}).collect(Collectors.toList());
}
@Override
public List<FlowImportantAllVo> findAllFlowImportant() {
List<Flow> all = flowMapper.findAll();
return all.stream().map(flow -> {
FlowImportantAllVo flowImportantAllVo = new FlowImportantAllVo();
flowImportantAllVo.setRowKey(UUID.randomUUID().toString().replace("-",""));
flowImportantAllVo.setHasChildren(true);
flowImportantAllVo.setFlowName(flow.getFlowName());
flowImportantAllVo.setFlowId(flow.getFlowId());
return flowImportantAllVo;
}).collect(Collectors.toList());
}
@Override
public List<Flow> findAllFlow() {
return flowMapper.findAll();
}
@Override @Override
public Flow findFlowById(Integer id) { public Flow findFlowById(Integer id) {
return flowMapper.getById(id); return flowMapper.getById(id);
......
package com.byit.service.impl;
import cn.hutool.core.util.IdcardUtil;
import com.byit.mapper.FlowVersionMapper;
import com.byit.model.FlowVersion;
import com.byit.model.vo.FlowImportantAllVo;
import com.byit.model.vo.FlowVersionDetailedVo;
import com.byit.model.vo.FlowVersionVo;
import com.byit.service.FlowVersionService;
import com.byit.model.vo.FlowVersionVoDep;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 工作流版本业务的实现
* @author huangfu
*/
@Service
public class FlowVersionServiceImpl implements FlowVersionService {
private final FlowVersionMapper flowVersionMapper;
public FlowVersionServiceImpl(FlowVersionMapper flowVersionMapper) {
this.flowVersionMapper = flowVersionMapper;
}
@Override
public List<FlowVersionVoDep> findAllFlow() {
List<FlowVersion> allFlow = flowVersionMapper.findAllFlow();
Map<String, List<FlowVersion>> versionColl = allFlow.stream().collect(Collectors.groupingBy(FlowVersion::getFlowName));
List<FlowVersionVoDep> flowVersionVoDeps = new ArrayList<>();
versionColl.forEach((key,value) ->{
FlowVersionVoDep flowVersionVoDep = new FlowVersionVoDep();
flowVersionVoDep.setFlowName(key);
flowVersionVoDep.setChildren(value);
flowVersionVoDeps.add(flowVersionVoDep);
});
return flowVersionVoDeps;
}
@Override
public List<FlowVersionVo> findAllVersion() {
List<FlowVersion> allFlow = flowVersionMapper.findAllFlow();
return allFlow.stream().map(flowVersion -> {
FlowVersionVo flowVersionVo = new FlowVersionVo();
flowVersionVo.setNodeId(UUID.randomUUID().toString().replace("-",""));
flowVersionVo.setFlowVersionId(flowVersion.getFlowVersionId());
flowVersionVo.setFlowName(flowVersion.getFlowName());
flowVersionVo.setVersionName(flowVersion.getVersionName());
flowVersionVo.setHasChildren(true);
return flowVersionVo;
}).collect(Collectors.toList());
}
@Override
public List<FlowVersionDetailedVo> findAllByFlowId(Integer flowId) {
List<FlowVersion> allByFlowId = flowVersionMapper.findAllByFlowId(flowId);
return allByFlowId.stream().map(e ->{
FlowVersionDetailedVo flowVersionDetailedVo = new FlowVersionDetailedVo();
flowVersionDetailedVo.setRowKey(UUID.randomUUID().toString().replace("-",""));
BeanUtils.copyProperties(e,flowVersionDetailedVo);
return flowVersionDetailedVo;
}).collect(Collectors.toList());
}
}
package com.byit.service.impl; package com.byit.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.byit.mapper.JobTaskRunLogMapper; import com.byit.mapper.JobTaskRunLogMapper;
import com.byit.model.JobTask;
import com.byit.model.JobTaskRunLog; import com.byit.model.JobTaskRunLog;
import com.byit.model.JobTaskRunLogWithBLOBs; import com.byit.model.JobTaskRunLogWithBLOBs;
import com.byit.model.vo.RunLogVo;
import com.byit.service.JobTaskRunLogService; import com.byit.service.JobTaskRunLogService;
import com.byit.service.JobTaskService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
/** /**
* @program: byit-myth-job->JobTaskRunLogServiceImpl * @program: byit-myth-job->JobTaskRunLogServiceImpl
...@@ -24,10 +32,12 @@ import java.util.List; ...@@ -24,10 +32,12 @@ import java.util.List;
public class JobTaskRunLogServiceImpl implements JobTaskRunLogService { public class JobTaskRunLogServiceImpl implements JobTaskRunLogService {
private final JobTaskRunLogMapper jobTaskRunLogMapper; private final JobTaskRunLogMapper jobTaskRunLogMapper;
private final JobTaskService jobTaskService;
@Autowired @Autowired
public JobTaskRunLogServiceImpl(JobTaskRunLogMapper jobTaskRunLogMapper) { public JobTaskRunLogServiceImpl(JobTaskRunLogMapper jobTaskRunLogMapper, JobTaskService jobTaskService) {
this.jobTaskRunLogMapper = jobTaskRunLogMapper; this.jobTaskRunLogMapper = jobTaskRunLogMapper;
this.jobTaskService = jobTaskService;
} }
@Override @Override
...@@ -46,6 +56,27 @@ public class JobTaskRunLogServiceImpl implements JobTaskRunLogService { ...@@ -46,6 +56,27 @@ public class JobTaskRunLogServiceImpl implements JobTaskRunLogService {
} }
@Override @Override
public List<RunLogVo> findAllRunLogIdByFlowIdAndRunId(Integer flowId, String runId) {
List<JobTaskRunLogWithBLOBs> jobTaskRunLogWithBLOBsByFlowIdAndRunId = jobTaskRunLogMapper.findJobTaskRunLogWithBLOBsByFlowIdAndRunId(flowId, runId);
List<RunLogVo> collect = jobTaskRunLogWithBLOBsByFlowIdAndRunId.stream().map(log -> {
RunLogVo runLogVo = new RunLogVo();
runLogVo.setHasTrigger(true);
runLogVo.setRowKey(UUID.randomUUID().toString().replace("-", ""));
BeanUtils.copyProperties(log, runLogVo);
return runLogVo;
}).collect(Collectors.toList());
//这个是还未运行的信息
List<JobTask> jobTaskByRunId = jobTaskService.findJobTaskByRunId(runId, flowId);
jobTaskByRunId.forEach(jobTask -> {
RunLogVo runLogVo = new RunLogVo();
runLogVo.setHasTrigger(false);
runLogVo.setRowKey(UUID.randomUUID().toString().replace("-",""));
collect.add(runLogVo);
});
return collect;
}
@Override
public List<JobTaskRunLog> findJobTaskRunLogEndOrFailureNode() { public List<JobTaskRunLog> findJobTaskRunLogEndOrFailureNode() {
return jobTaskRunLogMapper.findJobTaskRunLogEndOrFailureNode(); return jobTaskRunLogMapper.findJobTaskRunLogEndOrFailureNode();
} }
......
package com.byit.service.impl;
import com.byit.mapper.FlowVersionMapper;
import com.byit.mapper.NodeVersionMapper;
import com.byit.model.FlowVersion;
import com.byit.model.NodeVersion;
import com.byit.model.vo.FlowNodeVersionVo;
import com.byit.service.FlowVersionService;
import com.byit.service.NodeVersionService;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* 节点版本的业务
* @author huangfu
*/
@Service
public class NodeVersionServiceImpl implements NodeVersionService {
private final NodeVersionMapper nodeVersionMapper;
private final FlowVersionMapper flowVersionMapper;
public NodeVersionServiceImpl(NodeVersionMapper nodeVersionMapper, FlowVersionMapper flowVersionMapper) {
this.nodeVersionMapper = nodeVersionMapper;
this.flowVersionMapper = flowVersionMapper;
}
@Override
public List<FlowNodeVersionVo> findAll() {
List<FlowNodeVersionVo> flowNodeVersionVos = new ArrayList<>();
List<NodeVersion> nodeVersionMapperAll = nodeVersionMapper.findAll();
List<FlowVersion> allFlow = flowVersionMapper.findAllFlow();
allFlow.forEach(flow ->{
FlowNodeVersionVo flowNodeVersionVo = new FlowNodeVersionVo();
flowNodeVersionVo.setFlowName(flow.getFlowName());
flowNodeVersionVo.setVersionName(flow.getVersionName());
List<NodeVersion> nodeVersions = nodeVersionMapperAll.stream()
.filter(nodeVersion -> flow.getFlowId().equals(nodeVersion.getFlowId()))
.collect(Collectors.toList());
flowNodeVersionVo.setNodeVersions(nodeVersions);
flowNodeVersionVos.add(flowNodeVersionVo);
});
return flowNodeVersionVos;
}
@Override
public List<NodeVersion> findAllByFlowId(Integer flowId) {
return nodeVersionMapper.findAllByFlowId(flowId);
}
}
...@@ -3,11 +3,15 @@ package com.byit.service.impl; ...@@ -3,11 +3,15 @@ package com.byit.service.impl;
import com.byit.enums.RunRecordingEnum; import com.byit.enums.RunRecordingEnum;
import com.byit.mapper.RunRecordingMapper; import com.byit.mapper.RunRecordingMapper;
import com.byit.model.RunRecording; import com.byit.model.RunRecording;
import com.byit.model.vo.RunRecordingViewVo;
import com.byit.service.RunRecordingService; import com.byit.service.RunRecordingService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
/** /**
* @program: byit-myth-job->RunRecordingServiceImpl * @program: byit-myth-job->RunRecordingServiceImpl
...@@ -25,6 +29,40 @@ public class RunRecordingServiceImpl implements RunRecordingService { ...@@ -25,6 +29,40 @@ public class RunRecordingServiceImpl implements RunRecordingService {
} }
@Override @Override
public List<RunRecordingViewVo> findAllRunRecordingViewVo() {
List<RunRecording> runRecordings = findAll();
return runRecordings.stream().map(runRecording -> {
RunRecordingViewVo runRecordingViewVo = new RunRecordingViewVo();
runRecordingViewVo.setHasChildren(true);
BeanUtils.copyProperties(runRecording,runRecordingViewVo);
runRecordingViewVo.setRowKey(UUID.randomUUID().toString().replace("-",""));
return runRecordingViewVo;
}).collect(Collectors.toList());
}
@Override
public List<RunRecording> findAll() {
return runRecordingMapper.findAll();
}
@Override
public List<RunRecordingViewVo> findAllError() {
List<RunRecording> allError = runRecordingMapper.findAllError();
return allError.stream().map(runRecording -> {
RunRecordingViewVo runRecordingViewVo = new RunRecordingViewVo();
runRecordingViewVo.setHasChildren(true);
BeanUtils.copyProperties(runRecording,runRecordingViewVo);
runRecordingViewVo.setRowKey(UUID.randomUUID().toString().replace("-",""));
return runRecordingViewVo;
}).collect(Collectors.toList());
}
@Override
public List<RunRecording> findAllRunIng() {
return runRecordingMapper.findAllRunIng();
}
@Override
public List<RunRecording> findRunRecordingByEndAndNotIsAlarm() { public List<RunRecording> findRunRecordingByEndAndNotIsAlarm() {
return runRecordingMapper.findRunRecordingByEndAndNotIsAlarm(); return runRecordingMapper.findRunRecordingByEndAndNotIsAlarm();
} }
......
...@@ -16,6 +16,6 @@ public class RunScriptServiceImpl implements RunScriptService { ...@@ -16,6 +16,6 @@ public class RunScriptServiceImpl implements RunScriptService {
private ScriptExecutorService scriptExecutorService; private ScriptExecutorService scriptExecutorService;
@Override @Override
public DispatchResponseDto runScript(ScriptDto scriptDto) { public DispatchResponseDto runScript(ScriptDto scriptDto) {
return scriptExecutorService.runPythonScript(scriptDto); return scriptExecutorService.runScript(scriptDto);
} }
} }
...@@ -12,7 +12,6 @@ import com.byit.service.RunRecordingService; ...@@ -12,7 +12,6 @@ import com.byit.service.RunRecordingService;
import com.byit.service.mapservice.RunRecordingAndEmailService; import com.byit.service.mapservice.RunRecordingAndEmailService;
import com.byit.util.TimeFormatUtil; import com.byit.util.TimeFormatUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.csource.common.MyException;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.IOException; import java.io.IOException;
...@@ -108,7 +107,7 @@ public class RunRecordingAndEmailServiceImpl implements RunRecordingAndEmailServ ...@@ -108,7 +107,7 @@ public class RunRecordingAndEmailServiceImpl implements RunRecordingAndEmailServ
if(null != jobTaskRunLog.getLogRemotelyPath()){ if(null != jobTaskRunLog.getLogRemotelyPath()){
logStr = new String(fileSystem.downloaderFile(jobTaskRunLog.getLogRemotelyPath()), StandardCharsets.UTF_8); logStr = new String(fileSystem.downloaderFile(jobTaskRunLog.getLogRemotelyPath()), StandardCharsets.UTF_8);
} }
} catch (IOException | MyException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
stringBuilder.append("<tr align='center'>") stringBuilder.append("<tr align='center'>")
......
...@@ -4,6 +4,7 @@ import com.byit.conf.MythJobAutoConfigure; ...@@ -4,6 +4,7 @@ import com.byit.conf.MythJobAutoConfigure;
import com.byit.dto.plugin.JavaTask; import com.byit.dto.plugin.JavaTask;
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.model.JobTaskRunLogWithBLOBs; import com.byit.model.JobTaskRunLogWithBLOBs;
import com.byit.packet.request.PluginRpcRequestPacket; import com.byit.packet.request.PluginRpcRequestPacket;
import com.byit.packet.response.PluginRpcResponsePacket; import com.byit.packet.response.PluginRpcResponsePacket;
...@@ -22,6 +23,7 @@ import java.util.Date; ...@@ -22,6 +23,7 @@ import java.util.Date;
* @author huangfu * @author huangfu
*/ */
public class JavaTaskJobTask implements TimerTask { public class JavaTaskJobTask implements TimerTask {
public static final String JAVA_SYNC = "JAVA_SYNC";
private final JavaTask javaTask; private final JavaTask javaTask;
public JavaTaskJobTask(JavaTask javaTask) { public JavaTaskJobTask(JavaTask javaTask) {
...@@ -29,7 +31,7 @@ public class JavaTaskJobTask implements TimerTask { ...@@ -29,7 +31,7 @@ public class JavaTaskJobTask implements TimerTask {
} }
@Override @Override
public void run(Timeout timeout) throws Exception { public void run(Timeout timeout) {
MythJobAutoConfigure.LOW_LEVEL_JOB_THREAD_POOL.execute(this::runJob); MythJobAutoConfigure.LOW_LEVEL_JOB_THREAD_POOL.execute(this::runJob);
} }
...@@ -55,15 +57,14 @@ public class JavaTaskJobTask implements TimerTask { ...@@ -55,15 +57,14 @@ public class JavaTaskJobTask implements TimerTask {
try { try {
PluginRpcResponsePacket pluginRpcResponsePacket = service.runJava(request); PluginRpcResponsePacket pluginRpcResponsePacket = service.runJava(request);
if(pluginRpcResponsePacket.isStatus()){ if(pluginRpcResponsePacket.isStatus()){
log.setTriggerCode(NodeRunStatusPropertyEnum.RUN_SUCCESS.getCode()); log.setTriggerCode(RunResultEnum.TRIGGER_SUCCESS.getCode());
}else{ }else{
log.setTriggerCode(NodeRunStatusPropertyEnum.RUN_FAILURE.getCode()); log.setTriggerCode(RunResultEnum.TRIGGER_ERROR.getCode());
} }
log.setTriggerMsg(pluginRpcResponsePacket.getMsg()); log.setTriggerMsg(pluginRpcResponsePacket.getMsg());
}catch (Exception e){ }catch (Exception e){
log.setTriggerCode("2"); log.setTriggerCode(RunResultEnum.TRIGGER_ERROR.getCode());
log.setRunCode(NodeRunStatusPropertyEnum.RUN_FAILURE.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());
} }
...@@ -81,14 +82,9 @@ public class JavaTaskJobTask implements TimerTask { ...@@ -81,14 +82,9 @@ public class JavaTaskJobTask implements TimerTask {
log.setHandlerName(javaTask.getTaskName()); log.setHandlerName(javaTask.getTaskName());
log.setRunParams(javaTask.getParam()); log.setRunParams(javaTask.getParam());
log.setTriggerTime(new Date()); log.setTriggerTime(new Date());
log.setJobType("JAVA_SYNC"); log.setJobType(JAVA_SYNC);
JobTaskRunLogServiceImpl jobTaskRunLogService = SpringUtil.getBean(JobTaskRunLogServiceImpl.class); JobTaskRunLogServiceImpl jobTaskRunLogService = SpringUtil.getBean(JobTaskRunLogServiceImpl.class);
int i = jobTaskRunLogService.saveJobTaskRunLog(log); int i = jobTaskRunLogService.saveJobTaskRunLog(log);
return log.getLogId(); return log.getLogId();
} }
public JavaTask getJavaTask() {
return javaTask;
}
} }
package com.byit.thread;
import cn.hutool.core.collection.CollectionUtil;
import com.byit.model.EmailAlarm;
import com.byit.model.vo.EmailAlarmVo;
import com.byit.service.EmailAlarmService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* @program: com.byit.thread.EmailScanHelper
* @description: 对于邮箱的扫描
* @author: huangfu
* @date: 2020年1月7日10:44:01
**/
@Component
@Slf4j
@Deprecated
public class EmailScanHelper {
private final DataSource dataSource;
private final EmailAlarmService emailAlarmService;
private volatile boolean emailThreadIsStop = false;
private Thread emailThread;
public EmailScanHelper(DataSource dataSource, EmailAlarmService emailAlarmService) {
this.dataSource = dataSource;
this.emailAlarmService = emailAlarmService;
}
public void start(){
startScanNotSentEmailFlow();
}
public void startScanNotSentEmailFlow(){
emailThread = new Thread(() ->{
dateAligned(5000);
log.info("--------------【com.byit.thread.EmailScanHelper.startScanNotSentEmailFlow】init success---------------");
while (!emailThreadIsStop){
//是否需要睡眠
boolean isSleep = false;
Connection conn = null;
Boolean connAutoCommit = null;
PreparedStatement preparedStatement = null;
try {
/**
* 添加行锁
*/
conn = dataSource.getConnection();
connAutoCommit = conn.getAutoCommit();
conn.setAutoCommit(false);
preparedStatement = conn.prepareStatement("SELECT * FROM JOB_LOCK WHERE LOCK_NAME = 'emali_alarm_lock' FOR UPDATE ");
preparedStatement.execute();
//查询未告警的邮箱
List<EmailAlarm> emailAlarmByAlarmResults = emailAlarmService.findEmailAlarmByAlarmResult();
if(CollectionUtil.isNotEmpty(emailAlarmByAlarmResults)){
emailAlarmByAlarmResults.forEach(emailAlarm ->{
EmailAlarmVo emailAlarmVo = new EmailAlarmVo();
BeanUtils.copyProperties(emailAlarm,emailAlarmVo);
emailAlarmService.sendEmail(emailAlarmVo);
});
}else{
isSleep = true;
}
}catch (Exception e){
e.printStackTrace();
}finally {
//释放资源
if(conn != null){
try {
conn.commit();
} catch (SQLException e) {
if(!emailThreadIsStop){
log.error("--------------------【提交行锁出错】---------------------");
}
}
}
try {
if(conn != null){
conn.setAutoCommit(connAutoCommit);
}
} catch (SQLException e) {
if(!emailThreadIsStop){
log.error("--------------------【恢复自动提交出错】---------------------");
}
}
if(preparedStatement != null){
try {
preparedStatement.close();
} catch (SQLException e) {
if(!emailThreadIsStop){
log.error("--------------------【关闭执行器出错】---------------------");
}
}
}
try {
conn.close();
} catch (SQLException e) {
if(!emailThreadIsStop){
log.error("--------------------【关闭链接出错】---------------------");
}
}
}
if(isSleep){
dateAligned(20000);
}
}
});
emailThread.setDaemon(true);
emailThread.setName("myth-job#【EmailScanHelper】#startScanNotSentEmailFlow");
emailThread.start();
}
public void doStop(){
this.emailThreadIsStop = true;
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace( );
}
if (emailThread.getState() != Thread.State.TERMINATED) {
emailThread.interrupt();
try {
emailThread.join();
} catch (InterruptedException e) {
e.printStackTrace( );
}
}
log.warn("---------------【日志扫描线程被注销】-----------------------");
}
/**
* 对齐时钟。整秒运行
*/
private void dateAligned(long waitTime){
try {
TimeUnit.MILLISECONDS.sleep(waitTime - System.currentTimeMillis()%1000);
} catch (InterruptedException e) {
log.warn("----------------【线程被中断】-----------------------");
}
}
}
package com.byit.thread;
import cn.hutool.core.collection.CollectionUtil;
import com.byit.job.utils.CronExpression;
import com.byit.model.Flow;
import com.byit.model.Node;
import com.byit.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* 扫描任务流表的线程
* 目的:扫描即将要执行的任务流表 半个小时
* @author huangfu
*/
@Component
@Slf4j
@Deprecated
public class FlowScanHelper {
private final Long PRE_TEST_TIME = System.currentTimeMillis()+TimeUnit.HOURS.toMillis(30);
private final FlowService flowService;
private final DataSource dataSource;
private final NodeService nodeService;
private final RunNodeServer runNodeServer;
private Thread flowThread;
private volatile boolean flowThreadIsStop = false;
public FlowScanHelper(FlowService flowService, DataSource dataSource, NodeService nodeService, RunNodeServer runNodeServer) {
this.flowService = flowService;
this.dataSource = dataSource;
this.nodeService = nodeService;
this.runNodeServer = runNodeServer;
}
public void start(){
flowThreadStart();
}
/**
* 运行扫描工作流的线程
*/
private void flowThreadStart(){
flowThread = new Thread(() ->{
dateAligned(5000);
log.info("--------------【com.byit.thread.FlowScanHelper#flowThreadStart】init success---------------");
while (!flowThreadIsStop){
Connection conn = null;
Boolean connAutoCommit = null;
PreparedStatement preparedStatement = null;
//是否需要睡眠
boolean isSleep = false;
try {
/**
* 添加行锁
*/
conn = dataSource.getConnection();
connAutoCommit = conn.getAutoCommit();
conn.setAutoCommit(false);
preparedStatement = conn.prepareStatement("SELECT * FROM JOB_LOCK WHERE LOCK_NAME = 'flow_lock' FOR UPDATE ");
preparedStatement.execute();
//这个查询时有一个条件是 剩余次数不等于0也就是说 等于0的就查询不出来
List<Flow> halfAnHourFlow = flowService.findHalfAnHourFlow(PRE_TEST_TIME);
if (CollectionUtil.isNotEmpty(halfAnHourFlow)) {
for(Flow flow : halfAnHourFlow ){
log.debug("-----------------【工作流{}的执行次数大于0,放行】-------------------------",flow.getFlowName());
//String versionName = flow.getVersionName()
Integer flowId = flow.getFlowId();
//根据工作流查询工作流下所有的节点
List<Node> nodeByFlowIdAndVersionName = nodeService.findNodeByFlowIdAndVersionName(flowId);
if(CollectionUtil.isNotEmpty(nodeByFlowIdAndVersionName)){
//保存到运行记录表和任务表
runNodeServer.saveRunRec(flow,nodeByFlowIdAndVersionName);
if (flow.getRemainingCount()>0) {
flow.setRemainingCount(flow.getRemainingCount()-1);
}
//获取cron表达式
String flowCron = flow.getFlowCron();
//设置下一周期的时间
Date nextValidTime = new CronExpression(flowCron).getNextValidTimeAfter(new Date(flow.getTriggerNextTime()));
flow.setTriggerNextTime(nextValidTime.getTime());
flowService.updateByIdSelective(flow);
}
}
}else{
isSleep = true;
}
}catch (Exception e){
e.printStackTrace();
}finally {
//释放资源
if(conn != null){
try {
conn.commit();
} catch (SQLException e) {
if(!flowThreadIsStop){
log.error("--------------------【提交行锁出错】---------------------");
}
}
}
try {
if(conn != null){
conn.setAutoCommit(connAutoCommit);
}
} catch (SQLException e) {
if(!flowThreadIsStop){
log.error("--------------------【恢复自动提交出错】---------------------");
}
}
if(preparedStatement != null){
try {
preparedStatement.close();
} catch (SQLException e) {
if(!flowThreadIsStop){
log.error("--------------------【关闭执行器出错】---------------------");
}
}
}
try {
conn.close();
} catch (SQLException e) {
if(!flowThreadIsStop){
log.error("--------------------【关闭链接出错】---------------------");
}
}
}
if(isSleep){
try {
log.info("------------------【未扫描到要执行的工作流】-------------------");
TimeUnit.MINUTES.sleep(1);
} catch (InterruptedException e) {
log.warn("----------------------【扫描工作流的线程被关闭了】----------------------------");
}
}
}
});
flowThread.setDaemon(true);
flowThread.setName("myth-job#【FlowScanHelper】#flowThreadStart");
flowThread.start();
}
public void doStop(){
this.flowThreadIsStop = true;
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace( );
}
if (flowThread.getState() != Thread.State.TERMINATED) {
flowThread.interrupt();
try {
flowThread.join();
} catch (InterruptedException e) {
e.printStackTrace( );
}
}
log.warn("---------------【工作扫描线程被注销】-----------------------");
}
/**
* 对齐时钟。整秒运行
*/
private void dateAligned(long waitTime){
try {
TimeUnit.MILLISECONDS.sleep(waitTime - System.currentTimeMillis()%1000);
} catch (InterruptedException e) {
log.warn("----------------【线程被中断】-----------------------");
}
}
}
package com.byit.thread; package com.byit.thread;
import com.byit.dto.executor.JobRunResultDto; import com.byit.enums.JobResultEnum;
import com.byit.dto.web.ReturnResult; import com.byit.enums.task.RunResultEnum;
import com.byit.enums.RunRecordingEnum;
import com.byit.model.JobTaskRunLogWithBLOBs; import com.byit.model.JobTaskRunLogWithBLOBs;
import com.byit.packet.response.PluginRpcResponsePacket; import com.byit.packet.response.PluginRpcResponsePacket;
import com.byit.service.impl.JobTaskRunLogServiceImpl; import com.byit.service.impl.JobTaskRunLogServiceImpl;
...@@ -26,8 +25,14 @@ public class JavaTaskCallbackThread implements Runnable { ...@@ -26,8 +25,14 @@ public class JavaTaskCallbackThread implements Runnable {
JobTaskRunLogServiceImpl mythJobTaskRunLogService = SpringUtil.getBean(JobTaskRunLogServiceImpl.class); JobTaskRunLogServiceImpl mythJobTaskRunLogService = SpringUtil.getBean(JobTaskRunLogServiceImpl.class);
Map<String,String> result = (Map<String,String>)pluginRpcResponsePacket.getResult(); Map<String,String> result = (Map<String,String>)pluginRpcResponsePacket.getResult();
JobTaskRunLogWithBLOBs jobTaskRunLog = new JobTaskRunLogWithBLOBs(); JobTaskRunLogWithBLOBs jobTaskRunLog = new JobTaskRunLogWithBLOBs();
String code;
if(JobResultEnum.SUCCESS.getCode().equals(result.get("code"))){
code = RunResultEnum.RUN_SUCCESS.getCode();
}else {
code = RunResultEnum.RUN_ERROR.getCode();
}
jobTaskRunLog.setRunMsg(result.get("msg")); jobTaskRunLog.setRunMsg(result.get("msg"));
jobTaskRunLog.setRunCode(result.get("code")); jobTaskRunLog.setRunCode(code);
jobTaskRunLog.setLogId(logId); jobTaskRunLog.setLogId(logId);
mythJobTaskRunLogService.updateJobTaskRunLogWithBLOBs(jobTaskRunLog); mythJobTaskRunLogService.updateJobTaskRunLogWithBLOBs(jobTaskRunLog);
......
package com.byit.thread; package com.byit.thread;
import com.byit.dto.executor.JobRunResultDto; import com.byit.dto.executor.JobRunResultDto;
import com.byit.enums.EmailEnum;
import com.byit.model.JobTaskRunLogWithBLOBs; import com.byit.model.JobTaskRunLogWithBLOBs;
import com.byit.service.impl.JobTaskRunLogServiceImpl; import com.byit.service.impl.JobTaskRunLogServiceImpl;
import com.byit.util.SpringUtil; import com.byit.util.SpringUtil;
...@@ -32,9 +33,6 @@ public class LogCallbackThread implements Runnable { ...@@ -32,9 +33,6 @@ public class LogCallbackThread implements Runnable {
if (jobTaskRunLogById.getRunCount()>1) { if (jobTaskRunLogById.getRunCount()>1) {
String runMsg = jobTaskRunLogById.getRunMsg()+"|"+jobRunResultDto.getReturnResult().getMsg(); String runMsg = jobTaskRunLogById.getRunMsg()+"|"+jobRunResultDto.getReturnResult().getMsg();
//这里需要追加文件 TODO //这里需要追加文件 TODO
//这里需要追加文件 TODO
jobTaskRunLog.setRunMsg(runMsg); jobTaskRunLog.setRunMsg(runMsg);
}else{ }else{
jobTaskRunLog.setRunMsg(jobRunResultDto.getReturnResult().getMsg()); jobTaskRunLog.setRunMsg(jobRunResultDto.getReturnResult().getMsg());
...@@ -45,7 +43,7 @@ public class LogCallbackThread implements Runnable { ...@@ -45,7 +43,7 @@ public class LogCallbackThread implements Runnable {
jobTaskRunLog.setEndTime(jobRunResultDto.getEndTime()); jobTaskRunLog.setEndTime(jobRunResultDto.getEndTime());
jobTaskRunLog.setRunCode(jobRunResultDto.getReturnResult().getCode()); jobTaskRunLog.setRunCode(jobRunResultDto.getReturnResult().getCode());
jobTaskRunLog.setAlertEnd("0"); jobTaskRunLog.setAlertEnd(EmailEnum.IS_ALARM_NO.getCode());
mythJobTaskRunLogService.updateJobTaskRunLogWithBLOBs(jobTaskRunLog); mythJobTaskRunLogService.updateJobTaskRunLogWithBLOBs(jobTaskRunLog);
} }
......
...@@ -129,7 +129,13 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper { ...@@ -129,7 +129,13 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper {
String preHourDate = preHourLocalDateTime.format(DATE_FORMATTER); String preHourDate = preHourLocalDateTime.format(DATE_FORMATTER);
String preHourHour = String.valueOf(preHourLocalDateTime.getHour()); String preHourHour = String.valueOf(preHourLocalDateTime.getHour());
List<FlowStatusSnapshoot> preHourFlowStatusSnapshootList = flowStatusSnapshootMapper.findByDateAndHourAndFlowId(preHourDate, preHourHour, flow.getFlowId()); List<FlowStatusSnapshoot> preHourFlowStatusSnapshootList = flowStatusSnapshootMapper.findByDateAndHourAndFlowId(preHourDate, preHourHour, flow.getFlowId());
flowStatusSnapshootList.addAll(preHourFlowStatusSnapshootList); if (null != preHourFlowStatusSnapshootList || preHourFlowStatusSnapshootList.size() > 0){
flowStatusSnapshootList.addAll(preHourFlowStatusSnapshootList);
}else {
//如果上个小时也没有,就设置为未运行
flowStatusSnapshoot.setUnstartNode(flow.getFlowNodeCount());
flowStatusSnapshootList.add(flowStatusSnapshoot);
}
} }
} }
}else { }else {
...@@ -138,7 +144,7 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper { ...@@ -138,7 +144,7 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper {
flowStatusSnapshootList.add(flowStatusSnapshoot); flowStatusSnapshootList.add(flowStatusSnapshoot);
} }
}); });
if (flowList != null && flowList.size() > 0){ if (null != flowStatusSnapshootList && flowStatusSnapshootList.size() > 0){
flowStatusSnapshootMapper.saveList(flowStatusSnapshootList); flowStatusSnapshootMapper.saveList(flowStatusSnapshootList);
} }
//获取过期的时间戳 //获取过期的时间戳
......
...@@ -230,7 +230,7 @@ public class TaskThreadRunHelper extends BaseThreadRunHelper { ...@@ -230,7 +230,7 @@ public class TaskThreadRunHelper extends BaseThreadRunHelper {
} }
for (JobTaskRunLog jobTaskRunLog : errorJobLog) { for (JobTaskRunLog jobTaskRunLog : errorJobLog) {
//失败重试次数大于0 而且错误原因不是上级节点执行失败 //失败重试次数大于0 而且错误原因不是上级节点执行失败
if(jobTaskRunLog.getFailedRemainingCount()>0 && !("6".equals(jobTaskRunLog.getRunCode()) && "5".equals(jobTaskRunLog.getRunCode()))){ if(jobTaskRunLog.getFailedRemainingCount()!= null && jobTaskRunLog.getFailedRemainingCount()>0 && !("6".equals(jobTaskRunLog.getRunCode()) || "5".equals(jobTaskRunLog.getRunCode()))){
log.debug("----------------【{}节点没有重试完毕】----------------",jobTaskRunLog); log.debug("----------------【{}节点没有重试完毕】----------------",jobTaskRunLog);
return false; return false;
} }
......
...@@ -34,6 +34,12 @@ ...@@ -34,6 +34,12 @@
schedule_follow, is_update, scan_mark schedule_follow, is_update, scan_mark
</sql> </sql>
<select id="findAllFlow" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from flow
</select>
<select id="findHalfAnHourFlow" resultMap="BaseResultMap"> <select id="findHalfAnHourFlow" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
......
...@@ -31,6 +31,16 @@ ...@@ -31,6 +31,16 @@
repeat_count, version_mark, workspace_id, author, principal, version_name, is_inner repeat_count, version_mark, workspace_id, author, principal, version_name, is_inner
</sql> </sql>
<select id="findAllByFlowId" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from flow_version where flow_id=#{flowId,jdbcType=INTEGER} and remove_mark = '1'
</select>
<select id="findAllFlow" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from flow_version where remove_mark = '1'
</select>
<select id="getById" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="getById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<!-- generated @mbg.generated date: 2019-12-31 --> <!-- generated @mbg.generated date: 2019-12-31 -->
select select
......
...@@ -349,7 +349,7 @@ ...@@ -349,7 +349,7 @@
#{triggerCode,jdbcType=VARCHAR}, #{triggerCode,jdbcType=VARCHAR},
</if> </if>
<if test="triggerTime != null"> <if test="triggerTime != null">
#{triggerTime,jdbcType=DATE}, #{triggerTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="jobGroupIp != null"> <if test="jobGroupIp != null">
#{jobGroupIp,jdbcType=VARCHAR}, #{jobGroupIp,jdbcType=VARCHAR},
......
...@@ -56,6 +56,20 @@ ...@@ -56,6 +56,20 @@
run_source run_source
</sql> </sql>
<select id="findAllByFlowId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from node_version
where remove_mark = '1' and flow_version_id = #{flowId,jdbcType=INTEGER}
</select>
<select id="findAll" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from node_version
where remove_mark = '1'
</select>
<select id="getById" parameterType="java.lang.Integer" resultMap="ResultMapWithBLOBs"> <select id="getById" parameterType="java.lang.Integer" resultMap="ResultMapWithBLOBs">
<!-- generated @mbg.generated date: 2019-12-31 --> <!-- generated @mbg.generated date: 2019-12-31 -->
select select
......
...@@ -32,6 +32,27 @@ ...@@ -32,6 +32,27 @@
flow_id, start_time, end_time, is_alarm,is_inner,fail_fast, flow_node_count, schedule_type, operator, re_run_id flow_id, start_time, end_time, is_alarm,is_inner,fail_fast, flow_node_count, schedule_type, operator, re_run_id
</sql> </sql>
<select id="findAll" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from run_recording
</select>
<select id="findAllError" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from run_recording
where flow_run_result = '2' or flow_run_result = '4'
or flow_run_result = '5'
</select>
<select id="findAllRunIng" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from run_recording
where flow_status = '2' or flow_status = '3'
</select>
<!--查询已完结 没有告警的--> <!--查询已完结 没有告警的-->
<select id="findRunRecordingByEndAndNotIsAlarm" resultMap="BaseResultMap"> <select id="findRunRecordingByEndAndNotIsAlarm" resultMap="BaseResultMap">
select select
...@@ -194,7 +215,19 @@ ...@@ -194,7 +215,19 @@
) )
</select> </select>
<delete id="deleteById" parameterType="java.lang.Integer"> <select id="findNewStatus" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from run_recording
where flow_id = #{flowId}
and trigger_time = (
select max(trigger_time)
from run_recording
where flow_id = #{flowId}
)
</select>
<delete id="deleteById" parameterType="java.lang.Integer">
<!-- generated @mbg.generated date: 2019-12-25 --> <!-- generated @mbg.generated date: 2019-12-25 -->
delete from run_recording delete from run_recording
where recording_id = #{recordingId,jdbcType=INTEGER} where recording_id = #{recordingId,jdbcType=INTEGER}
......
...@@ -13,9 +13,14 @@ ...@@ -13,9 +13,14 @@
<artifactId>myth-core-common</artifactId> <artifactId>myth-core-common</artifactId>
<dependencies> <dependencies>
<dependency> <!--<dependency>
<groupId>net.oschina.zcx7878</groupId> <groupId>net.oschina.zcx7878</groupId>
<artifactId>fastdfs-client-java</artifactId> <artifactId>fastdfs-client-java</artifactId>
</dependency>-->
<dependency>
<groupId>com.github.tobato</groupId>
<artifactId>fastdfs-client</artifactId>
<version>1.26.1-RELEASE</version>
</dependency> </dependency>
<!-- slf4j --> <!-- slf4j -->
<dependency> <dependency>
......
package com.byit.filesystem; package com.byit.filesystem;
import cn.hutool.core.collection.CollectionUtil; import com.github.tobato.fastdfs.FdfsClientConfig;
import org.csource.common.MyException; import com.github.tobato.fastdfs.domain.MateData;
import org.csource.common.NameValuePair; import com.github.tobato.fastdfs.domain.StorePath;
import org.csource.fastdfs.ClientGlobal; import com.github.tobato.fastdfs.proto.storage.DownloadByteArray;
import org.csource.fastdfs.StorageClient1; import com.github.tobato.fastdfs.service.FastFileStorageClient;
import org.csource.fastdfs.TrackerClient;
import org.csource.fastdfs.TrackerServer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.IOException; import java.io.ByteArrayInputStream;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
...@@ -21,74 +21,62 @@ import java.util.Set; ...@@ -21,74 +21,62 @@ import java.util.Set;
*/ */
@Component @Component
@ConditionalOnExpression("'${myth-job.filestystem}'.equals('FASTDFS')") @ConditionalOnExpression("'${myth-job.filestystem}'.equals('FASTDFS')")
@Import(FdfsClientConfig.class)
public class FastDfsFileSystem implements FileSystem { public class FastDfsFileSystem implements FileSystem {
public FastDfsFileSystem() { private final FastFileStorageClient fastFileStorageClient;
try {
ClientGlobal.init("fdfs_client.conf"); public FastDfsFileSystem(FastFileStorageClient fastFileStorageClient) {
} catch (IOException | MyException e) { this.fastFileStorageClient = fastFileStorageClient;
e.printStackTrace();
}
} }
@Override @Override
public String uploadFile(byte[] fileBuffer, String fileExtName, Map<String, String> mateDaTa) throws IOException, MyException { public String uploadFile(byte[] fileBuffer, String fileExtName, Map<String, String> mateDaTas) {
TrackerClient trackerClient = new TrackerClient(); ByteArrayInputStream byteInput = new ByteArrayInputStream(fileBuffer);
TrackerServer trackerServer = trackerClient.getConnection(); Set<MateData> mateDataSet = new HashSet<>(2);
StorageClient1 storageClient1 = new StorageClient1(trackerServer, null); mateDaTas.forEach((key,value) ->{
NameValuePair[] mathList = new NameValuePair[mateDaTa.size()]; MateData mateData = new MateData();
if(CollectionUtil.isNotEmpty(mateDaTa)){ mateData.setName(key);
Set<Map.Entry<String, String>> mateSet = mateDaTa.entrySet(); mateData.setValue(value);
int i = 0; mateDataSet.add(mateData);
for (Map.Entry<String, String> mate : mateSet) { });
mathList[i] = new NameValuePair(mate.getKey(),mate.getValue());
i++; StorePath storePath = fastFileStorageClient.uploadFile(byteInput, fileBuffer.length, fileExtName, mateDataSet);
}
} return storePath.getFullPath();
String fileId = storageClient1.upload_file1(fileBuffer, fileExtName, mathList);
trackerServer.close();
return fileId;
} }
@Override @Override
public byte[] downloaderFile(String remPath) throws IOException, MyException { public byte[] downloaderFile(String remPath) {
TrackerClient trackerClient = new TrackerClient(); DownloadByteArray callback = new DownloadByteArray();
TrackerServer trackerServer = trackerClient.getConnection(); return fastFileStorageClient.downloadFile(getPathGroup(remPath), getPath(remPath), callback);
StorageClient1 storageClient1 = new StorageClient1(trackerServer, null);
byte[] bytes = storageClient1.download_file1(remPath);
trackerServer.close();
return bytes;
} }
@Override @Override
public void fileRemove(String remPath) throws IOException, MyException { public void fileRemove(String remPath) {
TrackerClient trackerClient = new TrackerClient(); fastFileStorageClient.deleteFile(remPath);
TrackerServer trackerServer = trackerClient.getConnection();
StorageClient1 storageClient1 = new StorageClient1(trackerServer, null);
storageClient1.delete_file1(remPath);
trackerServer.close();
} }
@Override @Override
public Map<String, String> getFileMate(String filePath) throws IOException, MyException { public Map<String, String> getFileMate(String filePath) {
TrackerClient trackerClient = new TrackerClient(); Set<MateData> metadataSet = fastFileStorageClient.getMetadata(getPathGroup(filePath), getPath(filePath));
TrackerServer trackerServer = trackerClient.getConnection(); HashMap<String, String> map = new HashMap<>(2);
StorageClient1 storageClient1 = new StorageClient1(trackerServer, null); metadataSet.forEach(mateData -> {
NameValuePair[] metadata1 = storageClient1.get_metadata1(filePath); map.put(mateData.getName(),mateData.getValue());
Map<String,String> map = new HashMap<String,String>(5); });
if(metadata1 != null){ return map;
}
for (int i = 0; i <metadata1.length ; i++) { public static String getPathGroup(String fullPath){
map.put(metadata1[i].getName(),metadata1[i].getValue()); int i = fullPath.indexOf("/");
} return fullPath.substring(0, i);
}else{ }
map.put("filename","filename"+filePath.substring(filePath.lastIndexOf("."),filePath.length()));
}
return map; public static String getPath(String fullPath){
int i = fullPath.indexOf("/");
return fullPath.substring(i+1);
} }
public static void main(String[] args) { public static void main(String[] args) {
String filePath = "sadsadsadsadsad.py"; System.out.println(getPath("ddmp/M00/00/09/CgB4Al6mSVSAHi-rAAAABhCiqmE437.log"));
System.out.println(filePath.substring(filePath.lastIndexOf("."), filePath.length()));
} }
} }
package com.byit.filesystem; package com.byit.filesystem;
import org.csource.common.MyException;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
...@@ -17,26 +16,23 @@ public interface FileSystem { ...@@ -17,26 +16,23 @@ public interface FileSystem {
* @param mateDaTA 文件源信息 * @param mateDaTA 文件源信息
* @return 上传路径 * @return 上传路径
* @throws IOException * @throws IOException
* @throws MyException
*/ */
String uploadFile(byte[] fileBuffer, String fileExtName, Map<String, String> mateDaTA) throws IOException, MyException; String uploadFile(byte[] fileBuffer, String fileExtName, Map<String, String> mateDaTA) throws IOException;
/** /**
* 文件下载接口 * 文件下载接口
* @param remPath 远程地址 * @param remPath 远程地址
* @return 文件字节数组 * @return 文件字节数组
* @throws IOException * @throws IOException
* @throws MyException
*/ */
byte[] downloaderFile(String remPath) throws IOException, MyException; byte[] downloaderFile(String remPath) throws IOException;
/** /**
* 文件删除 * 文件删除
* @param remPath 远程地址 * @param remPath 远程地址
* @throws IOException * @throws IOException
* @throws MyException
*/ */
void fileRemove(String remPath) throws IOException, MyException; void fileRemove(String remPath) throws IOException;
/** /**
...@@ -44,9 +40,8 @@ public interface FileSystem { ...@@ -44,9 +40,8 @@ public interface FileSystem {
* @param filePath * @param filePath
* @return * @return
* @throws IOException * @throws IOException
* @throws MyException
*/ */
Map<String,String> getFileMate(String filePath) throws IOException, MyException; Map<String,String> getFileMate(String filePath) throws IOException;
} }
package com.byit.dto.web; package com.byit.dto.web;
import com.byit.enums.IEnum; import com.byit.enums.IEnum;
import com.byit.enums.TransferResultEnum;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
...@@ -32,8 +33,8 @@ public class ResponseResult<T> implements Serializable { ...@@ -32,8 +33,8 @@ public class ResponseResult<T> implements Serializable {
*/ */
public static<T> ResponseResult<T> ok(T t){ public static<T> ResponseResult<T> ok(T t){
ResponseResult<T> tResponseResult = new ResponseResult<>(); ResponseResult<T> tResponseResult = new ResponseResult<>();
tResponseResult.setCode("0000000"); tResponseResult.setCode(TransferResultEnum.SUCCESS.getCode());
tResponseResult.setMsg("成功"); tResponseResult.setMsg(TransferResultEnum.SUCCESS.getMsg());
tResponseResult.setResult(t); tResponseResult.setResult(t);
return tResponseResult; return tResponseResult;
} }
...@@ -44,8 +45,8 @@ public class ResponseResult<T> implements Serializable { ...@@ -44,8 +45,8 @@ public class ResponseResult<T> implements Serializable {
*/ */
public static<T> ResponseResult<T> ok(){ public static<T> ResponseResult<T> ok(){
ResponseResult<T> tResponseResult = new ResponseResult<>(); ResponseResult<T> tResponseResult = new ResponseResult<>();
tResponseResult.setCode("0000000"); tResponseResult.setCode(TransferResultEnum.SUCCESS.getCode());
tResponseResult.setMsg("成功"); tResponseResult.setMsg(TransferResultEnum.SUCCESS.getMsg());
return tResponseResult; return tResponseResult;
} }
...@@ -71,7 +72,7 @@ public class ResponseResult<T> implements Serializable { ...@@ -71,7 +72,7 @@ public class ResponseResult<T> implements Serializable {
public static<T> ResponseResult<T> error(String msg){ public static<T> ResponseResult<T> error(String msg){
ResponseResult<T> tResponseResult = new ResponseResult<>(); ResponseResult<T> tResponseResult = new ResponseResult<>();
tResponseResult.setMsg(msg); tResponseResult.setMsg(msg);
tResponseResult.setCode("00000500"); tResponseResult.setCode(TransferResultEnum.ERROR.getCode());
return tResponseResult; return tResponseResult;
} }
...@@ -94,7 +95,7 @@ public class ResponseResult<T> implements Serializable { ...@@ -94,7 +95,7 @@ public class ResponseResult<T> implements Serializable {
*/ */
public boolean isSuccess(){ public boolean isSuccess(){
//成功 //成功
if ("0000000".equals(this.code)){ if (TransferResultEnum.SUCCESS.getCode().equals(this.code)){
return true; return true;
} }
//失败 //失败
......
...@@ -18,17 +18,16 @@ import java.io.Serializable; ...@@ -18,17 +18,16 @@ import java.io.Serializable;
@NoArgsConstructor @NoArgsConstructor
public class ReturnResult<T> implements Serializable { public class ReturnResult<T> implements Serializable {
public static final long serialVersionUID = 1573630876693L; public static final long serialVersionUID = 1573630876693L;
public static final ReturnResult<String> SUCCESS = new ReturnResult<String>(null); public static final ReturnResult<String> SUCCESS = new ReturnResult<>(null);
public static final ReturnResult FAIL = new ReturnResult(JobResultEnum.FAIL.getRes(), JobResultEnum.FAIL.getMsg()); public static final ReturnResult<String> FAIL = new ReturnResult<>(JobResultEnum.FAIL.getCode(), JobResultEnum.FAIL.getMsg());
public static final ReturnResult FAIL_TIMEOUT = new ReturnResult(JobResultEnum.FAIL_TIMEOUT.getRes(),JobResultEnum.FAIL_TIMEOUT.getMsg());
private String code; private String code;
private String msg; private String msg;
private T content; private T content;
/** /**
* 默认就是错误 * 默认就是错误
* @param code * @param code 错误码
* @param msg * @param msg 执行信息
*/ */
public ReturnResult(String code, String msg) { public ReturnResult(String code, String msg) {
this.code = code; this.code = code;
...@@ -37,10 +36,10 @@ public class ReturnResult<T> implements Serializable { ...@@ -37,10 +36,10 @@ public class ReturnResult<T> implements Serializable {
/** /**
* 默认就是成功 * 默认就是成功
* @param content * @param content 结果集
*/ */
private ReturnResult(T content) { private ReturnResult(T content) {
this.code = JobResultEnum.SUCCESS.getRes(); this.code = JobResultEnum.SUCCESS.getCode();
this.msg = JobResultEnum.SUCCESS.getMsg(); this.msg = JobResultEnum.SUCCESS.getMsg();
this.content = content; this.content = content;
} }
......
...@@ -5,24 +5,23 @@ package com.byit.enums; ...@@ -5,24 +5,23 @@ package com.byit.enums;
* @author huangfu * @author huangfu
*/ */
public enum JobResultEnum implements IEnum { public enum JobResultEnum implements IEnum {
SUCCESS("100200","任务执行成功","1"), SUCCESS("100200","任务执行成功"),
FAIL("100500","任务执行失败","2"), FAIL("100500","任务执行失败"),
FAIL_TIMEOUT("100502","超时错误","2"), FAIL_TIMEOUT("100502","超时错误"),
DISPATCH_SUCCESS("200200","调度成功","1"), DISPATCH_SUCCESS("200200","调度成功"),
DISPATCH_FAIL("200500","调度失败","2"), DISPATCH_FAIL("200500","调度失败"),
KILL_SUCCESS("400000","执行数据被kill"),
RUN_MSG_FAIL("300000","执行结果异常","2"); RUN_MSG_FAIL("300000","执行结果异常");
private String code; private String code;
private String msg; private String msg;
private String res;
JobResultEnum() { JobResultEnum() {
} }
JobResultEnum(String code, String msg,String res) { JobResultEnum(String code, String msg) {
this.code = code; this.code = code;
this.msg = msg; this.msg = msg;
this.res = res;
} }
...@@ -35,7 +34,4 @@ public enum JobResultEnum implements IEnum { ...@@ -35,7 +34,4 @@ public enum JobResultEnum implements IEnum {
public String getMsg() { public String getMsg() {
return this.msg; return this.msg;
} }
public String getRes() {
return this.res;
}
} }
\ No newline at end of file
package com.byit.enums;
/**
* 调用结果枚举 标准
* @author huangfu
*/
public enum TransferResultEnum implements IEnum {
SUCCESS("000000","调用成功"),
ERROR("500000","发生错误")
;
private String code;
private String msg;
TransferResultEnum(String code, String msg) {
this.code = code;
this.msg = msg;
}
@Override
public String getCode() {
return code;
}
@Override
public String getMsg() {
return msg;
}
}
package com.byit.enums.task;
/**
* @author huangfu
*/
public enum RunResultEnum {
TRIGGER_SUCCESS("1","调度成功"),
TRIGGER_ERROR("2","调度失败"),
RUN_SUCCESS("1","执行成功"),
RUN_ERROR("2","执行失败"),
KILL_SUCCESS("5","节点被kill")
;
private String code;
private String msg;
RunResultEnum(String code, String msg) {
this.code = code;
this.msg = msg;
}
public String getCode() {
return code;
}
public String getMsg() {
return msg;
}
}
package com.byit.enums.task;
/**
* 运行类型枚举
* @author huangfu
*/
public enum RunTypeEnum {
PLUGIN_RUN("2","插件执行!"),
EXECUTIVE_MACHINE_RUN("1","执行机执行!")
;
private String code;
private String msg;
RunTypeEnum(String code, String msg) {
this.code = code;
this.msg = msg;
}
public String getCode() {
return code;
}
public String getMsg() {
return msg;
}
}
...@@ -2,6 +2,7 @@ package com.byit.web.advice; ...@@ -2,6 +2,7 @@ package com.byit.web.advice;
import com.byit.dto.web.ResponseResult; import com.byit.dto.web.ResponseResult;
import com.byit.enums.IEnum; import com.byit.enums.IEnum;
import com.byit.enums.TransferResultEnum;
import com.byit.exception.DataValidationException; import com.byit.exception.DataValidationException;
import com.byit.job.exceptions.IException; import com.byit.job.exceptions.IException;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
...@@ -26,7 +27,7 @@ public class ExceptionHandle { ...@@ -26,7 +27,7 @@ public class ExceptionHandle {
if(e instanceof IException){ if(e instanceof IException){
return error(e); return error(e);
}else if(e instanceof DataValidationException){ }else if(e instanceof DataValidationException){
return ResponseResult.error("500",e.getMessage()); return ResponseResult.error(TransferResultEnum.ERROR.getCode(),e.getMessage());
} }
return ResponseResult.error(e.getMessage()); return ResponseResult.error(e.getMessage());
} }
......
...@@ -14,5 +14,5 @@ public interface ScriptExecutorService { ...@@ -14,5 +14,5 @@ public interface ScriptExecutorService {
* @param scriptDto 参数 * @param scriptDto 参数
* @return 调用结果 * @return 调用结果
*/ */
DispatchResponseDto runPythonScript(ScriptDto scriptDto); DispatchResponseDto runScript(ScriptDto scriptDto);
} }
...@@ -33,7 +33,7 @@ public class RunJobServerHandler extends SimpleChannelInboundHandler<FullHttpReq ...@@ -33,7 +33,7 @@ public class RunJobServerHandler extends SimpleChannelInboundHandler<FullHttpReq
200, 200,
60L, 60L,
TimeUnit.SECONDS, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(1000), new LinkedBlockingQueue<>(1000),
r ->new Thread(r, "Netty RunJobServerHandler serverThread-" + r.hashCode())); r ->new Thread(r, "Netty RunJobServerHandler serverThread-" + r.hashCode()));
private static final String PENG = "PENG"; private static final String PENG = "PENG";
...@@ -42,23 +42,23 @@ public class RunJobServerHandler extends SimpleChannelInboundHandler<FullHttpReq ...@@ -42,23 +42,23 @@ public class RunJobServerHandler extends SimpleChannelInboundHandler<FullHttpReq
protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest req) throws Exception { protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest req) throws Exception {
log.debug("----------------------有请求过来了------------------------"); log.debug("----------------------有请求过来了------------------------");
DispatchResponseDto dispatchResponseDto = new DispatchResponseDto(); DispatchResponseDto dispatchResponseDto = new DispatchResponseDto();
dispatchResponseDto.setCode(JobResultEnum.DISPATCH_FAIL.getRes()); dispatchResponseDto.setCode(JobResultEnum.DISPATCH_FAIL.getCode());
dispatchResponseDto.setMsg(JobResultEnum.DISPATCH_FAIL.getMsg()); dispatchResponseDto.setMsg(JobResultEnum.DISPATCH_FAIL.getMsg());
if(req != null){ if(req != null){
//解析 调度中心 的数据对象 //解析 调度中心 的数据对象
AdminSenPluginDto adminSenPluginDto = analysisParam(req.content( )); AdminSenPluginDto adminSenPluginDto = analysisParam(req.content( ));
if(null == adminSenPluginDto){ if(null == adminSenPluginDto){
throw new Exception("核心参数 为 null"); throw new Exception("核心参数为空!");
} }
//检测是否有心跳参数,有心跳参数则为测试参数,且为PENG的话,服务端回复 PONG //检测是否有心跳参数,有心跳参数则为测试参数,且为PENG的话,服务端回复 PONG
String heartbeat = adminSenPluginDto.getHeartbeat(); String heartbeat = adminSenPluginDto.getHeartbeat();
if(null == heartbeat){ if(null == heartbeat){
JOB_TRIGGER_POOL.execute(new RunJobThread(adminSenPluginDto)); JOB_TRIGGER_POOL.execute(new RunJobThread(adminSenPluginDto));
dispatchResponseDto.setCode(JobResultEnum.DISPATCH_SUCCESS.getRes()); dispatchResponseDto.setCode(JobResultEnum.DISPATCH_SUCCESS.getCode());
dispatchResponseDto.setMsg(JobResultEnum.DISPATCH_SUCCESS.getMsg()); dispatchResponseDto.setMsg(JobResultEnum.DISPATCH_SUCCESS.getMsg());
}else if(PENG.equals(heartbeat)){ }else if(PENG.equals(heartbeat)){
log.debug("----------调度平台心跳检测-------------"); log.debug("----------调度平台心跳检测-------------");
dispatchResponseDto.setCode(JobResultEnum.DISPATCH_SUCCESS.getRes()); dispatchResponseDto.setCode(JobResultEnum.DISPATCH_SUCCESS.getCode());
dispatchResponseDto.setMsg(JobResultEnum.DISPATCH_SUCCESS.getMsg()); dispatchResponseDto.setMsg(JobResultEnum.DISPATCH_SUCCESS.getMsg());
dispatchResponseDto.setContent(PONG); dispatchResponseDto.setContent(PONG);
} }
...@@ -78,8 +78,8 @@ public class RunJobServerHandler extends SimpleChannelInboundHandler<FullHttpReq ...@@ -78,8 +78,8 @@ public class RunJobServerHandler extends SimpleChannelInboundHandler<FullHttpReq
/** /**
* 格式化参数 * 格式化参数
* @param byteBuf * @param byteBuf 将缓冲流更改为字符串
* @return * @return 调用的必要信息承载类
*/ */
private AdminSenPluginDto analysisParam(ByteBuf byteBuf){ private AdminSenPluginDto analysisParam(ByteBuf byteBuf){
return JSON.parseObject(byteBuf.toString(CharsetUtil.UTF_8),AdminSenPluginDto.class); return JSON.parseObject(byteBuf.toString(CharsetUtil.UTF_8),AdminSenPluginDto.class);
...@@ -87,12 +87,11 @@ public class RunJobServerHandler extends SimpleChannelInboundHandler<FullHttpReq ...@@ -87,12 +87,11 @@ public class RunJobServerHandler extends SimpleChannelInboundHandler<FullHttpReq
/** /**
* 异常捕获 * 异常捕获
* @param ctx * @param ctx 上线文对象
* @param cause * @param cause 异常信息
* @throws Exception
*/ */
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
cause.printStackTrace(); cause.printStackTrace();
ctx.close(); ctx.close();
} }
......
...@@ -45,16 +45,16 @@ public class RunJobThread implements Runnable { ...@@ -45,16 +45,16 @@ public class RunJobThread implements Runnable {
log.info("---------服务器端:{},花费时间:{}-------------", jobRunResultDto,jobRunResultDto.getStartTime().getTime()-jobRunResultDto.getEndTime().getTime()); log.info("---------服务器端:{},花费时间:{}-------------", jobRunResultDto,jobRunResultDto.getStartTime().getTime()-jobRunResultDto.getEndTime().getTime());
} }
private ReturnResult runJob(String jobHandlerName, String param){ private ReturnResult<String> runJob(String jobHandlerName, String param){
Class<? extends IJobHandler> jobClass = JobUtils.jobCache.get(jobHandlerName); Class<? extends IJobHandler> jobClass = JobUtils.jobCache.get(jobHandlerName);
try { try {
IJobHandler iJobHandler = jobClass.newInstance(); IJobHandler iJobHandler = jobClass.newInstance();
return iJobHandler.execute(param); return iJobHandler.execute(param);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace( ); e.printStackTrace( );
ReturnResult returnResult = new ReturnResult(); ReturnResult<String> returnResult = new ReturnResult<>();
returnResult.setMsg(e.getMessage()); returnResult.setMsg(e.getMessage());
returnResult.setCode(JobResultEnum.FAIL.getRes()); returnResult.setCode(JobResultEnum.FAIL.getCode());
return returnResult; return returnResult;
} }
......
...@@ -101,6 +101,10 @@ public class JobUtils { ...@@ -101,6 +101,10 @@ public class JobUtils {
*/ */
public static final String REQUEST_LOADNODESTATISTICDATA = "/api/flow/loadNodeStatisticData"; public static final String REQUEST_LOADNODESTATISTICDATA = "/api/flow/loadNodeStatisticData";
/** /**
* 获取当前的工作流运行状态
*/
public static final String REQUEST_LOADCURRENTSTATUS = "/api/flow/loadCurrentStatus";
/**
* 补批工作流 * 补批工作流
*/ */
public static final String REQUEST_REPAIRFLOW = "/api/flow/repairFlow"; public static final String REQUEST_REPAIRFLOW = "/api/flow/repairFlow";
...@@ -139,6 +143,10 @@ public class JobUtils { ...@@ -139,6 +143,10 @@ public class JobUtils {
*/ */
private static final String REQUEST_RUN_JAVATASK = "/api/node/runJavaTask"; private static final String REQUEST_RUN_JAVATASK = "/api/node/runJavaTask";
/** /**
* 立即运行quartz任务
*/
private static final String REQUEST_RUN_TASK = "/api/node/runTask";
/**
* 获取当前的运行状态 * 获取当前的运行状态
*/ */
private static final String REQUEST_LOADSTATUS_JAVATASK = "/api/node/loadCurrentStatusByJobName"; private static final String REQUEST_LOADSTATUS_JAVATASK = "/api/node/loadCurrentStatusByJobName";
...@@ -424,6 +432,21 @@ public class JobUtils { ...@@ -424,6 +432,21 @@ public class JobUtils {
} }
/** /**
* 获取当前的工作流运行状态
* @param workspaceName 工作空间名称
* @param flowNames 工作流名称,多个以","分割
* @return
*/
public static ResponseResult loadCurrentStatus(String workspaceName, String flowNames){
Map<String, Object> param = new HashMap<>();
param.put("workspaceName", workspaceName);
param.put("flowNames", flowNames);
String response = createHttpRequest(REQUEST_LOADCURRENTSTATUS, "param=" + JSON.toJSONString(param));
log.info("--------------------获取当前的工作流运行状态接口调用成功,结果为:{}------------------------",response);
return JSON.parseObject(response, ResponseResult.class);
}
/**
* 补批工作流 * 补批工作流
* @param workspaceName 工作空间名称 * @param workspaceName 工作空间名称
* @param flowName 工作流名称 * @param flowName 工作流名称
...@@ -597,6 +620,18 @@ public class JobUtils { ...@@ -597,6 +620,18 @@ public class JobUtils {
} }
/** /**
* 立即运行quartz任务 不验证是否存在数据库中
* @param javaTask
* @return
*/
public static ResponseResult runTask(JavaTask javaTask){
log.info("-------------立即运行quartz任务----------------------");
String response = createHttpRequest(REQUEST_RUN_TASK, "param=" + JSON.toJSONString(javaTask,WriteClassName));
log.info("--------------------立即运行quartz任务,结果为:{}------------------------",response);
return JSON.parseObject(response, ResponseResult.class);
}
/**
* 获取当前的运行状态 * 获取当前的运行状态
* @param jobNames * @param jobNames
* @return * @return
......
...@@ -34,4 +34,12 @@ authentication: ...@@ -34,4 +34,12 @@ authentication:
user: user:
header-name: token header-name: token
expire: 43200 # 外部token有效期为12小时 expire: 43200 # 外部token有效期为12小时
pub-key: client/pub.key # 解密 pub-key: client/pub.key # 解密
\ No newline at end of file
fdfs:
so-timeout: 1500
connect-timeout: 600
pool:
jmx-enabled: false
tracker-list:
- 10.0.120.2:22122
\ No newline at end of file
...@@ -34,4 +34,12 @@ authentication: ...@@ -34,4 +34,12 @@ authentication:
user: user:
header-name: token header-name: token
expire: 43200 # 外部token有效期为12小时 expire: 43200 # 外部token有效期为12小时
pub-key: client/pub.key # 解密 pub-key: client/pub.key # 解密
\ No newline at end of file
fdfs:
so-timeout: 1500
connect-timeout: 600
pool:
jmx-enabled: false
tracker-list:
- 10.0.120.2:22122
\ No newline at end of file
...@@ -21,8 +21,8 @@ myth-job: ...@@ -21,8 +21,8 @@ myth-job:
spring: spring:
redis: redis:
database: 0 database: 0
host: ${Redis_IP} host: 10.0.120.208
port: ${Redis_port} port: 6379
password: password:
timeout: 3000 timeout: 3000
pool: pool:
...@@ -35,4 +35,14 @@ authentication: ...@@ -35,4 +35,14 @@ authentication:
user: user:
header-name: token header-name: token
expire: 43200 # 外部token有效期为12小时 expire: 43200 # 外部token有效期为12小时
pub-key: client/pub.key # 解密 pub-key: client/pub.key # 解密
\ No newline at end of file
fdfs:
so-timeout: 1500
connect-timeout: 600
pool:
jmx-enabled: false
tracker-list:
- 10.0.120.216:22122
- 10.0.120.217:22122
- 10.0.120.218:22122
\ No newline at end of file
...@@ -5,7 +5,7 @@ myth-rpc: ...@@ -5,7 +5,7 @@ myth-rpc:
biz: byit-myth-job biz: byit-myth-job
env: test env: test
remoting: remoting:
port: ${Remote_PORT} port: 7776
logging: logging:
config: classpath:logback.xml config: classpath:logback.xml
...@@ -35,4 +35,14 @@ authentication: ...@@ -35,4 +35,14 @@ authentication:
user: user:
header-name: token header-name: token
expire: 43200 # 外部token有效期为12小时 expire: 43200 # 外部token有效期为12小时
pub-key: client/pub.key # 解密 pub-key: client/pub.key # 解密
\ No newline at end of file
fdfs:
so-timeout: 1500
connect-timeout: 600
pool:
jmx-enabled: false
tracker-list:
- 10.0.120.216:22122
- 10.0.120.217:22122
- 10.0.120.218:22122
\ No newline at end of file
#路由规则参考byit-myth-rpc中的LoadBalance枚举类中的类型 默认是轮询
gateway: gateway:
load: load:
balance: ROUND balance: ROUND
......
...@@ -91,6 +91,30 @@ ...@@ -91,6 +91,30 @@
</resources> </resources>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
<!-- optionally overwrite tags every time image is built with docker:build -->
<forceTags>true</forceTags>
<imageTags>
<imageTag>${docker.image.tag}</imageTag>
</imageTags>
<dockerDirectory>${project.basedir}</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
<serverId>harbor</serverId>
<registryUrl>10.0.101.122</registryUrl>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
......
...@@ -33,3 +33,4 @@ spring: ...@@ -33,3 +33,4 @@ spring:
static-path-pattern: /static/** static-path-pattern: /static/**
resources: resources:
static-locations: classpath:/static/ static-locations: classpath:/static/
...@@ -49,20 +49,6 @@ ...@@ -49,20 +49,6 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- Javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- GPG --> <!-- GPG -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
......
...@@ -45,7 +45,7 @@ public class NettyClientHandler extends SimpleChannelInboundHandler<RpcResponse> ...@@ -45,7 +45,7 @@ public class NettyClientHandler extends SimpleChannelInboundHandler<RpcResponse>
logger.debug(">>>>>>>>>>> myth-rpc netty client close an idle channel.");*/ logger.debug(">>>>>>>>>>> myth-rpc netty client close an idle channel.");*/
nettyConnectClient.send(Beat.BEAT_PING); // beat N, close if fail(may throw error) nettyConnectClient.send(Beat.BEAT_PING); // beat N, close if fail(may throw error)
logger.info(">>>>>>>>>>> myth-rpc netty client send beat-ping."+ctx.channel().id().asShortText()); logger.info(">>>>>>>>>>> myth-rpc netty client send beat-ping.");
} else { } else {
super.userEventTriggered(ctx, evt); super.userEventTriggered(ctx, evt);
......
...@@ -71,7 +71,7 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<RpcRequest> ...@@ -71,7 +71,7 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<RpcRequest>
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (evt instanceof IdleStateEvent){ if (evt instanceof IdleStateEvent){
ctx.channel().close(); // beat 3N, close if idle ctx.channel().close(); // beat 3N, close if idle
logger.info(">>>>>>>>>>> myth-rpc provider netty server close an idle channel."+ctx.channel().id()); logger.info(">>>>>>>>>>> myth-rpc provider netty server close an idle channel.");
} else { } else {
super.userEventTriggered(ctx, evt); super.userEventTriggered(ctx, evt);
} }
......
...@@ -15,7 +15,6 @@ public class NettyPluginClient extends PluginClient { ...@@ -15,7 +15,6 @@ public class NettyPluginClient extends PluginClient {
@Override @Override
public void send(String address, PluginRpcRequestPacket pluginRpcRequestPacket) throws Exception { public void send(String address, PluginRpcRequestPacket pluginRpcRequestPacket) throws Exception {
System.out.println("--------------我发送信息了");
PluginConnectClient.send(pluginRpcRequestPacket,address,pluginConnectClientImpl,pluginClientInitialization); PluginConnectClient.send(pluginRpcRequestPacket,address,pluginConnectClientImpl,pluginClientInitialization);
} }
} }
...@@ -32,7 +32,7 @@ public class NettyClientHandler extends SimpleChannelInboundHandler<PluginRpcRes ...@@ -32,7 +32,7 @@ public class NettyClientHandler extends SimpleChannelInboundHandler<PluginRpcRes
//判断事件是否是心跳事件 //判断事件是否是心跳事件
if( evt instanceof IdleStateEvent){ if( evt instanceof IdleStateEvent){
pluginConnectClient.send(PluginBeat.PLUGIN_RPC_REQUEST_PACKET); pluginConnectClient.send(PluginBeat.PLUGIN_RPC_REQUEST_PACKET);
System.out.println("------客户端发送心跳请求-----"+ctx.channel().id().asShortText()); System.out.println("------客户端发送心跳请求-----");
}else{ }else{
super.userEventTriggered(ctx, evt); super.userEventTriggered(ctx, evt);
} }
......
...@@ -23,6 +23,9 @@ import java.util.concurrent.ThreadPoolExecutor; ...@@ -23,6 +23,9 @@ import java.util.concurrent.ThreadPoolExecutor;
*/ */
public class NettyPluginServerHandler extends SimpleChannelInboundHandler<PluginRpcRequestPacket> { public class NettyPluginServerHandler extends SimpleChannelInboundHandler<PluginRpcRequestPacket> {
public static final String TOKEN_NAME = "token";
public static final String HEADER_TOKEN_NAME = TOKEN_NAME;
public static final String HEADER_CONTENT_TYPE = "contentType";
private PluginServerFactory pluginServerFactory; private PluginServerFactory pluginServerFactory;
private ThreadPoolExecutor threadPoolExecutor; private ThreadPoolExecutor threadPoolExecutor;
...@@ -32,15 +35,14 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin ...@@ -32,15 +35,14 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin
} }
/** /**
* //TODO 这一块有问题 不能返回两次结果 考虑能否加一个结果回调,回调的方式由自己实现 * 接收到消费方的请求 开始处理消费方的请求
* @param ctx * @param ctx 上下文对象
* @param msg * @param msg 消息对象
* @throws Exception
*/ */
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, PluginRpcRequestPacket msg) throws Exception { protected void channelRead0(ChannelHandlerContext ctx, PluginRpcRequestPacket msg) {
if(PluginBeat.BEAT_ID.equals(msg.getRequestId())){ if(PluginBeat.BEAT_ID.equals(msg.getRequestId())){
System.out.println("------接收到客户端的心跳连接-------"+ctx.channel().id().asShortText()); System.out.println("------接收到客户端的心跳连接-------");
return; return;
} }
PluginRpcResponsePacket transferPluginRpcResponse = new PluginRpcResponsePacket(); PluginRpcResponsePacket transferPluginRpcResponse = new PluginRpcResponsePacket();
...@@ -55,20 +57,20 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin ...@@ -55,20 +57,20 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin
ReturnResult<String> execute = iJobHandler.execute(msg.getParam()); ReturnResult<String> execute = iJobHandler.execute(msg.getParam());
long endTime = System.currentTimeMillis(); long endTime = System.currentTimeMillis();
rpcResponsePacket.setResult(execute); rpcResponsePacket.setResult(execute);
rpcResponsePacket.setCode("000000"); rpcResponsePacket.setCode(JobResultEnum.SUCCESS.getCode());
rpcResponsePacket.setMsg("SUCCESS"); rpcResponsePacket.setMsg(JobResultEnum.SUCCESS.getMsg());
rpcResponsePacket.setStatus(true); rpcResponsePacket.setStatus(true);
rpcResponsePacket.setRunTime(endTime-startTime); rpcResponsePacket.setRunTime(endTime-startTime);
rpcResponsePacket.setExtension(msg.getExtension()); rpcResponsePacket.setExtension(msg.getExtension());
sendMsg(rpcResponsePacket,msg); sendMsg(rpcResponsePacket,msg);
}catch (Throwable e){ }catch (Throwable e){
rpcResponsePacket.setCode("500000"); rpcResponsePacket.setCode(JobResultEnum.FAIL.getCode());
rpcResponsePacket.setMsg(e.getMessage()); rpcResponsePacket.setMsg(e.getMessage());
rpcResponsePacket.setStatus(false); rpcResponsePacket.setStatus(false);
rpcResponsePacket.setExtension(msg.getExtension()); rpcResponsePacket.setExtension(msg.getExtension());
ReturnResult<String> execute = new ReturnResult<>(); ReturnResult<String> execute = new ReturnResult<>();
execute.setMsg(e.getMessage()); execute.setMsg(e.getMessage());
execute.setCode(JobResultEnum.FAIL.getRes()); execute.setCode(JobResultEnum.FAIL.getCode());
rpcResponsePacket.setResult(execute); rpcResponsePacket.setResult(execute);
sendMsg(rpcResponsePacket,msg); sendMsg(rpcResponsePacket,msg);
throw new RuntimeException(e); throw new RuntimeException(e);
...@@ -91,8 +93,8 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin ...@@ -91,8 +93,8 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin
String responseStr = JSON.toJSONString(rpcResponsePacket); String responseStr = JSON.toJSONString(rpcResponsePacket);
HttpRequest post = HttpRequest.post(msg.getCallbackUrl()); HttpRequest post = HttpRequest.post(msg.getCallbackUrl());
post.header("token", "Token"); post.header(HEADER_TOKEN_NAME, "Token");
post.header("contentType","application/json"); post.header(HEADER_CONTENT_TYPE,"application/json");
post.body(responseStr).execute(); post.body(responseStr).execute();
System.out.println("-------消息回复成功-----------"); System.out.println("-------消息回复成功-----------");
} }
...@@ -101,10 +103,9 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin ...@@ -101,10 +103,9 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin
* 异常处理 * 异常处理
* @param ctx 上下文对象 * @param ctx 上下文对象
* @param cause 异常对象 * @param cause 异常对象
* @throws Exception 异常信息
*/ */
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
cause.printStackTrace(); cause.printStackTrace();
ctx.close(); ctx.close();
} }
......
...@@ -34,7 +34,7 @@ public class IndexController { ...@@ -34,7 +34,7 @@ public class IndexController {
@ResponseBody @ResponseBody
public DispatchResponseDto say1(String name){ public DispatchResponseDto say1(String name){
DispatchResponseDto dispatchResponseDto = scriptExecutorService.runPythonScript(null); DispatchResponseDto dispatchResponseDto = scriptExecutorService.runScript(null);
return dispatchResponseDto; return dispatchResponseDto;
} }
} }
...@@ -13,11 +13,13 @@ import java.util.concurrent.TimeUnit; ...@@ -13,11 +13,13 @@ import java.util.concurrent.TimeUnit;
*/ */
public class AddComplexPy1 { public class AddComplexPy1 {
public static void main(String[] args) { public static void main(String[] args) {
PluginPackage pluginPackage = new PluginPackage(); PluginPackage pluginPackage = new PluginPackage();
pluginPackage.setWorkspaceName("test"); pluginPackage.setWorkspaceName("test");
pluginPackage.setFlow(createFlow()); pluginPackage.setFlow(createFlow());
JobUtils.setRequestUrl("http://127.0.0.1:8081/myth-job-admin"); JobUtils.setRequestUrl("http://127.0.0.1:8081/myth-job-admin");
JobUtils.setTOKEN("test"); JobUtils.setTOKEN("test");
//JobUtils.addWorkspace("test");
JobUtils.publish(pluginPackage); JobUtils.publish(pluginPackage);
} }
......
package com.byit.job; package com.byit.job;
import com.byit.filesystem.FastDfsFileSystem; import com.byit.filesystem.FastDfsFileSystem;
import org.csource.common.MyException;
import java.io.IOException; import java.io.IOException;
...@@ -12,10 +11,10 @@ import java.io.IOException; ...@@ -12,10 +11,10 @@ import java.io.IOException;
* @date: 2019/11/20 12:18 * @date: 2019/11/20 12:18
**/ **/
public class Mains { public class Mains {
public static void main(String[] args) throws InterruptedException, IOException, MyException { public static void main(String[] args) {
FastDfsFileSystem fastDfsFileSystem = new FastDfsFileSystem(); /*FastDfsFileSystem fastDfsFileSystem = new FastDfsFileSystem(fastFileStorageClient);
byte[] bytes = fastDfsFileSystem.downloaderFile("ddmp/M00/00/00/CgB4Al5wa36ADcUtAAAAiVc2FQ85978.py"); byte[] bytes = fastDfsFileSystem.downloaderFile("ddmp/M00/00/00/CgB4Al5wa36ADcUtAAAAiVc2FQ85978.py");
System.out.println(new String(bytes)); System.out.println(new String(bytes));*/
/*new JobRunServerLauncher("/plugin.xml"); /*new JobRunServerLauncher("/plugin.xml");
JobUtils.jobCache.forEach((key,value) ->{ JobUtils.jobCache.forEach((key,value) ->{
......
...@@ -13,7 +13,7 @@ import org.springframework.stereotype.Component; ...@@ -13,7 +13,7 @@ import org.springframework.stereotype.Component;
* @author huangfu * @author huangfu
*/ */
@Component @Component
@TaskHandler(expand = "{sadasdadasdasdasd}",cron = "0 0/2 * * * ?",taskName = "sentEmailServer",autoPublish = true,publishUrl = "http://127.0.0.1:8081/myth-job-admin/api/node/autoAddJavaTask") @TaskHandler(expand = "{sadasdadasdasdasd}",cron = "0 0/2 * * * ?",taskName = "sentEmailServer",autoPublish = false,publishUrl = "http://127.0.0.1:8081/myth-job-admin/api/node/autoAddJavaTask")
@Slf4j @Slf4j
public class SentEmailServer extends BaseJobHandler { public class SentEmailServer extends BaseJobHandler {
@Override @Override
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
<relativePath/> <relativePath/>
</parent> </parent>
<properties> <properties>
<docker.image.prefix>10.0.101.122/myth</docker.image.prefix>
<docker.image.tag>v1.0</docker.image.tag>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
...@@ -69,12 +71,20 @@ ...@@ -69,12 +71,20 @@
<springfox-swagger-ui.version>2.9.2</springfox-swagger-ui.version> <springfox-swagger-ui.version>2.9.2</springfox-swagger-ui.version>
<org-apache-commons.version>1.3</org-apache-commons.version> <org-apache-commons.version>1.3</org-apache-commons.version>
<fastdfs-client-java-version>1.27.0.0</fastdfs-client-java-version> <fastdfs-client-java-version>1.27.0.0</fastdfs-client-java-version>
<fastdfs-client-version>1.26.1-RELEASE</fastdfs-client-version>
</properties> </properties>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<!-- fastdfs-client 依赖-->
<dependency>
<groupId>com.github.tobato</groupId>
<artifactId>fastdfs-client</artifactId>
<version>${fastdfs-client-version}</version>
</dependency>
<dependency> <dependency>
<groupId>net.oschina.zcx7878</groupId> <groupId>net.oschina.zcx7878</groupId>
<artifactId>fastdfs-client-java</artifactId> <artifactId>fastdfs-client-java</artifactId>
...@@ -214,4 +224,32 @@ ...@@ -214,4 +224,32 @@
</snapshotRepository> </snapshotRepository>
</distributionManagement> </distributionManagement>
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
<!-- optionally overwrite tags every time image is built with docker:build -->
<forceTags>true</forceTags>
<imageTags>
<imageTag>${docker.image.tag}</imageTag>
</imageTags>
<dockerDirectory>${project.basedir}</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
<serverId>harbor</serverId>
<registryUrl>10.0.101.122</registryUrl>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>
\ 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