Esempio n. 1
0
 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);
     }
 }
Esempio n. 2
0
 private void UnreserveInternal(Priority priority, FSSchedulerNode node)
 {
     lock (this)
     {
         IDictionary <NodeId, RMContainer> reservedContainers = this.reservedContainers[priority
                                                                ];
         RMContainer reservedContainer = Sharpen.Collections.Remove(reservedContainers, node
                                                                    .GetNodeID());
         if (reservedContainers.IsEmpty())
         {
             Sharpen.Collections.Remove(this.reservedContainers, priority);
         }
         // Reset the re-reservation count
         ResetReReservations(priority);
         Org.Apache.Hadoop.Yarn.Api.Records.Resource resource = reservedContainer.GetContainer
                                                                    ().GetResource();
         Resources.SubtractFrom(currentReservation, resource);
         Log.Info("Application " + GetApplicationId() + " unreserved " + " on node " + node
                  + ", currently has " + reservedContainers.Count + " at priority " + priority +
                  "; currentReservation " + currentReservation);
     }
 }