예제 #1
0
 public FSLeafQueue(string name, FairScheduler scheduler, FSParentQueue parent)
     : base(name, scheduler, parent)
 {
     // apps that are runnable
     // get a lock with fair distribution for app list updates
     // Variables used for preemption
     // Track the AM resource usage for this queue
     this.lastTimeAtMinShare           = scheduler.GetClock().GetTime();
     this.lastTimeAtFairShareThreshold = scheduler.GetClock().GetTime();
     activeUsersManager = new ActiveUsersManager(GetMetrics());
     amResourceUsage    = Org.Apache.Hadoop.Yarn.Api.Records.Resource.NewInstance(0, 0);
 }
예제 #2
0
        public virtual void TestHeadroom()
        {
            FairScheduler mockScheduler = Org.Mockito.Mockito.Mock <FairScheduler>();

            Org.Mockito.Mockito.When(mockScheduler.GetClock()).ThenReturn(scheduler.GetClock(
                                                                              ));
            FSLeafQueue mockQueue         = Org.Mockito.Mockito.Mock <FSLeafQueue>();
            Resource    queueMaxResources = Resource.NewInstance(5 * 1024, 3);

            Org.Apache.Hadoop.Yarn.Api.Records.Resource queueFairShare = Resources.CreateResource
                                                                             (4096, 2);
            Org.Apache.Hadoop.Yarn.Api.Records.Resource queueUsage = Org.Apache.Hadoop.Yarn.Api.Records.Resource
                                                                     .NewInstance(2048, 2);
            Org.Apache.Hadoop.Yarn.Api.Records.Resource queueStarvation = Resources.Subtract(
                queueFairShare, queueUsage);
            Org.Apache.Hadoop.Yarn.Api.Records.Resource queueMaxResourcesAvailable = Resources
                                                                                     .Subtract(queueMaxResources, queueUsage);
            Org.Apache.Hadoop.Yarn.Api.Records.Resource clusterResource = Resources.CreateResource
                                                                              (8192, 8);
            Org.Apache.Hadoop.Yarn.Api.Records.Resource clusterUsage = Resources.CreateResource
                                                                           (2048, 2);
            Org.Apache.Hadoop.Yarn.Api.Records.Resource clusterAvailable = Resources.Subtract
                                                                               (clusterResource, clusterUsage);
            QueueMetrics fakeRootQueueMetrics = Org.Mockito.Mockito.Mock <QueueMetrics>();

            Org.Mockito.Mockito.When(mockQueue.GetMaxShare()).ThenReturn(queueMaxResources);
            Org.Mockito.Mockito.When(mockQueue.GetFairShare()).ThenReturn(queueFairShare);
            Org.Mockito.Mockito.When(mockQueue.GetResourceUsage()).ThenReturn(queueUsage);
            Org.Mockito.Mockito.When(mockScheduler.GetClusterResource()).ThenReturn(clusterResource
                                                                                    );
            Org.Mockito.Mockito.When(fakeRootQueueMetrics.GetAllocatedResources()).ThenReturn
                (clusterUsage);
            Org.Mockito.Mockito.When(mockScheduler.GetRootQueueMetrics()).ThenReturn(fakeRootQueueMetrics
                                                                                     );
            ApplicationAttemptId applicationAttemptId = CreateAppAttemptId(1, 1);
            RMContext            rmContext            = resourceManager.GetRMContext();
            FSAppAttempt         schedulerApp         = new FSAppAttempt(mockScheduler, applicationAttemptId,
                                                                         "user1", mockQueue, null, rmContext);

            // Min of Memory and CPU across cluster and queue is used in
            // DominantResourceFairnessPolicy
            Org.Mockito.Mockito.When(mockQueue.GetPolicy()).ThenReturn(SchedulingPolicy.GetInstance
                                                                           (typeof(DominantResourceFairnessPolicy)));
            VerifyHeadroom(schedulerApp, Min(queueStarvation.GetMemory(), clusterAvailable.GetMemory
                                                 (), queueMaxResourcesAvailable.GetMemory()), Min(queueStarvation.GetVirtualCores
                                                                                                      (), clusterAvailable.GetVirtualCores(), queueMaxResourcesAvailable.GetVirtualCores
                                                                                                      ()));
            // Fair and Fifo ignore CPU of queue, so use cluster available CPU
            Org.Mockito.Mockito.When(mockQueue.GetPolicy()).ThenReturn(SchedulingPolicy.GetInstance
                                                                           (typeof(FairSharePolicy)));
            VerifyHeadroom(schedulerApp, Min(queueStarvation.GetMemory(), clusterAvailable.GetMemory
                                                 (), queueMaxResourcesAvailable.GetMemory()), Math.Min(clusterAvailable.GetVirtualCores
                                                                                                           (), queueMaxResourcesAvailable.GetVirtualCores()));
            Org.Mockito.Mockito.When(mockQueue.GetPolicy()).ThenReturn(SchedulingPolicy.GetInstance
                                                                           (typeof(FifoPolicy)));
            VerifyHeadroom(schedulerApp, Min(queueStarvation.GetMemory(), clusterAvailable.GetMemory
                                                 (), queueMaxResourcesAvailable.GetMemory()), Math.Min(clusterAvailable.GetVirtualCores
                                                                                                           (), queueMaxResourcesAvailable.GetVirtualCores()));
        }
