Search in sources :

Example 1 with EntityIdentifier

use of org.apache.hadoop.yarn.server.timeline.EntityIdentifier in project hadoop by apache.

the class TimelineACLsManager method checkAccess.

public boolean checkAccess(UserGroupInformation callerUGI, ApplicationAccessType applicationAccessType, TimelineEntity entity) throws YarnException, IOException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Verifying the access of " + (callerUGI == null ? null : callerUGI.getShortUserName()) + " on the timeline entity " + new EntityIdentifier(entity.getEntityId(), entity.getEntityType()));
    }
    if (!adminAclsManager.areACLsEnabled()) {
        return true;
    }
    // find domain owner and acls
    AccessControlListExt aclExt = aclExts.get(entity.getDomainId());
    if (aclExt == null) {
        aclExt = loadDomainFromTimelineStore(entity.getDomainId());
    }
    if (aclExt == null) {
        throw new YarnException("Domain information of the timeline entity " + new EntityIdentifier(entity.getEntityId(), entity.getEntityType()) + " doesn't exist.");
    }
    String owner = aclExt.owner;
    AccessControlList domainACL = aclExt.acls.get(applicationAccessType);
    if (domainACL == null) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("ACL not found for access-type " + applicationAccessType + " for domain " + entity.getDomainId() + " owned by " + owner + ". Using default [" + YarnConfiguration.DEFAULT_YARN_APP_ACL + "]");
        }
        domainACL = new AccessControlList(YarnConfiguration.DEFAULT_YARN_APP_ACL);
    }
    if (callerUGI != null && (adminAclsManager.isAdmin(callerUGI) || callerUGI.getShortUserName().equals(owner) || domainACL.isUserAllowed(callerUGI))) {
        return true;
    }
    return false;
}
Also used : AccessControlList(org.apache.hadoop.security.authorize.AccessControlList) EntityIdentifier(org.apache.hadoop.yarn.server.timeline.EntityIdentifier) YarnException(org.apache.hadoop.yarn.exceptions.YarnException)

Example 2 with EntityIdentifier

use of org.apache.hadoop.yarn.server.timeline.EntityIdentifier in project hadoop by apache.

the class TimelineWebServices method getEntity.

/**
   * Return a single entity of the given entity type and Id.
   */
@GET
@Path("/{entityType}/{entityId}")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8 })
public TimelineEntity getEntity(@Context HttpServletRequest req, @Context HttpServletResponse res, @PathParam("entityType") String entityType, @PathParam("entityId") String entityId, @QueryParam("fields") String fields) {
    init(res);
    TimelineEntity entity = null;
    try {
        entity = timelineDataManager.getEntity(parseStr(entityType), parseStr(entityId), parseFieldsStr(fields, ","), getUser(req));
    } catch (IllegalArgumentException e) {
        throw new BadRequestException(e);
    } catch (Exception e) {
        LOG.error("Error getting entity", e);
        throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
    }
    if (entity == null) {
        throw new NotFoundException("Timeline entity " + new EntityIdentifier(parseStr(entityId), parseStr(entityType)) + " is not found");
    }
    return entity;
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) EntityIdentifier(org.apache.hadoop.yarn.server.timeline.EntityIdentifier) TimelineEntity(org.apache.hadoop.yarn.api.records.timeline.TimelineEntity) ForbiddenException(org.apache.hadoop.yarn.webapp.ForbiddenException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) IOException(java.io.IOException) WebApplicationException(javax.ws.rs.WebApplicationException) BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

YarnException (org.apache.hadoop.yarn.exceptions.YarnException)2 EntityIdentifier (org.apache.hadoop.yarn.server.timeline.EntityIdentifier)2 IOException (java.io.IOException)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 AccessControlList (org.apache.hadoop.security.authorize.AccessControlList)1 TimelineEntity (org.apache.hadoop.yarn.api.records.timeline.TimelineEntity)1 BadRequestException (org.apache.hadoop.yarn.webapp.BadRequestException)1 ForbiddenException (org.apache.hadoop.yarn.webapp.ForbiddenException)1 NotFoundException (org.apache.hadoop.yarn.webapp.NotFoundException)1