示例#1
0
        /// <summary>
        /// Quick validation on the input to check some obvious fail conditions (fail
        /// fast) the input and returns the appropriate
        /// <see cref="Plan"/>
        /// associated with
        /// the specified
        /// <see cref="Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Scheduler.Queue"/>
        /// or throws an exception message illustrating the
        /// details of any validation check failures
        /// </summary>
        /// <param name="reservationSystem">
        /// the
        /// <see cref="ReservationSystem"/>
        /// to validate against
        /// </param>
        /// <param name="request">
        /// the
        /// <see cref="Org.Apache.Hadoop.Yarn.Api.Protocolrecords.ReservationUpdateRequest"/>
        /// defining the resources
        /// required over time for the request
        /// </param>
        /// <returns>
        /// the
        /// <see cref="Plan"/>
        /// to submit the request to
        /// </returns>
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
        public virtual Plan ValidateReservationUpdateRequest(ReservationSystem reservationSystem
                                                             , ReservationUpdateRequest request)
        {
            ReservationId reservationId = request.GetReservationId();
            Plan          plan          = ValidateReservation(reservationSystem, reservationId, RMAuditLogger.AuditConstants
                                                              .UpdateReservationRequest);

            ValidateReservationDefinition(reservationId, request.GetReservationDefinition(),
                                          plan, RMAuditLogger.AuditConstants.UpdateReservationRequest);
            return(plan);
        }
        public virtual void TestUpdateReservationDoesnotExist()
        {
            ReservationUpdateRequest request = CreateSimpleReservationUpdateRequest(1, 1, 1,
                                                                                    5, 4);
            ReservationId rId = request.GetReservationId();

            Org.Mockito.Mockito.When(rSystem.GetQueueForReservation(rId)).ThenReturn(null);
            Plan plan = null;

            try
            {
                plan = rrValidator.ValidateReservationUpdateRequest(rSystem, request);
                NUnit.Framework.Assert.Fail();
            }
            catch (YarnException e)
            {
                NUnit.Framework.Assert.IsNull(plan);
                string message = e.Message;
                NUnit.Framework.Assert.IsTrue(message.Equals(MessageFormat.Format("The specified reservation with ID: {0} is unknown. Please try again with a valid reservation."
                                                                                  , rId)));
                Log.Info(message);
            }
        }