Search in sources :

Example 6 with ForbiddenException

use of org.apache.hadoop.yarn.webapp.ForbiddenException in project hadoop by apache.

the class TimelineWebServices method putDomain.

/**
   * Store the given domain into the timeline store, and return the errors
   * that happen during storing.
   */
@PUT
@Path("/domain")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8 })
public TimelinePutResponse putDomain(@Context HttpServletRequest req, @Context HttpServletResponse res, TimelineDomain domain) {
    init(res);
    UserGroupInformation callerUGI = getUser(req);
    if (callerUGI == null) {
        String msg = "The owner of the posted timeline domain is not set";
        LOG.error(msg);
        throw new ForbiddenException(msg);
    }
    domain.setOwner(callerUGI.getShortUserName());
    try {
        timelineDataManager.putDomain(domain, callerUGI);
    } catch (YarnException e) {
        // The user doesn't have the access to override the existing domain.
        LOG.error(e.getMessage(), e);
        throw new ForbiddenException(e);
    } catch (RuntimeException e) {
        LOG.error("Error putting domain", e);
        throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
    } catch (IOException e) {
        LOG.error("Error putting domain", e);
        throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
    }
    return new TimelinePutResponse();
}
Also used : ForbiddenException(org.apache.hadoop.yarn.webapp.ForbiddenException) WebApplicationException(javax.ws.rs.WebApplicationException) TimelinePutResponse(org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse) IOException(java.io.IOException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Aggregations

ForbiddenException (org.apache.hadoop.yarn.webapp.ForbiddenException)6 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)5 Consumes (javax.ws.rs.Consumes)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 WebApplicationException (javax.ws.rs.WebApplicationException)3 NotFoundException (org.apache.hadoop.yarn.webapp.NotFoundException)3 IOException (java.io.IOException)2 POST (javax.ws.rs.POST)2 PUT (javax.ws.rs.PUT)2 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)2 ApplicationACLsManager (org.apache.hadoop.yarn.server.security.ApplicationACLsManager)2 BadRequestException (org.apache.hadoop.yarn.webapp.BadRequestException)2 Principal (java.security.Principal)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 Configuration (org.apache.hadoop.conf.Configuration)1 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)1 TimelinePutResponse (org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1