Browse Source

Add alertDao to spring management in master (#976)

* rename from DatasourceUserMapper to DataSourceUserMapper

* add unit test in UserMapper and WorkerGroupMapper

* change cn.escheduler to org.apache.dolphinscheduler

* add unit test in UdfFuncMapperTest

* add unit test in UdfFuncMapperTest

* remove DatabaseConfiguration

* add ConnectionFactoryTest

* cal duration in processInstancesList

* change desc to description

* change table name in mysql ddl

* change table name in mysql ddl

* change escheduler to dolphinscheduler

* change escheduler to dolphinscheduler

* change escheduler to dolphinscheduler

* remove log4j-1.2-api and modify AlertMapperTest

* remove log4j-1.2-api

* Add alertDao to spring management
pull/2/head
lgcareer 5 years ago committed by qiaozhanwei
parent
commit
b9157e1d8c
  1. 10
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java
  2. 13
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java

10
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java

@ -21,6 +21,7 @@ import org.apache.dolphinscheduler.common.thread.Stopper;
import org.apache.dolphinscheduler.common.thread.ThreadPoolExecutors; import org.apache.dolphinscheduler.common.thread.ThreadPoolExecutors;
import org.apache.dolphinscheduler.common.thread.ThreadUtils; import org.apache.dolphinscheduler.common.thread.ThreadUtils;
import org.apache.dolphinscheduler.common.utils.OSUtils; import org.apache.dolphinscheduler.common.utils.OSUtils;
import org.apache.dolphinscheduler.dao.AlertDao;
import org.apache.dolphinscheduler.dao.ProcessDao; import org.apache.dolphinscheduler.dao.ProcessDao;
import org.apache.dolphinscheduler.server.master.runner.MasterSchedulerThread; import org.apache.dolphinscheduler.server.master.runner.MasterSchedulerThread;
import org.apache.dolphinscheduler.server.quartz.ProcessScheduleJob; import org.apache.dolphinscheduler.server.quartz.ProcessScheduleJob;
@ -64,6 +65,9 @@ public class MasterServer extends AbstractServer {
@Autowired @Autowired
protected ProcessDao processDao; protected ProcessDao processDao;
@Autowired
protected AlertDao alertDao;
/** /**
* master exec thread pool * master exec thread pool
*/ */
@ -71,14 +75,14 @@ public class MasterServer extends AbstractServer {
public MasterServer(){} public MasterServer(){}
public MasterServer(ProcessDao processDao){ public MasterServer(ProcessDao processDao,AlertDao alertDao){
try { try {
conf = new PropertiesConfiguration(Constants.MASTER_PROPERTIES_PATH); conf = new PropertiesConfiguration(Constants.MASTER_PROPERTIES_PATH);
}catch (ConfigurationException e){ }catch (ConfigurationException e){
logger.error("load configuration failed : " + e.getMessage(),e); logger.error("load configuration failed : " + e.getMessage(),e);
System.exit(1); System.exit(1);
} }
zkMasterClient = ZKMasterClient.getZKMasterClient(processDao); zkMasterClient = ZKMasterClient.getZKMasterClient(processDao,alertDao);
this.masterSchedulerService = ThreadUtils.newDaemonSingleThreadExecutor("Master-Scheduler-Thread"); this.masterSchedulerService = ThreadUtils.newDaemonSingleThreadExecutor("Master-Scheduler-Thread");
} }
@ -98,7 +102,7 @@ public class MasterServer extends AbstractServer {
@Override @Override
public void run(String... strings) throws Exception { public void run(String... strings) throws Exception {
MasterServer masterServer = new MasterServer(processDao); MasterServer masterServer = new MasterServer(processDao,alertDao);
masterServer.run(processDao); masterServer.run(processDao);

13
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java

@ -85,11 +85,12 @@ public class ZKMasterClient extends AbstractZKClient {
* @param processDao * @param processDao
* @return * @return
*/ */
public static synchronized ZKMasterClient getZKMasterClient(ProcessDao processDao){ public static synchronized ZKMasterClient getZKMasterClient(ProcessDao processDao,AlertDao alertDao){
if(zkMasterClient == null){ if(zkMasterClient == null){
zkMasterClient = new ZKMasterClient(processDao); zkMasterClient = new ZKMasterClient(processDao);
} }
zkMasterClient.processDao = processDao; zkMasterClient.processDao = processDao;
zkMasterClient.alertDao = alertDao;
return zkMasterClient; return zkMasterClient;
} }
@ -98,8 +99,6 @@ public class ZKMasterClient extends AbstractZKClient {
* init * init
*/ */
public void init(){ public void init(){
// init dao
this.initDao();
InterProcessMutex mutex = null; InterProcessMutex mutex = null;
try { try {
@ -135,14 +134,6 @@ public class ZKMasterClient extends AbstractZKClient {
/**
* init dao
*/
public void initDao(){
this.alertDao = DaoFactory.getDaoInstance(AlertDao.class);
// this.processDao = DaoFactory.getDaoInstance(ProcessDao.class);
}
/** /**
* get alert dao * get alert dao
* @return * @return

Loading…
Cancel
Save