public override void ReserveResource(SchedulerApplicationAttempt application, Priority
                                      priority, RMContainer container)
 {
     lock (this)
     {
         // Check if it's already reserved
         RMContainer reservedContainer = GetReservedContainer();
         if (reservedContainer != null)
         {
             // Sanity check
             if (!container.GetContainer().GetNodeId().Equals(GetNodeID()))
             {
                 throw new InvalidOperationException("Trying to reserve" + " container " + container
                                                     + " on node " + container.GetReservedNode() + " when currently" + " reserved resource "
                                                     + reservedContainer + " on node " + reservedContainer.GetReservedNode());
             }
             // Cannot reserve more than one application attempt on a given node!
             // Reservation is still against attempt.
             if (!reservedContainer.GetContainer().GetId().GetApplicationAttemptId().Equals(container
                                                                                            .GetContainer().GetId().GetApplicationAttemptId()))
             {
                 throw new InvalidOperationException("Trying to reserve" + " container " + container
                                                     + " for application " + application.GetApplicationAttemptId() + " when currently"
                                                     + " reserved container " + reservedContainer + " on node " + this);
             }
             if (Log.IsDebugEnabled())
             {
                 Log.Debug("Updated reserved container " + container.GetContainer().GetId() + " on node "
                           + this + " for application attempt " + application.GetApplicationAttemptId());
             }
         }
         else
         {
             if (Log.IsDebugEnabled())
             {
                 Log.Debug("Reserved container " + container.GetContainer().GetId() + " on node "
                           + this + " for application attempt " + application.GetApplicationAttemptId());
             }
         }
         SetReservedContainer(container);
     }
 }
 public override void UnreserveResource(SchedulerApplicationAttempt application)
 {
     lock (this)
     {
         // adding NP checks as this can now be called for preemption
         if (GetReservedContainer() != null && GetReservedContainer().GetContainer() != null &&
             GetReservedContainer().GetContainer().GetId() != null && GetReservedContainer
                 ().GetContainer().GetId().GetApplicationAttemptId() != null)
         {
             // Cannot unreserve for wrong application...
             ApplicationAttemptId reservedApplication = GetReservedContainer().GetContainer().
                                                        GetId().GetApplicationAttemptId();
             if (!reservedApplication.Equals(application.GetApplicationAttemptId()))
             {
                 throw new InvalidOperationException("Trying to unreserve " + " for application "
                                                     + application.GetApplicationAttemptId() + " when currently reserved " + " for application "
                                                     + reservedApplication.GetApplicationId() + " on node " + this);
             }
         }
         SetReservedContainer(null);
     }
 }
 public override void UnreserveResource(SchedulerApplicationAttempt application)
 {
     lock (this)
     {
         // Cannot unreserve for wrong application...
         ApplicationAttemptId reservedApplication = GetReservedContainer().GetContainer().
                                                    GetId().GetApplicationAttemptId();
         if (!reservedApplication.Equals(application.GetApplicationAttemptId()))
         {
             throw new InvalidOperationException("Trying to unreserve " + " for application "
                                                 + application.GetApplicationId() + " when currently reserved " + " for application "
                                                 + reservedApplication.GetApplicationId() + " on node " + this);
         }
         SetReservedContainer(null);
         this.reservedAppSchedulable = null;
     }
 }