Example #1
0
        public override Allocation Allocate(ApplicationAttemptId applicationAttemptId, IList
                                            <ResourceRequest> ask, IList <ContainerId> release, IList <string> blacklistAdditions
                                            , IList <string> blacklistRemovals)
        {
            FiCaSchedulerApp application = GetApplicationAttempt(applicationAttemptId);

            if (application == null)
            {
                Log.Error("Calling allocate on removed " + "or non existant application " + applicationAttemptId
                          );
                return(EmptyAllocation);
            }
            // Sanity check
            SchedulerUtils.NormalizeRequests(ask, resourceCalculator, clusterResource, minimumAllocation
                                             , GetMaximumResourceCapability());
            // Release containers
            ReleaseContainers(release, application);
            lock (application)
            {
                // make sure we aren't stopping/removing the application
                // when the allocate comes in
                if (application.IsStopped())
                {
                    Log.Info("Calling allocate on a stopped " + "application " + applicationAttemptId
                             );
                    return(EmptyAllocation);
                }
                if (!ask.IsEmpty())
                {
                    Log.Debug("allocate: pre-update" + " applicationId=" + applicationAttemptId + " application="
                              + application);
                    application.ShowRequests();
                    // Update application requests
                    application.UpdateResourceRequests(ask);
                    Log.Debug("allocate: post-update" + " applicationId=" + applicationAttemptId + " application="
                              + application);
                    application.ShowRequests();
                    Log.Debug("allocate:" + " applicationId=" + applicationAttemptId + " #ask=" + ask
                              .Count);
                }
                application.UpdateBlacklist(blacklistAdditions, blacklistRemovals);
                SchedulerApplicationAttempt.ContainersAndNMTokensAllocation allocation = application
                                                                                         .PullNewlyAllocatedContainersAndNMTokens();
                Org.Apache.Hadoop.Yarn.Api.Records.Resource headroom = application.GetHeadroom();
                application.SetApplicationHeadroomForMetrics(headroom);
                return(new Allocation(allocation.GetContainerList(), headroom, null, null, null,
                                      allocation.GetNMTokenList()));
            }
        }