private Plan getPlanFromQueue(ReservationSystem reservationSystem, String queue, String auditConstant) throws YarnException { String nullQueueErrorMessage = "The queue is not specified." + " Please try again with a valid reservable queue."; String nullPlanErrorMessage = "The specified queue: " + queue + " is not managed by reservation system." + " Please try again with a valid reservable queue."; return getPlanFromQueue(reservationSystem, queue, auditConstant, nullQueueErrorMessage, nullPlanErrorMessage); }
private Plan validateReservation(ReservationSystem reservationSystem, ReservationId reservationId, String auditConstant) throws YarnException { // check if the reservation id is valid if (reservationId == null) { String message = "Missing reservation id." + " Please try again by specifying a reservation id."; RMAuditLogger.logFailure("UNKNOWN", auditConstant, "validate reservation input", "ClientRMService", message); throw RPCUtil.getRemoteException(message); } String queue = reservationSystem.getQueueForReservation(reservationId); String nullQueueErrorMessage = "The specified reservation with ID: " + reservationId + " is unknown. Please try again with a valid reservation."; String nullPlanErrorMessage = "The specified reservation: " + reservationId + " is not associated with any valid plan." + " Please try again with a valid reservation."; return getPlanFromQueue(reservationSystem, queue, auditConstant, nullQueueErrorMessage, nullPlanErrorMessage); }
Plan plan = getPlanFromQueue(reservationSystem, queue, AuditConstants.SUBMIT_RESERVATION_REQUEST);
/** * Quick validation on the input to check some obvious fail conditions (fail * fast) the input and returns the appropriate {@link Plan} associated with * the specified {@link Queue} or throws an exception message illustrating the * details of any validation check failures. * * @param reservationSystem the {@link ReservationSystem} to validate against * @param request the {@link ReservationListRequest} defining search * parameters for reservations in the {@link ReservationSystem} that * is being validated against. * @return the {@link Plan} to list reservations of. * @throws YarnException if validation fails */ public Plan validateReservationListRequest( ReservationSystem reservationSystem, ReservationListRequest request) throws YarnException { String queue = request.getQueue(); if (request.getEndTime() < request.getStartTime()) { String errorMessage = "The specified end time must be greater than " + "the specified start time."; RMAuditLogger.logFailure("UNKNOWN", AuditConstants.LIST_RESERVATION_REQUEST, "validate list reservation input", "ClientRMService", errorMessage); throw RPCUtil.getRemoteException(errorMessage); } // Check if it is a managed queue return getPlanFromQueue(reservationSystem, queue, AuditConstants.LIST_RESERVATION_REQUEST); }