@Override
  public Response updateReservation(ReservationUpdateRequestInfo resContext,
      HttpServletRequest hsr) throws AuthorizationException, IOException, InterruptedException {

    // parameter verification
    if (resContext == null || resContext.getReservationId() == null
        || resContext.getReservationDefinition() == null) {
      routerMetrics.incrUpdateReservationFailedRetrieved();
      String errMsg = "Missing updateReservation resContext or reservationId " +
          "or reservation definition.";
      RouterAuditLogger.logFailure(getUser().getShortUserName(), UPDATE_RESERVATION,
          UNKNOWN, TARGET_WEB_SERVICE, errMsg);
      return Response.status(Status.BAD_REQUEST).entity(errMsg).build();
    }

    // get reservationId
    String reservationId = resContext.getReservationId();

    // Check that the reservationId format is accurate
    try {
      RouterServerUtil.validateReservationId(reservationId);
    } catch (IllegalArgumentException e) {
      routerMetrics.incrUpdateReservationFailedRetrieved();
      RouterAuditLogger.logFailure(getUser().getShortUserName(), UPDATE_RESERVATION,
          UNKNOWN, TARGET_WEB_SERVICE, e.getLocalizedMessage());
      throw e;
    }

    try {
      SubClusterInfo subClusterInfo = getHomeSubClusterInfoByReservationId(reservationId);
      DefaultRequestInterceptorREST interceptor = getOrCreateInterceptorForSubCluster(
          subClusterInfo.getSubClusterId(), subClusterInfo.getRMWebServiceAddress());
      HttpServletRequest hsrCopy = clone(hsr);
      Response response = interceptor.updateReservation(resContext, hsrCopy);
      if (response != null) {
        RouterAuditLogger.logSuccess(getUser().getShortUserName(), UPDATE_RESERVATION,
            TARGET_WEB_SERVICE);
        return response;
      }
    } catch (Exception e) {
      routerMetrics.incrUpdateReservationFailedRetrieved();
      RouterAuditLogger.logFailure(getUser().getShortUserName(), UPDATE_RESERVATION,
          UNKNOWN, TARGET_WEB_SERVICE, e.getLocalizedMessage());
      RouterServerUtil.logAndThrowRunTimeException("updateReservation Failed.", e);
    }

    // throw an exception
    routerMetrics.incrUpdateReservationFailedRetrieved();
    RouterAuditLogger.logFailure(getUser().getShortUserName(), UPDATE_RESERVATION,
        UNKNOWN, TARGET_WEB_SERVICE, "updateReservation Failed, reservationId = " + reservationId);
    throw new YarnRuntimeException("updateReservation Failed, reservationId = " + reservationId);
  }
@Test
  public void testUpdateReservation() throws Exception {
    // submit reservation
    ReservationId reservationId = ReservationId.newInstance(Time.now(), 3);
    Response response = submitReservation(reservationId);
    Assert.assertNotNull(response);
    Assert.assertEquals(Status.ACCEPTED.getStatusCode(), response.getStatus());

    // update reservation
    ReservationSubmissionRequest resSubRequest =
        getReservationSubmissionRequest(reservationId, 6, 2048, 2);
    ReservationDefinition reservationDefinition = resSubRequest.getReservationDefinition();
    ReservationDefinitionInfo reservationDefinitionInfo =
        new ReservationDefinitionInfo(reservationDefinition);

    ReservationUpdateRequestInfo updateRequestInfo = new ReservationUpdateRequestInfo();
    updateRequestInfo.setReservationId(reservationId.toString());
    updateRequestInfo.setReservationDefinition(reservationDefinitionInfo);
    Response updateReservationResp = interceptor.updateReservation(updateRequestInfo, null);
    Assert.assertNotNull(updateReservationResp);
    Assert.assertEquals(Status.OK.getStatusCode(), updateReservationResp.getStatus());

    String applyReservationId = reservationId.toString();
    Response reservationResponse = interceptor.listReservation(
            QUEUE_DEDICATED_FULL, applyReservationId, -1, -1, false, null);
    Assert.assertNotNull(reservationResponse);

    Object entity = reservationResponse.getEntity();
    Assert.assertNotNull(entity);
    Assert.assertNotNull(entity instanceof ReservationListInfo);

    Assert.assertTrue(entity instanceof ReservationListInfo);
    ReservationListInfo listInfo = (ReservationListInfo) entity;
    Assert.assertNotNull(listInfo);

    List<ReservationInfo> reservationInfos = listInfo.getReservations();
    Assert.assertNotNull(reservationInfos);
    Assert.assertEquals(1, reservationInfos.size());

    ReservationInfo reservationInfo = reservationInfos.get(0);
    Assert.assertNotNull(reservationInfo);
    Assert.assertEquals(reservationInfo.getReservationId(), applyReservationId);

    ReservationDefinitionInfo resDefinitionInfo = reservationInfo.getReservationDefinition();
    Assert.assertNotNull(resDefinitionInfo);

    ReservationRequestsInfo reservationRequestsInfo = resDefinitionInfo.getReservationRequests();
    Assert.assertNotNull(reservationRequestsInfo);

    ArrayList<ReservationRequestInfo> reservationRequestInfoList =
            reservationRequestsInfo.getReservationRequest();
    Assert.assertNotNull(reservationRequestInfoList);
    Assert.assertEquals(1, reservationRequestInfoList.size());

    ReservationRequestInfo reservationRequestInfo = reservationRequestInfoList.get(0);
    Assert.assertNotNull(reservationRequestInfo);
    Assert.assertEquals(6, reservationRequestInfo.getNumContainers());

    ResourceInfo resourceInfo = reservationRequestInfo.getCapability();
    Assert.assertNotNull(resourceInfo);

    int vCore = resourceInfo.getvCores();
    long memory = resourceInfo.getMemorySize();
    Assert.assertEquals(2, vCore);
    Assert.assertEquals(2048, memory);
  }