Search in sources :

Example 1 with NewReservation

use of org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NewReservation in project hadoop by apache.

the class RMWebServices method createNewReservation.

/**
   * Generates a new ReservationId which is then sent to the client.
   *
   * @param hsr the servlet request
   * @return Response containing the app id and the maximum resource
   *         capabilities
   * @throws AuthorizationException if the user is not authorized
   *         to invoke this method.
   * @throws IOException if creation fails.
   * @throws InterruptedException if interrupted.
   */
@POST
@Path("/reservation/new-reservation")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public Response createNewReservation(@Context HttpServletRequest hsr) throws AuthorizationException, IOException, InterruptedException {
    init();
    UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true);
    if (callerUGI == null) {
        throw new AuthorizationException("Unable to obtain user name, " + "user not authenticated");
    }
    if (UserGroupInformation.isSecurityEnabled() && isStaticUser(callerUGI)) {
        String msg = "The default static user cannot carry out this operation.";
        return Response.status(Status.FORBIDDEN).entity(msg).build();
    }
    NewReservation reservationId = createNewReservation();
    return Response.status(Status.OK).entity(reservationId).build();
}
Also used : AuthorizationException(org.apache.hadoop.security.authorize.AuthorizationException) NewReservation(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NewReservation) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 2 with NewReservation

use of org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NewReservation in project hadoop by apache.

the class RMWebServices method createNewReservation.

/**
   * Function that actually creates the {@link ReservationId} by calling the
   * ClientRMService.
   *
   * @return returns structure containing the {@link ReservationId}
   * @throws IOException if creation fails.
   */
private NewReservation createNewReservation() throws IOException {
    GetNewReservationRequest req = recordFactory.newRecordInstance(GetNewReservationRequest.class);
    GetNewReservationResponse resp;
    try {
        resp = rm.getClientRMService().getNewReservation(req);
    } catch (YarnException e) {
        String msg = "Unable to create new reservation from RM web service";
        LOG.error(msg, e);
        throw new YarnRuntimeException(msg, e);
    }
    NewReservation reservationId = new NewReservation(resp.getReservationId().toString());
    return reservationId;
}
Also used : YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) GetNewReservationRequest(org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationRequest) NewReservation(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NewReservation) GetNewReservationResponse(org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationResponse) YarnException(org.apache.hadoop.yarn.exceptions.YarnException)

Aggregations

NewReservation (org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NewReservation)2 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 AuthorizationException (org.apache.hadoop.security.authorize.AuthorizationException)1 GetNewReservationRequest (org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationRequest)1 GetNewReservationResponse (org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationResponse)1 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)1 YarnRuntimeException (org.apache.hadoop.yarn.exceptions.YarnRuntimeException)1