예제 #3
0
 public FSAppAttempt(FairScheduler scheduler, ApplicationAttemptId applicationAttemptId
                     , string user, FSLeafQueue queue, ActiveUsersManager activeUsersManager, RMContext
                     rmContext)
     : base(applicationAttemptId, user, queue, activeUsersManager, rmContext)
 {
     this.scheduler       = scheduler;
     this.startTime       = scheduler.GetClock().GetTime();
     this.priority        = Priority.NewInstance(1);
     this.resourceWeights = new ResourceWeights();
 }
예제 #4
0
        public virtual void SetUp()
        {
            conf = new FairSchedulerConfiguration();
            FairScheduler           scheduler = Org.Mockito.Mockito.Mock <FairScheduler>();
            AllocationConfiguration allocConf = new AllocationConfiguration(conf);

            Org.Mockito.Mockito.When(scheduler.GetAllocationConfiguration()).ThenReturn(allocConf
                                                                                        );
            Org.Mockito.Mockito.When(scheduler.GetConf()).ThenReturn(conf);
            SystemClock clock = new SystemClock();

            Org.Mockito.Mockito.When(scheduler.GetClock()).ThenReturn(clock);
            notEmptyQueues = new HashSet <FSQueue>();
            queueManager   = new _QueueManager_47(this, scheduler);
            FSQueueMetrics.ForQueue("root", null, true, conf);
            queueManager.Initialize(conf);
        }
        public virtual void Setup()
        {
            Configuration conf = new Configuration();

            clock     = new FairSchedulerTestBase.MockClock();
            scheduler = Org.Mockito.Mockito.Mock <FairScheduler>();
            Org.Mockito.Mockito.When(scheduler.GetConf()).ThenReturn(new FairSchedulerConfiguration
                                                                         (conf));
            Org.Mockito.Mockito.When(scheduler.GetClock()).ThenReturn(clock);
            AllocationConfiguration allocConf = new AllocationConfiguration(conf);

            Org.Mockito.Mockito.When(scheduler.GetAllocationConfiguration()).ThenReturn(allocConf
                                                                                        );
            queueManager = new QueueManager(scheduler);
            queueManager.Initialize(conf);
            queueMaxApps    = allocConf.queueMaxApps;
            userMaxApps     = allocConf.userMaxApps;
            maxAppsEnforcer = new MaxRunningAppsEnforcer(scheduler);
            appNum          = 0;
            rmContext       = Org.Mockito.Mockito.Mock <RMContext>();
            Org.Mockito.Mockito.When(rmContext.GetEpoch()).ThenReturn(0L);
        }
