public virtual void ContainerCompleted(RMContainer rmContainer, ContainerStatus containerStatus , RMContainerEventType @event) { lock (this) { Container container = rmContainer.GetContainer(); ContainerId containerId = container.GetId(); // Remove from the list of newly allocated containers if found newlyAllocatedContainers.Remove(rmContainer); // Inform the container rmContainer.Handle(new RMContainerFinishedEvent(containerId, containerStatus, @event )); Log.Info("Completed container: " + rmContainer.GetContainerId() + " in state: " + rmContainer.GetState() + " event:" + @event); // Remove from the list of containers Sharpen.Collections.Remove(liveContainers, rmContainer.GetContainerId()); RMAuditLogger.LogSuccess(GetUser(), RMAuditLogger.AuditConstants.ReleaseContainer , "SchedulerApp", GetApplicationId(), containerId); // Update usage metrics Org.Apache.Hadoop.Yarn.Api.Records.Resource containerResource = rmContainer.GetContainer ().GetResource(); queue.GetMetrics().ReleaseResources(GetUser(), 1, containerResource); Resources.SubtractFrom(currentConsumption, containerResource); // remove from preemption map if it is completed Sharpen.Collections.Remove(preemptionMap, rmContainer); // Clear resource utilization metrics cache. lastMemoryAggregateAllocationUpdateTime = -1; } }
public virtual RMContainer Allocate(NodeType type, FSSchedulerNode node, Priority priority, ResourceRequest request, Container container) { lock (this) { // Update allowed locality level NodeType allowed = allowedLocalityLevel[priority]; if (allowed != null) { if (allowed.Equals(NodeType.OffSwitch) && (type.Equals(NodeType.NodeLocal) || type .Equals(NodeType.RackLocal))) { this.ResetAllowedLocalityLevel(priority, type); } else { if (allowed.Equals(NodeType.RackLocal) && type.Equals(NodeType.NodeLocal)) { this.ResetAllowedLocalityLevel(priority, type); } } } // Required sanity check - AM can call 'allocate' to update resource // request without locking the scheduler, hence we need to check if (GetTotalRequiredResources(priority) <= 0) { return(null); } // Create RMContainer RMContainer rmContainer = new RMContainerImpl(container, GetApplicationAttemptId( ), node.GetNodeID(), appSchedulingInfo.GetUser(), rmContext); // Add it to allContainers list. newlyAllocatedContainers.AddItem(rmContainer); liveContainers[container.GetId()] = rmContainer; // Update consumption and track allocations IList <ResourceRequest> resourceRequestList = appSchedulingInfo.Allocate(type, node , priority, request, container); Resources.AddTo(currentConsumption, container.GetResource()); // Update resource requests related to "request" and store in RMContainer ((RMContainerImpl)rmContainer).SetResourceRequests(resourceRequestList); // Inform the container rmContainer.Handle(new RMContainerEvent(container.GetId(), RMContainerEventType.Start )); if (Log.IsDebugEnabled()) { Log.Debug("allocate: applicationAttemptId=" + container.GetId().GetApplicationAttemptId () + " container=" + container.GetId() + " host=" + container.GetNodeId().GetHost () + " type=" + type); } RMAuditLogger.LogSuccess(GetUser(), RMAuditLogger.AuditConstants.AllocContainer, "SchedulerApp", GetApplicationId(), container.GetId()); return(rmContainer); } }