Browse Source

sleep when resource in not satisfy. fix #1522 (#1523)

* fix #1515

* sleep when resource in not satisfy. fix #1522

* add sleep 1s for no command
pull/2/head
Tboy 5 years ago committed by dailidong
parent
commit
076ccbdb9b
  1. 14
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterSchedulerThread.java

14
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterSchedulerThread.java

@ -98,7 +98,11 @@ public class MasterSchedulerThread implements Runnable {
InterProcessMutex mutex = null; InterProcessMutex mutex = null;
try { try {
if(OSUtils.checkResource(masterConfig.getMasterMaxCpuloadAvg(), masterConfig.getMasterReservedMemory())){ boolean runCheckFlag = OSUtils.checkResource(masterConfig.getMasterMaxCpuloadAvg(), masterConfig.getMasterReservedMemory());
if(!runCheckFlag) {
Thread.sleep(Constants.SLEEP_TIME_MILLIS);
continue;
}
if (zkMasterClient.getZkClient().getState() == CuratorFrameworkState.STARTED) { if (zkMasterClient.getZkClient().getState() == CuratorFrameworkState.STARTED) {
// create distributed lock with the root node path of the lock space as /dolphinscheduler/lock/masters // create distributed lock with the root node path of the lock space as /dolphinscheduler/lock/masters
@ -124,13 +128,11 @@ public class MasterSchedulerThread implements Runnable {
logger.error("scan command error ", e); logger.error("scan command error ", e);
processDao.moveToErrorCommand(command, e.toString()); processDao.moveToErrorCommand(command, e.toString());
} }
} else{
//indicate that no command ,sleep for 1s
Thread.sleep(Constants.SLEEP_TIME_MILLIS);
} }
} }
}
// accessing the command table every SLEEP_TIME_MILLIS milliseconds
Thread.sleep(Constants.SLEEP_TIME_MILLIS);
}catch (Exception e){ }catch (Exception e){
logger.error("master scheduler thread exception : " + e.getMessage(),e); logger.error("master scheduler thread exception : " + e.getMessage(),e);
}finally{ }finally{

Loading…
Cancel
Save