@POST
  @Path(RMWSConsts.SCHEDULER_CONF_VALIDATE)
  @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
          MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
  @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
  public synchronized Response validateAndGetSchedulerConfiguration(
          SchedConfUpdateInfo mutationInfo,
          @Context HttpServletRequest hsr) throws AuthorizationException {
    // Only admin user is allowed to read scheduler conf,
    // in order to avoid leaking sensitive info, such as ACLs
    UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true);
    initForWritableEndpoints(callerUGI, true);
    ResourceScheduler scheduler = rm.getResourceScheduler();
    if (isConfigurationMutable(scheduler)) {
      try {
        MutableConfigurationProvider mutableConfigurationProvider =
                ((MutableConfScheduler) scheduler).getMutableConfProvider();
        Configuration schedulerConf = mutableConfigurationProvider
                .getConfiguration();
        Configuration newSchedulerConf = mutableConfigurationProvider
                .applyChanges(schedulerConf, mutationInfo);
        Configuration yarnConf = ((CapacityScheduler) scheduler).getConf();

        Configuration newConfig = new Configuration(yarnConf);
        Iterator<Map.Entry<String, String>> iter = newSchedulerConf.iterator();
        Entry<String, String> e = null;
        while (iter.hasNext()) {
          e = iter.next();
          newConfig.set(e.getKey(), e.getValue());
        }
        CapacitySchedulerConfigValidator.validateCSConfiguration(yarnConf,
                newConfig, rm.getRMContext());

        return Response.status(Status.OK)
                .entity(new ConfInfo(newSchedulerConf))
                .build();
      } catch (Exception e) {
        String errorMsg = "CapacityScheduler configuration validation failed:"
                  + e.toString();
        LOG.warn(errorMsg);
        return Response.status(Status.BAD_REQUEST)
                  .entity(errorMsg)
                  .build();
      }
    } else {
      String errorMsg = String.format("Configuration change validation only supported by %s.",
          MutableConfScheduler.class.getSimpleName());
      LOG.warn(errorMsg);
      return Response.status(Status.BAD_REQUEST)
              .entity(errorMsg)
              .build();
    }
  }
@Test
  public void testValidateAndGetSchedulerConfigurationInvalidScheduler()
          throws AuthorizationException {
    ResourceScheduler scheduler = new CapacityScheduler();
    RMWebServices webService = prepareWebServiceForValidation(scheduler);
    SchedConfUpdateInfo mutationInfo = new SchedConfUpdateInfo();
    HttpServletRequest mockHsr = prepareServletRequestForValidation();
    Response response = webService
            .validateAndGetSchedulerConfiguration(mutationInfo, mockHsr);
    Assert.assertEquals(Status.BAD_REQUEST
            .getStatusCode(), response.getStatus());
    Assert.assertTrue(response.getEntity().toString()
            .contains(String.format("Configuration change validation only supported by %s.",
                MutableConfScheduler.class.getSimpleName())));
  }