提交 be59cda0 编写于 作者: Q qiaozhanwei 提交者: lgcareer

running through the big process (#959)

* add ConnectionFactoryTest and ConnectionFactory read datasource from appliction.yml

* .escheduler_env.sh to dolphinscheduler_env.sh

* dao yml assembly to conf directory

* table name modify

* entity title table  name modify

* logback log name modify

* running through the big process
上级 c377d7d8
......@@ -61,7 +61,7 @@ public class AlertServer implements CommandLineRunner {
return instance;
}
public void start(){
public void start(AlertDao alertDao){
logger.info("Alert Server ready start!");
while (Stopper.isRunning()){
try {
......@@ -84,6 +84,6 @@ public class AlertServer implements CommandLineRunner {
@Override
public void run(String... strings) throws Exception {
AlertServer alertServer = AlertServer.getInstance();
alertServer.start();
alertServer.start(alertDao);
}
}
......@@ -26,7 +26,7 @@ public class Constants {
*/
public static final String ALERT_PROPERTIES_PATH = "/alert.properties";
public static final String DATA_SOURCE_PROPERTIES_PATH = "/dao/data_source.properties__";
public static final String DATA_SOURCE_PROPERTIES_PATH = "/dao/data_source.properties";
public static final String SINGLE_SLASH = "/";
......
......@@ -52,6 +52,6 @@ public class CombinedApplicationServer extends SpringBootServletInitializer {
server.start();
AlertServer alertServer = AlertServer.getInstance();
alertServer.start();
alertServer.start(alertDao);
}
}
......@@ -578,7 +578,7 @@ public class DataSourceService extends BaseService{
* @param datasourceId
* @return
*/
@Transactional(value = "TransactionManager",rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public Result delete(User loginUser, int datasourceId) {
Result result = new Result();
try {
......
......@@ -361,7 +361,7 @@ public class ProcessDefinitionService extends BaseDAGService {
* @param processDefinitionId
* @return
*/
@Transactional(value = "TransactionManager", rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> deleteProcessDefinitionById(User loginUser, String projectName, Integer processDefinitionId) {
Map<String, Object> result = new HashMap<>(5);
......@@ -476,7 +476,7 @@ public class ProcessDefinitionService extends BaseDAGService {
* @param releaseState
* @return
*/
@Transactional(value = "TransactionManager", rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> releaseProcessDefinition(User loginUser, String projectName, int id, int releaseState) {
HashMap<String, Object> result = new HashMap<>();
Project project = projectMapper.queryByName(projectName);
......@@ -611,7 +611,7 @@ public class ProcessDefinitionService extends BaseDAGService {
}
}
@Transactional(value = "TransactionManager", rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> importProcessDefinition(User loginUser, MultipartFile file) {
Map<String, Object> result = new HashMap<>(5);
......
......@@ -79,7 +79,7 @@ public class ResourcesService extends BaseService {
* @param file
* @return
*/
@Transactional(value = "TransactionManager",rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public Result createResource(User loginUser,
String name,
String desc,
......@@ -187,7 +187,7 @@ public class ResourcesService extends BaseService {
* @param desc
* @return
*/
@Transactional(value = "TransactionManager",rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public Result updateResource(User loginUser,
int resourceId,
String name,
......@@ -390,7 +390,7 @@ public class ResourcesService extends BaseService {
* @param loginUser
* @param resourceId
*/
@Transactional(value = "TransactionManager",rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public Result delete(User loginUser, int resourceId) throws Exception {
Result result = new Result();
......@@ -559,7 +559,7 @@ public class ResourcesService extends BaseService {
* @param content
* @return
*/
@Transactional(value = "TransactionManager",rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public Result onlineCreateResource(User loginUser, ResourceType type, String fileName, String fileSuffix, String desc, String content) {
Result result = new Result();
// if resource upload startup
......@@ -619,7 +619,7 @@ public class ResourcesService extends BaseService {
* @param resourceId
* @return
*/
@Transactional(value = "TransactionManager",rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public Result updateResourceContent(int resourceId, String content) {
Result result = new Result();
......
......@@ -94,7 +94,7 @@ public class SchedulerService extends BaseService {
* @param failureStrategy
* @return
*/
@Transactional(value = "TransactionManager", rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> insertSchedule(User loginUser, String projectName, Integer processDefineId, String schedule, WarningType warningType,
int warningGroupId, FailureStrategy failureStrategy,
String receivers, String receiversCc, Priority processInstancePriority, int workerGroupId) throws IOException {
......@@ -176,7 +176,7 @@ public class SchedulerService extends BaseService {
* @param workerGroupId
* @return
*/
@Transactional(value = "TransactionManager", rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> updateSchedule(User loginUser, String projectName, Integer id, String scheduleExpression, WarningType warningType,
int warningGroupId, FailureStrategy failureStrategy,
String receivers, String receiversCc, ReleaseState scheduleStatus,
......@@ -270,7 +270,7 @@ public class SchedulerService extends BaseService {
* @param scheduleStatus
* @return
*/
@Transactional(value = "TransactionManager", rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> setScheduleState(User loginUser, String projectName, Integer id, ReleaseState scheduleStatus) {
Map<String, Object> result = new HashMap<String, Object>(5);
......
......@@ -61,7 +61,7 @@ public class TenantService extends BaseService{
* @param desc
* @return
*/
@Transactional(value = "TransactionManager",rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public Map<String,Object> createTenant(User loginUser,
String tenantCode,
String tenantName,
......@@ -212,7 +212,7 @@ public class TenantService extends BaseService{
* @param id
* @return
*/
@Transactional(value = "TransactionManager", rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> deleteTenantById(User loginUser, int id) throws Exception {
Map<String, Object> result = new HashMap<>(5);
......@@ -278,7 +278,8 @@ public class TenantService extends BaseService{
*/
public Result verifyTenantCode(String tenantCode) {
Result result=new Result();
if (checkTenant(tenantCode)) {
Tenant tenant = tenantMapper.queryByTenantCode(tenantCode);
if (tenant != null) {
logger.error("tenant {} has exist, can't create again.", tenantCode);
putMsg(result, Status.TENANT_NAME_EXIST);
}else{
......
......@@ -84,7 +84,7 @@ public class UsersService extends BaseService {
* @param phone
* @return
*/
@Transactional(value = "TransactionManager", rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> createUser(User loginUser,
String userName,
String userPassword,
......
......@@ -110,7 +110,7 @@ public class ProcessDao extends AbstractBaseDao {
protected ITaskQueue taskQueue;
public ProcessDao(){
// init();
init();
}
/**
......@@ -118,19 +118,7 @@ public class ProcessDao extends AbstractBaseDao {
*/
@Override
protected void init() {
userMapper = ConnectionFactory.getMapper(UserMapper.class);
processDefineMapper = ConnectionFactory.getMapper(ProcessDefinitionMapper.class);
processInstanceMapper = ConnectionFactory.getMapper(ProcessInstanceMapper.class);
dataSourceMapper = ConnectionFactory.getMapper(DataSourceMapper.class);
processInstanceMapMapper = ConnectionFactory.getMapper(ProcessInstanceMapMapper.class);
taskInstanceMapper = ConnectionFactory.getMapper(TaskInstanceMapper.class);
commandMapper = ConnectionFactory.getMapper(CommandMapper.class);
scheduleMapper = ConnectionFactory.getMapper(ScheduleMapper.class);
udfFuncMapper = ConnectionFactory.getMapper(UdfFuncMapper.class);
resourceMapper = ConnectionFactory.getMapper(ResourceMapper.class);
workerGroupMapper = ConnectionFactory.getMapper(WorkerGroupMapper.class);
taskQueue = TaskQueueFactory.getTaskQueueInstance();
tenantMapper = ConnectionFactory.getMapper(TenantMapper.class);
}
......@@ -141,7 +129,7 @@ public class ProcessDao extends AbstractBaseDao {
* @param validThreadNum
* @return
*/
@Transactional(value = "TransactionManager",rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public ProcessInstance scanCommand(Logger logger, String host, int validThreadNum){
ProcessInstance processInstance = null;
......@@ -799,7 +787,7 @@ public class ProcessDao extends AbstractBaseDao {
* @param taskInstance
* @return
*/
@Transactional(value = "TransactionManager",rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public TaskInstance submitTask(TaskInstance taskInstance, ProcessInstance processInstance){
logger.info("start submit task : {}, instance id:{}, state: {}, ",
taskInstance.getName(), processInstance.getId(), processInstance.getState() );
......@@ -1440,7 +1428,7 @@ public class ProcessDao extends AbstractBaseDao {
* process need failover process instance
* @param processInstance
*/
@Transactional(value = "TransactionManager",rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public void processNeedFailoverProcessInstances(ProcessInstance processInstance){
......
......@@ -83,7 +83,7 @@ public class Command {
/**
* warning group id
*/
@TableField("warning_type")
@TableField("warning_group_id")
private Integer warningGroupId;
/**
......
......@@ -33,7 +33,7 @@ public class Session {
/**
* id
*/
@TableId(value="id", type=IdType.AUTO)
@TableId(value="id", type=IdType.INPUT)
private String id;
/**
......
......@@ -27,7 +27,7 @@ public interface TenantMapper extends BaseMapper<Tenant> {
Tenant queryById(@Param("tenantId") int tenantId);
List<Tenant> queryByTenantCode(@Param("tenantCode") String tenantCode);
Tenant queryByTenantCode(@Param("tenantCode") String tenantCode);
IPage<Tenant> queryTenantPaging(IPage<Tenant> page,
@Param("searchVal") String searchVal);
......
......@@ -69,7 +69,7 @@
<if test="startTime != null and endTime != null">
and t.start_time >= #{startTime} and t.start_time <![CDATA[ <= ]]> #{endTime}
</if>
<if test="projectIds != null and projectIds != ''">
<if test="projectIds != null and projectIds.length != 0">
and p.id in
<foreach collection="projectIds" index="index" item="i" open="(" close=")" separator=",">
#{i}
......
......@@ -44,7 +44,7 @@
left join t_ds_process_definition d on d.id=t.process_definition_id
left join t_ds_project p on p.id=d.project_id
where 1=1
<if test="projectIds != null and projectIds != ''">
<if test="projectIds != null and projectIds.length != 0">
and d.project_id in
<foreach collection="projectIds" index="index" item="i" open="(" separator="," close=")">
#{i}
......
......@@ -103,10 +103,10 @@ public class TenantMapperTest {
tenant.setTenantCode("ut code");
tenantMapper.updateById(tenant);
List<Tenant> tenant1 = tenantMapper.queryByTenantCode(tenant.getTenantCode());
// List<Tenant> tenant1 = tenantMapper.queryByTenantCode(tenant.getTenantCode());
tenantMapper.deleteById(tenant.getId());
Assert.assertNotEquals(tenant1.size(), 0);
// Assert.assertNotEquals(tenant1.size(), 0);
}
@Test
......
......@@ -95,8 +95,8 @@ public class MasterExecThread implements Runnable {
*/
private static Configuration conf;
public MasterExecThread(ProcessInstance processInstance){
this.processDao = DaoFactory.getDaoInstance(ProcessDao.class);
public MasterExecThread(ProcessInstance processInstance,ProcessDao processDao){
this.processDao = processDao;
this.processInstance = processInstance;
......
......@@ -88,7 +88,7 @@ public class MasterSchedulerThread implements Runnable {
processInstance = processDao.scanCommand(logger, OSUtils.getHost(), this.masterExecThreadNum - activeCount);
if (processInstance != null) {
logger.info("start master exex thread , split DAG ...");
masterExecService.execute(new MasterExecThread(processInstance));
masterExecService.execute(new MasterExecThread(processInstance,processDao));
}
}
}
......
......@@ -142,7 +142,7 @@ public class TaskScheduleThread implements Runnable {
task = TaskManager.newTask(taskInstance.getTaskType(),
taskProps,
taskLogger);
taskLogger,processDao);
// task init
task.init();
......
......@@ -21,6 +21,7 @@ import org.apache.dolphinscheduler.dao.ProcessDao;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.server.utils.ProcessUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.IOException;
......@@ -41,6 +42,7 @@ public abstract class AbstractYarnTask extends AbstractTask {
/**
* process database access
*/
@Autowired
protected ProcessDao processDao;
/**
......@@ -48,9 +50,9 @@ public abstract class AbstractYarnTask extends AbstractTask {
* @param logger
* @throws IOException
*/
public AbstractYarnTask(TaskProps taskProps, Logger logger) {
public AbstractYarnTask(TaskProps taskProps, Logger logger,ProcessDao processDao) {
super(taskProps, logger);
this.processDao = DaoFactory.getDaoInstance(ProcessDao.class);
this.processDao = processDao;
this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
taskProps.getTaskDir(),
taskProps.getTaskAppId(),
......
......@@ -18,6 +18,7 @@ package org.apache.dolphinscheduler.server.worker.task;
import org.apache.dolphinscheduler.common.enums.TaskType;
import org.apache.dolphinscheduler.dao.ProcessDao;
import org.apache.dolphinscheduler.server.worker.task.dependent.DependentTask;
import org.apache.dolphinscheduler.server.worker.task.flink.FlinkTask;
import org.apache.dolphinscheduler.server.worker.task.http.HttpTask;
......@@ -44,27 +45,27 @@ public class TaskManager {
* @return
* @throws IllegalArgumentException
*/
public static AbstractTask newTask(String taskType, TaskProps props, Logger logger)
public static AbstractTask newTask(String taskType, TaskProps props, Logger logger,ProcessDao processDao)
throws IllegalArgumentException {
switch (EnumUtils.getEnum(TaskType.class,taskType)) {
case SHELL:
return new ShellTask(props, logger);
return new ShellTask(props, logger,processDao);
case PROCEDURE:
return new ProcedureTask(props, logger);
return new ProcedureTask(props, logger,processDao);
case SQL:
return new SqlTask(props, logger);
return new SqlTask(props, logger,processDao);
case MR:
return new MapReduceTask(props, logger);
return new MapReduceTask(props, logger,processDao);
case SPARK:
return new SparkTask(props, logger);
return new SparkTask(props, logger,processDao);
case FLINK:
return new FlinkTask(props, logger);
return new FlinkTask(props, logger,processDao);
case PYTHON:
return new PythonTask(props, logger);
return new PythonTask(props, logger,processDao);
case DEPENDENT:
return new DependentTask(props, logger);
return new DependentTask(props, logger,processDao);
case HTTP:
return new HttpTask(props, logger);
return new HttpTask(props, logger,processDao);
default:
logger.error("unsupport task type: {}", taskType);
throw new IllegalArgumentException("not support task type");
......
......@@ -52,8 +52,9 @@ public class DependentTask extends AbstractTask {
private ProcessDao processDao;
public DependentTask(TaskProps props, Logger logger) {
public DependentTask(TaskProps props, Logger logger,ProcessDao processDao) {
super(props, logger);
this.processDao = processDao;
}
@Override
......@@ -68,7 +69,7 @@ public class DependentTask extends AbstractTask {
taskModel.getDependItemList(), taskModel.getRelation()));
}
this.processDao = DaoFactory.getDaoInstance(ProcessDao.class);
if(taskProps.getScheduleTime() != null){
this.dependentDate = taskProps.getScheduleTime();
......
......@@ -21,6 +21,7 @@ import org.apache.dolphinscheduler.common.task.AbstractParameters;
import org.apache.dolphinscheduler.common.task.flink.FlinkParameters;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
import org.apache.dolphinscheduler.dao.ProcessDao;
import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
import org.apache.dolphinscheduler.server.utils.FlinkArgsUtils;
import org.apache.dolphinscheduler.server.utils.ParamUtils;
......@@ -49,8 +50,8 @@ public class FlinkTask extends AbstractYarnTask {
*/
private FlinkParameters flinkParameters;
public FlinkTask(TaskProps props, Logger logger) {
super(props, logger);
public FlinkTask(TaskProps props, Logger logger,ProcessDao processDao) {
super(props, logger,processDao);
}
@Override
......
......@@ -75,9 +75,9 @@ public class HttpTask extends AbstractTask {
protected String output;
public HttpTask(TaskProps props, Logger logger) {
public HttpTask(TaskProps props, Logger logger,ProcessDao processDao) {
super(props, logger);
this.processDao = DaoFactory.getDaoInstance(ProcessDao.class);
this.processDao = processDao;
}
@Override
......
......@@ -23,6 +23,7 @@ import org.apache.dolphinscheduler.common.task.AbstractParameters;
import org.apache.dolphinscheduler.common.task.mr.MapreduceParameters;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
import org.apache.dolphinscheduler.dao.ProcessDao;
import org.apache.dolphinscheduler.server.utils.ParamUtils;
import org.apache.dolphinscheduler.server.worker.task.AbstractYarnTask;
import org.apache.dolphinscheduler.server.worker.task.TaskProps;
......@@ -48,8 +49,8 @@ public class MapReduceTask extends AbstractYarnTask {
* @param props
* @param logger
*/
public MapReduceTask(TaskProps props, Logger logger) {
super(props, logger);
public MapReduceTask(TaskProps props, Logger logger,ProcessDao processDao) {
super(props, logger,processDao);
}
@Override
......
......@@ -64,7 +64,7 @@ public class ProcedureTask extends AbstractTask {
*/
private BaseDataSource baseDataSource;
public ProcedureTask(TaskProps taskProps, Logger logger) {
public ProcedureTask(TaskProps taskProps, Logger logger,ProcessDao processDao) {
super(taskProps, logger);
logger.info("procedure task params {}", taskProps.getTaskParams());
......@@ -76,7 +76,7 @@ public class ProcedureTask extends AbstractTask {
throw new RuntimeException("procedure task params is not valid");
}
this.processDao = DaoFactory.getDaoInstance(ProcessDao.class);
this.processDao = processDao;
}
@Override
......
......@@ -59,7 +59,7 @@ public class PythonTask extends AbstractTask {
private ProcessDao processDao;
public PythonTask(TaskProps taskProps, Logger logger) {
public PythonTask(TaskProps taskProps, Logger logger,ProcessDao processDao) {
super(taskProps, logger);
this.taskDir = taskProps.getTaskDir();
......@@ -73,7 +73,7 @@ public class PythonTask extends AbstractTask {
taskProps.getTaskStartTime(),
taskProps.getTaskTimeout(),
logger);
this.processDao = DaoFactory.getDaoInstance(ProcessDao.class);
this.processDao = processDao;
}
@Override
......
......@@ -61,7 +61,7 @@ public class ShellTask extends AbstractTask {
private ProcessDao processDao;
public ShellTask(TaskProps taskProps, Logger logger) {
public ShellTask(TaskProps taskProps, Logger logger,ProcessDao processDao) {
super(taskProps, logger);
this.taskDir = taskProps.getTaskDir();
......@@ -74,7 +74,7 @@ public class ShellTask extends AbstractTask {
taskProps.getTaskStartTime(),
taskProps.getTaskTimeout(),
logger);
this.processDao = DaoFactory.getDaoInstance(ProcessDao.class);
this.processDao = processDao;
}
@Override
......
......@@ -21,6 +21,7 @@ import org.apache.dolphinscheduler.common.task.AbstractParameters;
import org.apache.dolphinscheduler.common.task.spark.SparkParameters;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
import org.apache.dolphinscheduler.dao.ProcessDao;
import org.apache.dolphinscheduler.server.utils.ParamUtils;
import org.apache.dolphinscheduler.server.utils.SparkArgsUtils;
import org.apache.dolphinscheduler.server.worker.task.AbstractYarnTask;
......@@ -47,8 +48,8 @@ public class SparkTask extends AbstractYarnTask {
*/
private SparkParameters sparkParameters;
public SparkTask(TaskProps props, Logger logger) {
super(props, logger);
public SparkTask(TaskProps props, Logger logger,ProcessDao processDao) {
super(props, logger,processDao);
}
@Override
......
......@@ -47,6 +47,7 @@ import org.apache.dolphinscheduler.server.utils.UDFUtils;
import org.apache.dolphinscheduler.server.worker.task.AbstractTask;
import org.apache.dolphinscheduler.server.worker.task.TaskProps;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import java.sql.*;
import java.util.*;
......@@ -74,6 +75,7 @@ public class SqlTask extends AbstractTask {
/**
* alert dao
*/
@Autowired
private AlertDao alertDao;
/**
......@@ -87,7 +89,7 @@ public class SqlTask extends AbstractTask {
private BaseDataSource baseDataSource;
public SqlTask(TaskProps taskProps, Logger logger) {
public SqlTask(TaskProps taskProps, Logger logger,ProcessDao processDao) {
super(taskProps, logger);
logger.info("sql task params {}", taskProps.getTaskParams());
......@@ -96,8 +98,8 @@ public class SqlTask extends AbstractTask {
if (!sqlParameters.checkParameters()) {
throw new RuntimeException("sql task params is not valid");
}
this.processDao = DaoFactory.getDaoInstance(ProcessDao.class);
this.alertDao = DaoFactory.getDaoInstance(AlertDao.class);
this.processDao = processDao;
// this.alertDao = DaoFactory.getDaoInstance(AlertDao.class);
}
@Override
......
......@@ -79,7 +79,7 @@ public class ShellCommandExecutorTest {
taskInstance.getId()));
AbstractTask task = TaskManager.newTask(taskInstance.getTaskType(), taskProps, taskLogger);
AbstractTask task = TaskManager.newTask(taskInstance.getTaskType(), taskProps, taskLogger,null);
logger.info("task info : {}", task);
......
......@@ -122,7 +122,7 @@ public class SqlExecutorTest {
taskInstance.getId()));
AbstractTask task = TaskManager.newTask(taskInstance.getTaskType(), taskProps, taskLogger);
AbstractTask task = TaskManager.newTask(taskInstance.getTaskType(), taskProps, taskLogger,null);
logger.info("task info : {}", task);
......
......@@ -52,7 +52,7 @@ public class DependentTaskTest {
taskProps.setTaskInstId(252612);
taskProps.setDependence(dependString);
DependentTask dependentTask = new DependentTask(taskProps, logger);
DependentTask dependentTask = new DependentTask(taskProps, logger,null);
dependentTask.init();
dependentTask.handle();
Assert.assertEquals(dependentTask.getExitStatusCode(), Constants.EXIT_CODE_FAILURE );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册