Commit b5170a1f authored by sml's avatar sml

代码提交(关联job,启动类名称修改)

parent 31b9fcab
......@@ -17,7 +17,7 @@
<java.version>1.8</java.version>
<shiro.version>1.2.3</shiro.version>
<mybatis-pagehelper.version>4.2.0</mybatis-pagehelper.version>
<start-class>com.jz.dmp.cmdexectool.ApiApplication</start-class>
<start-class>com.jz.dmp.cmdexectool.CmdExecToolApplication</start-class>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
......@@ -586,7 +586,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.jz.dmp.cmdexectool.ApiApplication</mainClass>
<mainClass>com.jz.dmp.cmdexectool.CmdExecToolApplication</mainClass>
</configuration>
<!--<dependencies>
<dependency>
......
......@@ -20,14 +20,14 @@ import com.jz.dmp.cmdexectool.scheduler.service.process.ProcessService;
@EnableTransactionManagement
@SpringBootApplication
@EnableCaching
public class ApiApplication implements HealthIndicator {
public class CmdExecToolApplication implements HealthIndicator {
private static Logger logger = LoggerFactory.getLogger(ApiApplication.class);
private static Logger logger = LoggerFactory.getLogger(CmdExecToolApplication.class);
public static void main(String[] args) {
long start = System.currentTimeMillis();
ConfigurableApplicationContext context = new SpringApplicationBuilder(ApiApplication.class).web(WebApplicationType.NONE).bannerMode(Banner.Mode.OFF).run(args);
ConfigurableApplicationContext context = new SpringApplicationBuilder(CmdExecToolApplication.class).web(WebApplicationType.NONE).bannerMode(Banner.Mode.OFF).run(args);
Integer taskId = Integer.parseInt(args[0]);
if (taskId==null) {
......
......@@ -126,6 +126,26 @@ public class ProcessService {
throws Exception {
TaskExecutionContext taskExecutionContext = new TaskExecutionContext();
// 获取任务数据,并获取job json,并组装TaskInstance
DmpDevelopTaskDto dmpDevelopTaskDto = findDevelopTaskByTaskId(taskId, isSingle);
taskExecutionContext = dto2execcontext(dmpDevelopTaskDto, jobId);
//设置azkaban执行ID
taskExecutionContext.setExecId(execId);
return taskExecutionContext;
}
/**
* @Title: extracted
* @Description: TODO(根据taskId获取任务)
* @param @param taskId
* @param @param isSingle
* @param @return
* @param @throws Exception 参数
* @return DmpDevelopTaskDto 返回类型
* @throws
*/
private DmpDevelopTaskDto findDevelopTaskByTaskId(Integer taskId, boolean isSingle) throws Exception {
DmpDevelopTaskDto dmpDevelopTaskDto = dmpDevelopTaskMapper.findById(taskId);
if (!isSingle) {
Map<String, Object> param = new HashMap<String, Object>();
......@@ -137,12 +157,7 @@ public class ProcessService {
}
dmpDevelopTaskDto = MyDmpDevelopTaskHistoryConverter.INSTANCE().historyDto2taskDto(dmpDevelopTaskHistoryDtos.get(0));
}
taskExecutionContext = dto2execcontext(dmpDevelopTaskDto, jobId);
//设置azkaban执行ID
taskExecutionContext.setExecId(execId);
return taskExecutionContext;
return dmpDevelopTaskDto;
}
/**
......@@ -199,8 +214,19 @@ public class ProcessService {
comparLabel = lable+"_"+taskName;
}
if (jobId.equals(comparLabel)) {
jobType = JobType.valueOf(jObject.getString("taskType"));//job类型
if (CommConstant.WORK_TYPE_SQL.equals(taskJobType)
|| CommConstant.WORK_TYPE_SHELL.equals(taskJobType)
|| CommConstant.WORK_TYPE_SYNC.equals(taskJobType)) {
String taskId2 = jObject.getString("script");//获取关联任务的taskId
DmpDevelopTaskDto dmpDevelopTaskDto2 = findDevelopTaskByTaskId(Integer.parseInt(taskId2), false);
script = dmpDevelopTaskDto2.getScript();
} else {
script = jObject.toJSONString();
}
jobType = JobType.valueOf(taskJobType);//job类型
taskAppId = lable;
break;
}
......
......@@ -51,7 +51,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.jz.dmp.cmdexectool.ApiApplication;
import com.jz.dmp.cmdexectool.CmdExecToolApplication;
import com.jz.dmp.cmdexectool.scheduler.common.Constants;
import com.jz.dmp.cmdexectool.scheduler.common.enums.DbType;
import com.jz.dmp.cmdexectool.scheduler.common.enums.ExecutionStatus;
......@@ -76,7 +76,7 @@ import com.jz.dmp.cmdexectool.scheduler.service.process.ProcessService;
* python shell command executor test
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ApiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@SpringBootTest(classes = CmdExecToolApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class SQLCommandExecutorTest {
private static final Logger logger = LoggerFactory.getLogger(SQLCommandExecutorTest.class);
......
......@@ -16,7 +16,7 @@
*/
package com.jz.cmdexectool.test.task.shell;
import com.jz.dmp.cmdexectool.ApiApplication;
import com.jz.dmp.cmdexectool.CmdExecToolApplication;
import com.jz.dmp.cmdexectool.scheduler.common.Constants;
import com.jz.dmp.cmdexectool.scheduler.common.enums.ExecutionStatus;
import com.jz.dmp.cmdexectool.scheduler.server.entity.TaskExecutionContext;
......@@ -40,7 +40,7 @@ import org.springframework.test.context.junit4.SpringRunner;
* python shell command executor test
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ApiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@SpringBootTest(classes = CmdExecToolApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ShellCommandExecutorTest {
private static final Logger logger = LoggerFactory.getLogger(ShellCommandExecutorTest.class);
......
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