예제 #6
0
        private Org.Apache.Hadoop.Yarn.Api.Records.Resource AssignContainer(FSSchedulerNode
                                                                            node, bool reserved)
        {
            if (Log.IsDebugEnabled())
            {
                Log.Debug("Node offered to app: " + GetName() + " reserved: " + reserved);
            }
            ICollection <Priority> prioritiesToTry = (reserved) ? Arrays.AsList(node.GetReservedContainer
                                                                                    ().GetReservedPriority()) : GetPriorities();

            // For each priority, see if we can schedule a node local, rack local
            // or off-switch request. Rack of off-switch requests may be delayed
            // (not scheduled) in order to promote better locality.
            lock (this)
            {
                foreach (Priority priority in prioritiesToTry)
                {
                    if (GetTotalRequiredResources(priority) <= 0 || !HasContainerForNode(priority, node
                                                                                         ))
                    {
                        continue;
                    }
                    AddSchedulingOpportunity(priority);
                    // Check the AM resource usage for the leaf queue
                    if (GetLiveContainers().Count == 0 && !GetUnmanagedAM())
                    {
                        if (!((FSLeafQueue)GetQueue()).CanRunAppAM(GetAMResource()))
                        {
                            return(Resources.None());
                        }
                    }
                    ResourceRequest rackLocalRequest = GetResourceRequest(priority, node.GetRackName(
                                                                              ));
                    ResourceRequest localRequest = GetResourceRequest(priority, node.GetNodeName());
                    if (localRequest != null && !localRequest.GetRelaxLocality())
                    {
                        Log.Warn("Relax locality off is not supported on local request: " + localRequest);
                    }
                    NodeType allowedLocality;
                    if (scheduler.IsContinuousSchedulingEnabled())
                    {
                        allowedLocality = GetAllowedLocalityLevelByTime(priority, scheduler.GetNodeLocalityDelayMs
                                                                            (), scheduler.GetRackLocalityDelayMs(), scheduler.GetClock().GetTime());
                    }
                    else
                    {
                        allowedLocality = GetAllowedLocalityLevel(priority, scheduler.GetNumClusterNodes(
                                                                      ), scheduler.GetNodeLocalityThreshold(), scheduler.GetRackLocalityThreshold());
                    }
                    if (rackLocalRequest != null && rackLocalRequest.GetNumContainers() != 0 && localRequest
                        != null && localRequest.GetNumContainers() != 0)
                    {
                        return(AssignContainer(node, localRequest, NodeType.NodeLocal, reserved));
                    }
                    if (rackLocalRequest != null && !rackLocalRequest.GetRelaxLocality())
                    {
                        continue;
                    }
                    if (rackLocalRequest != null && rackLocalRequest.GetNumContainers() != 0 && (allowedLocality
                                                                                                 .Equals(NodeType.RackLocal) || allowedLocality.Equals(NodeType.OffSwitch)))
                    {
                        return(AssignContainer(node, rackLocalRequest, NodeType.RackLocal, reserved));
                    }
                    ResourceRequest offSwitchRequest = GetResourceRequest(priority, ResourceRequest.Any
                                                                          );
                    if (offSwitchRequest != null && !offSwitchRequest.GetRelaxLocality())
                    {
                        continue;
                    }
                    if (offSwitchRequest != null && offSwitchRequest.GetNumContainers() != 0)
                    {
                        if (!HasNodeOrRackLocalRequests(priority) || allowedLocality.Equals(NodeType.OffSwitch
                                                                                            ))
                        {
                            return(AssignContainer(node, offSwitchRequest, NodeType.OffSwitch, reserved));
                        }
                    }
                }
            }
            return(Resources.None());
        }