示例#1
0
 public SchedulerApplicationAttempt(ApplicationAttemptId applicationAttemptId, string
                                    user, Queue queue, ActiveUsersManager activeUsersManager, RMContext rmContext)
 {
     // This pendingRelease is used in work-preserving recovery scenario to keep
     // track of the AM's outstanding release requests. RM on recovery could
     // receive the release request form AM before it receives the container status
     // from NM for recovery. In this case, the to-be-recovered containers reported
     // by NM should not be recovered.
     // Time of the last container scheduled at the current allowed level
     Preconditions.CheckNotNull(rmContext, "RMContext should not be null");
     this.rmContext         = rmContext;
     this.appSchedulingInfo = new AppSchedulingInfo(applicationAttemptId, user, queue,
                                                    activeUsersManager, rmContext.GetEpoch());
     this.queue          = queue;
     this.pendingRelease = new HashSet <ContainerId>();
     this.attemptId      = applicationAttemptId;
     if (rmContext.GetRMApps() != null && rmContext.GetRMApps().Contains(applicationAttemptId
                                                                         .GetApplicationId()))
     {
         ApplicationSubmissionContext appSubmissionContext = rmContext.GetRMApps()[applicationAttemptId
                                                                                   .GetApplicationId()].GetApplicationSubmissionContext();
         if (appSubmissionContext != null)
         {
             unmanagedAM = appSubmissionContext.GetUnmanagedAM();
             this.logAggregationContext = appSubmissionContext.GetLogAggregationContext();
         }
     }
 }
        public virtual void TestMove()
        {
            string               user          = "******";
            Queue                parentQueue   = CreateQueue("parent", null);
            Queue                oldQueue      = CreateQueue("old", parentQueue);
            Queue                newQueue      = CreateQueue("new", parentQueue);
            QueueMetrics         parentMetrics = parentQueue.GetMetrics();
            QueueMetrics         oldMetrics    = oldQueue.GetMetrics();
            QueueMetrics         newMetrics    = newQueue.GetMetrics();
            ApplicationAttemptId appAttId      = CreateAppAttemptId(0, 0);
            RMContext            rmContext     = Org.Mockito.Mockito.Mock <RMContext>();

            Org.Mockito.Mockito.When(rmContext.GetEpoch()).ThenReturn(3L);
            SchedulerApplicationAttempt app = new SchedulerApplicationAttempt(appAttId, user,
                                                                              oldQueue, oldQueue.GetActiveUsersManager(), rmContext);

            oldMetrics.SubmitApp(user);
            // confirm that containerId is calculated based on epoch.
            NUnit.Framework.Assert.AreEqual(unchecked ((long)(0x30000000001L)), app.GetNewContainerId
                                                ());
            // Resource request
            Resource        requestedResource = Resource.NewInstance(1536, 2);
            Priority        requestedPriority = Priority.NewInstance(2);
            ResourceRequest request           = ResourceRequest.NewInstance(requestedPriority, ResourceRequest
                                                                            .Any, requestedResource, 3);

            app.UpdateResourceRequests(Arrays.AsList(request));
            // Allocated container
            RMContainer container1 = CreateRMContainer(appAttId, 1, requestedResource);

            app.liveContainers[container1.GetContainerId()] = container1;
            SchedulerNode node = CreateNode();

            app.appSchedulingInfo.Allocate(NodeType.OffSwitch, node, requestedPriority, request
                                           , container1.GetContainer());
            // Reserved container
            Priority    prio1            = Priority.NewInstance(1);
            Resource    reservedResource = Resource.NewInstance(2048, 3);
            RMContainer container2       = CreateReservedRMContainer(appAttId, 1, reservedResource,
                                                                     node.GetNodeID(), prio1);
            IDictionary <NodeId, RMContainer> reservations = new Dictionary <NodeId, RMContainer
                                                                             >();

            reservations[node.GetNodeID()] = container2;
            app.reservedContainers[prio1]  = reservations;
            oldMetrics.ReserveResource(user, reservedResource);
            CheckQueueMetrics(oldMetrics, 1, 1, 1536, 2, 2048, 3, 3072, 4);
            CheckQueueMetrics(newMetrics, 0, 0, 0, 0, 0, 0, 0, 0);
            CheckQueueMetrics(parentMetrics, 1, 1, 1536, 2, 2048, 3, 3072, 4);
            app.Move(newQueue);
            CheckQueueMetrics(oldMetrics, 0, 0, 0, 0, 0, 0, 0, 0);
            CheckQueueMetrics(newMetrics, 1, 1, 1536, 2, 2048, 3, 3072, 4);
            CheckQueueMetrics(parentMetrics, 1, 1, 1536, 2, 2048, 3, 3072, 4);
        }
        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);
        }