From 7e22b6a520527dd1729c049d2678a34b2201a2ad Mon Sep 17 00:00:00 2001 From: qiaozhanwei Date: Sat, 25 May 2019 17:11:10 +0800 Subject: [PATCH] master startup fault tolerance update --- .../main/java/cn/escheduler/dao/ProcessDao.java | 14 ++++++++++---- .../cn/escheduler/server/zk/ZKMasterClient.java | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/escheduler-dao/src/main/java/cn/escheduler/dao/ProcessDao.java b/escheduler-dao/src/main/java/cn/escheduler/dao/ProcessDao.java index f8182d692c..09e2149d88 100644 --- a/escheduler-dao/src/main/java/cn/escheduler/dao/ProcessDao.java +++ b/escheduler-dao/src/main/java/cn/escheduler/dao/ProcessDao.java @@ -1377,7 +1377,7 @@ public class ProcessDao extends AbstractBaseDao { * @return */ public List queryNeedFailoverTaskInstances(String host){ - return taskInstanceMapper.queryByHostAndStatus(host,stateArray); + return taskInstanceMapper.queryByHostAndStatus(host, stateArray); } /** @@ -1555,10 +1555,16 @@ public class ProcessDao extends AbstractBaseDao { } - public void selfFaultTolerant(int ... states){ - List processInstanceList = processInstanceMapper.listByStatus(states); + /** + * master starup fault tolerant + */ + public void masterStartupFaultTolerant(){ + + int[] readyStopAndKill=new int[]{ExecutionStatus.READY_PAUSE.ordinal(),ExecutionStatus.READY_STOP.ordinal(), + ExecutionStatus.NEED_FAULT_TOLERANCE.ordinal(),ExecutionStatus.RUNNING_EXEUTION.ordinal()}; + List processInstanceList = processInstanceMapper.listByStatus(readyStopAndKill); for (ProcessInstance processInstance:processInstanceList){ - selfFaultTolerant(processInstance); + processNeedFailoverProcessInstances(processInstance); } } diff --git a/escheduler-server/src/main/java/cn/escheduler/server/zk/ZKMasterClient.java b/escheduler-server/src/main/java/cn/escheduler/server/zk/ZKMasterClient.java index e5ef726f9c..85f9f6a7d2 100644 --- a/escheduler-server/src/main/java/cn/escheduler/server/zk/ZKMasterClient.java +++ b/escheduler-server/src/main/java/cn/escheduler/server/zk/ZKMasterClient.java @@ -134,7 +134,7 @@ public class ZKMasterClient extends AbstractZKClient { // check if fault tolerance is required,failure and tolerance if (getActiveMasterNum() == 1) { - processDao.selfFaultTolerant(ExecutionStatus.RUNNING_EXEUTION.ordinal(),ExecutionStatus.NEED_FAULT_TOLERANCE.ordinal()); + processDao.masterStartupFaultTolerant(); } }catch (Exception e){