diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java index 601af7f86cd53ebd39b6a8140c1ff94da859a741..c1d1a62674159d1cea4e39c8ff6441e7c22b270a 100644 --- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java +++ b/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.ThreadUtils; import org.apache.dolphinscheduler.common.utils.OSUtils; +import org.apache.dolphinscheduler.dao.AlertDao; import org.apache.dolphinscheduler.dao.ProcessDao; import org.apache.dolphinscheduler.server.master.runner.MasterSchedulerThread; import org.apache.dolphinscheduler.server.quartz.ProcessScheduleJob; @@ -64,6 +65,9 @@ public class MasterServer extends AbstractServer { @Autowired protected ProcessDao processDao; + @Autowired + protected AlertDao alertDao; + /** * master exec thread pool */ @@ -71,14 +75,14 @@ public class MasterServer extends AbstractServer { public MasterServer(){} - public MasterServer(ProcessDao processDao){ + public MasterServer(ProcessDao processDao,AlertDao alertDao){ try { conf = new PropertiesConfiguration(Constants.MASTER_PROPERTIES_PATH); }catch (ConfigurationException e){ logger.error("load configuration failed : " + e.getMessage(),e); System.exit(1); } - zkMasterClient = ZKMasterClient.getZKMasterClient(processDao); + zkMasterClient = ZKMasterClient.getZKMasterClient(processDao,alertDao); this.masterSchedulerService = ThreadUtils.newDaemonSingleThreadExecutor("Master-Scheduler-Thread"); } @@ -98,7 +102,7 @@ public class MasterServer extends AbstractServer { @Override public void run(String... strings) throws Exception { - MasterServer masterServer = new MasterServer(processDao); + MasterServer masterServer = new MasterServer(processDao,alertDao); masterServer.run(processDao); diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java index 90a2679f5b8ec08586c88033d190717e310fa259..409d39a8044b709f34c4930ce44fcf3735c52891 100644 --- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java +++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java @@ -85,11 +85,12 @@ public class ZKMasterClient extends AbstractZKClient { * @param processDao * @return */ - public static synchronized ZKMasterClient getZKMasterClient(ProcessDao processDao){ + public static synchronized ZKMasterClient getZKMasterClient(ProcessDao processDao,AlertDao alertDao){ if(zkMasterClient == null){ zkMasterClient = new ZKMasterClient(processDao); } zkMasterClient.processDao = processDao; + zkMasterClient.alertDao = alertDao; return zkMasterClient; } @@ -98,8 +99,6 @@ public class ZKMasterClient extends AbstractZKClient { * init */ public void init(){ - // init dao - this.initDao(); InterProcessMutex mutex = null; 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 * @return