Commit 076ccbdb authored by Tboy's avatar Tboy Committed by dailidong
Browse files

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
parent b859be48
Loading
Loading
Loading
Loading
+31 −29
Original line number Diff line number Diff line
@@ -98,7 +98,11 @@ public class MasterSchedulerThread implements Runnable {
            InterProcessMutex mutex = null;
            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) {

                    // 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);
                            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){
                logger.error("master scheduler thread exception : " + e.getMessage(),e);
            }finally{