Example #1
0
 public virtual bool Unreserve(FiCaSchedulerNode node, Priority priority)
 {
     lock (this)
     {
         IDictionary <NodeId, RMContainer> reservedContainers = this.reservedContainers[priority
                                                                ];
         if (reservedContainers != null)
         {
             RMContainer reservedContainer = Sharpen.Collections.Remove(reservedContainers, node
                                                                        .GetNodeID());
             // unreserve is now triggered in new scenarios (preemption)
             // as a consequence reservedcontainer might be null, adding NP-checks
             if (reservedContainer != null && reservedContainer.GetContainer() != null && reservedContainer
                 .GetContainer().GetResource() != null)
             {
                 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);
                 return(true);
             }
         }
         return(false);
     }
 }
Example #2
0
 public virtual RMContainer Allocate(NodeType type, FiCaSchedulerNode node, Priority
                                     priority, ResourceRequest request, Container container)
 {
     lock (this)
     {
         if (isStopped)
         {
             return(null);
         }
         // 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, this.GetApplicationAttemptId
                                                           (), node.GetNodeID(), appSchedulingInfo.GetUser(), this.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);
     }
 }
 public static bool IsBlacklisted(FiCaSchedulerApp application, FiCaSchedulerNode
                                  node, Log Log)
 {
     if (application.IsBlacklisted(node.GetNodeName()))
     {
         if (Log.IsDebugEnabled())
         {
             Log.Debug("Skipping 'host' " + node.GetNodeName() + " for " + application.GetApplicationId
                           () + " since it has been blacklisted");
         }
         return(true);
     }
     if (application.IsBlacklisted(node.GetRackName()))
     {
         if (Log.IsDebugEnabled())
         {
             Log.Debug("Skipping 'rack' " + node.GetRackName() + " for " + application.GetApplicationId
                           () + " since it has been blacklisted");
         }
         return(true);
     }
     return(false);
 }