Ejemplo n.º 1
0
 /// <summary>
 /// This method produces an Allocation that includes the current view
 /// of the resources that will be allocated to and preempted from this
 /// application.
 /// </summary>
 /// <param name="rc"/>
 /// <param name="clusterResource"/>
 /// <param name="minimumAllocation"/>
 /// <returns>an allocation</returns>
 public virtual Allocation GetAllocation(ResourceCalculator rc, Org.Apache.Hadoop.Yarn.Api.Records.Resource
                                         clusterResource, Org.Apache.Hadoop.Yarn.Api.Records.Resource minimumAllocation)
 {
     lock (this)
     {
         ICollection <ContainerId> currentContPreemption = Sharpen.Collections.UnmodifiableSet
                                                               (new HashSet <ContainerId>(containersToPreempt));
         containersToPreempt.Clear();
         Org.Apache.Hadoop.Yarn.Api.Records.Resource tot = Org.Apache.Hadoop.Yarn.Api.Records.Resource
                                                           .NewInstance(0, 0);
         foreach (ContainerId c in currentContPreemption)
         {
             Resources.AddTo(tot, liveContainers[c].GetContainer().GetResource());
         }
         int numCont = (int)Math.Ceil(Resources.Divide(rc, clusterResource, tot, minimumAllocation
                                                       ));
         ResourceRequest rr = ResourceRequest.NewInstance(Priority.Undefined, ResourceRequest
                                                          .Any, minimumAllocation, numCont);
         SchedulerApplicationAttempt.ContainersAndNMTokensAllocation allocation = PullNewlyAllocatedContainersAndNMTokens
                                                                                      ();
         Org.Apache.Hadoop.Yarn.Api.Records.Resource headroom = GetHeadroom();
         SetApplicationHeadroomForMetrics(headroom);
         return(new Allocation(allocation.GetContainerList(), headroom, null, currentContPreemption
                               , Sharpen.Collections.SingletonList(rr), allocation.GetNMTokenList()));
     }
 }
Ejemplo n.º 2
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()));
            }
        }