public synchronized void unreserveResource(SchedulerApplicationAttempt application) { // adding NP checks as this can now be called for preemption if (reservedContainer != null && reservedContainer.getContainer() != null && reservedContainer.getContainer().getId() != null && reservedContainer.getContainer().getId().getApplicationAttemptId() != null) { // Cannot unreserve for wrong application... ApplicationAttemptId reservedApplication = reservedContainer.getContainer().getId().getApplicationAttemptId(); if (!reservedApplication.equals(application.getApplicationAttemptId())) { throw new IllegalStateException( "Trying to unreserve " + " for application " + application.getApplicationAttemptId() + " when currently reserved " + " for application " + reservedApplication.getApplicationId() + " on node " + this); } } reservedContainer = null; }
public synchronized void reserveResource( SchedulerApplicationAttempt application, Priority priority, RMContainer reservedContainer) { // Check if it's already reserved if (this.reservedContainer != null) { // Sanity check if (!reservedContainer.getContainer().getNodeId().equals(getNodeID())) { throw new IllegalStateException( "Trying to reserve" + " container " + reservedContainer + " on node " + reservedContainer.getReservedNode() + " when currently" + " reserved resource " + this.reservedContainer + " on node " + this.reservedContainer.getReservedNode()); } // Cannot reserve more than one application attempt on a given node! // Reservation is still against attempt. if (!this.reservedContainer .getContainer() .getId() .getApplicationAttemptId() .equals(reservedContainer.getContainer().getId().getApplicationAttemptId())) { throw new IllegalStateException( "Trying to reserve" + " container " + reservedContainer + " for application " + application.getApplicationAttemptId() + " when currently" + " reserved container " + this.reservedContainer + " on node " + this); } if (LOG.isDebugEnabled()) { LOG.debug( "Updated reserved container " + reservedContainer.getContainer().getId() + " on node " + this + " for application attempt " + application.getApplicationAttemptId()); } } else { if (LOG.isDebugEnabled()) { LOG.debug( "Reserved container " + reservedContainer.getContainer().getId() + " on node " + this + " for application attempt " + application.getApplicationAttemptId()); } } this.reservedContainer = reservedContainer; }