public virtual void Move(Queue newQueue) { lock (this) { QueueMetrics oldMetrics = queue.GetMetrics(); QueueMetrics newMetrics = newQueue.GetMetrics(); foreach (IDictionary <string, ResourceRequest> asks in requests.Values) { ResourceRequest request = asks[ResourceRequest.Any]; if (request != null) { oldMetrics.DecrPendingResources(user, request.GetNumContainers(), request.GetCapability ()); newMetrics.IncrPendingResources(user, request.GetNumContainers(), request.GetCapability ()); } } oldMetrics.MoveAppFrom(this); newMetrics.MoveAppTo(this); activeUsersManager.DeactivateApplication(user, applicationId); activeUsersManager = newQueue.GetActiveUsersManager(); activeUsersManager.ActivateApplication(user, applicationId); this.queue = newQueue; this.queueName = newQueue.GetQueueName(); } }
/// <summary> /// The ApplicationMaster is updating resource requirements for the /// application, by asking for more resources and releasing resources acquired /// by the application. /// </summary> /// <param name="requests">resources to be acquired</param> /// <param name="recoverPreemptedRequest">recover Resource Request on preemption</param> public virtual void UpdateResourceRequests(IList <ResourceRequest> requests, bool recoverPreemptedRequest) { lock (this) { QueueMetrics metrics = queue.GetMetrics(); // Update resource requests foreach (ResourceRequest request in requests) { Priority priority = request.GetPriority(); string resourceName = request.GetResourceName(); bool updatePendingResources = false; ResourceRequest lastRequest = null; if (resourceName.Equals(ResourceRequest.Any)) { if (Log.IsDebugEnabled()) { Log.Debug("update:" + " application=" + applicationId + " request=" + request); } updatePendingResources = true; // Premature optimization? // Assumes that we won't see more than one priority request updated // in one call, reasonable assumption... however, it's totally safe // to activate same application more than once. // Thus we don't need another loop ala the one in decrementOutstanding() // which is needed during deactivate. if (request.GetNumContainers() > 0) { activeUsersManager.ActivateApplication(user, applicationId); } } IDictionary <string, ResourceRequest> asks = this.requests[priority]; if (asks == null) { asks = new ConcurrentHashMap <string, ResourceRequest>(); this.requests[priority] = asks; this.priorities.AddItem(priority); } lastRequest = asks[resourceName]; if (recoverPreemptedRequest && lastRequest != null) { // Increment the number of containers to 1, as it is recovering a // single container. request.SetNumContainers(lastRequest.GetNumContainers() + 1); } asks[resourceName] = request; if (updatePendingResources) { // Similarly, deactivate application? if (request.GetNumContainers() <= 0) { Log.Info("checking for deactivate of application :" + this.applicationId); CheckForDeactivation(); } int lastRequestContainers = lastRequest != null?lastRequest.GetNumContainers() : 0; Org.Apache.Hadoop.Yarn.Api.Records.Resource lastRequestCapability = lastRequest != null?lastRequest.GetCapability() : Resources.None(); metrics.IncrPendingResources(user, request.GetNumContainers(), request.GetCapability ()); metrics.DecrPendingResources(user, lastRequestContainers, lastRequestCapability); } } } }