本文主要是介绍FairScheduler源码队列饥饿,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
小于最低资源保障量的队列,呈饥饿状态。
protected Resource resToPreempt(FSLeafQueue sched, long curTime) {long minShareTimeout = sched.getMinSharePreemptionTimeout();long fairShareTimeout = sched.getFairSharePreemptionTimeout();Resource resDueToMinShare = Resources.none();Resource resDueToFairShare = Resources.none();if (curTime - sched.getLastTimeAtMinShare() > minShareTimeout) { /sched.getLastTimeAtMinShare(),主要他不是饥饿的就会一直更新该时间Resource target = Resources.min(RESOURCE_CALCULATOR, clusterResource,sched.getMinShare(), sched.getDemand());resDueToMinShare = Resources.max(RESOURCE_CALCULATOR, clusterResource,Resources.none(), Resources.subtract(target, sched.getResourceUsage()));}///FSleafQueuepublic void updateStarvationStats() {long now = scheduler.getClock().getTime();if (!isStarvedForMinShare()) {setLastTimeAtMinShare(now);}if (!isStarvedForFairShare()) {setLastTimeAtFairShareThreshold(now);}}/*** Is a queue being starved for its min share.*/@VisibleForTestingboolean isStarvedForMinShare() {return isStarved(getMinShare());}//是否有问题//1、最低100,当前需要120 ,desiredShare返回100,看已使用是否小于100,这个没问题//2、最低100,当前需要50,,desiredShare返回50,看已使用是否小于50,已使用为40,bug?private boolean isStarved(Resource share) {Resource desiredShare = Resources.min(FairScheduler.getResourceCalculator(),scheduler.getClusterResource(), share, getDemand());/share为最小资源 getDemand如果大于最大资源则取最大资源return Resources.lessThan(FairScheduler.getResourceCalculator(),scheduler.getClusterResource(), getResourceUsage(), desiredShare);}
这篇关于FairScheduler源码队列饥饿的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!