Search in sources :

Example 6 with AtlasPerfTracer

use of org.apache.atlas.utils.AtlasPerfTracer in project incubator-atlas by apache.

the class EntityREST method getByUniqueAttributes.

/**
     * Fetch complete definition of an entity given its type and unique attribute.
     * @param typeName
     * @return AtlasEntityWithExtInfo
     * @throws AtlasBaseException
     */
@GET
@Path("/uniqueAttribute/type/{typeName}")
@Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
public AtlasEntityWithExtInfo getByUniqueAttributes(@PathParam("typeName") String typeName, @Context HttpServletRequest servletRequest) throws AtlasBaseException {
    AtlasPerfTracer perf = null;
    try {
        Map<String, Object> attributes = getAttributes(servletRequest);
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getByUniqueAttributes(" + typeName + "," + attributes + ")");
        }
        AtlasEntityType entityType = ensureEntityType(typeName);
        validateUniqueAttribute(entityType, attributes);
        return entitiesStore.getByUniqueAttributes(entityType, attributes);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) AtlasEntityType(org.apache.atlas.type.AtlasEntityType) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 7 with AtlasPerfTracer

use of org.apache.atlas.utils.AtlasPerfTracer in project incubator-atlas by apache.

the class EntityREST method deleteByUniqueAttribute.

/**
     * Delete an entity identified by its type and unique attributes.
     * @param  typeName - entity type to be deleted
     * @param  servletRequest - request containing unique attributes/values
     * @return EntityMutationResponse
     */
@DELETE
@Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
@Path("/uniqueAttribute/type/{typeName}")
public EntityMutationResponse deleteByUniqueAttribute(@PathParam("typeName") String typeName, @Context HttpServletRequest servletRequest) throws AtlasBaseException {
    AtlasPerfTracer perf = null;
    try {
        Map<String, Object> attributes = getAttributes(servletRequest);
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.deleteByUniqueAttribute(" + typeName + "," + attributes + ")");
        }
        AtlasEntityType entityType = ensureEntityType(typeName);
        return entitiesStore.deleteByUniqueAttributes(entityType, attributes);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) AtlasEntityType(org.apache.atlas.type.AtlasEntityType) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 8 with AtlasPerfTracer

use of org.apache.atlas.utils.AtlasPerfTracer in project incubator-atlas by apache.

the class EntityService method getEntity.

@GET
@Path("{entityId}")
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response getEntity(@Context HttpHeaders headers, @Context UriInfo ui, @PathParam("entityId") String entityId) throws CatalogException {
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityService.getEntity(" + entityId + ")");
        }
        BaseRequest request = new InstanceRequest(Collections.<String, Object>singletonMap("id", entityId));
        Result result = getResource(entityResourceProvider, request);
        return Response.status(Response.Status.OK).entity(getSerializer().serialize(result, ui)).build();
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) BaseRequest(org.apache.atlas.catalog.BaseRequest) InstanceRequest(org.apache.atlas.catalog.InstanceRequest) Result(org.apache.atlas.catalog.Result) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 9 with AtlasPerfTracer

use of org.apache.atlas.utils.AtlasPerfTracer in project incubator-atlas by apache.

the class EntityService method getEntities.

@GET
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response getEntities(@Context HttpHeaders headers, @Context UriInfo ui) throws CatalogException {
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityService.getEntities()");
        }
        String queryString = decode(getQueryString(ui));
        BaseRequest request = new CollectionRequest(Collections.<String, Object>emptyMap(), queryString);
        Result result = getResources(entityResourceProvider, request);
        return Response.status(Response.Status.OK).entity(getSerializer().serialize(result, ui)).build();
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : CollectionRequest(org.apache.atlas.catalog.CollectionRequest) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) BaseRequest(org.apache.atlas.catalog.BaseRequest) Result(org.apache.atlas.catalog.Result) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 10 with AtlasPerfTracer

use of org.apache.atlas.utils.AtlasPerfTracer in project incubator-atlas by apache.

the class EntityService method getEntityTag.

@GET
@Path("{entityId}/tags/{tag}")
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response getEntityTag(@Context HttpHeaders headers, @Context UriInfo ui, @PathParam("entityId") String entityId, @PathParam("tag") String tagName) throws CatalogException {
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityService.getEntityTag(" + entityId + ", " + tagName + ")");
        }
        Map<String, Object> properties = new HashMap<>();
        properties.put("id", entityId);
        properties.put("name", tagName);
        Result result = getResource(entityTagResourceProvider, new InstanceRequest(properties));
        return Response.status(Response.Status.OK).entity(getSerializer().serialize(result, ui)).build();
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : HashMap(java.util.HashMap) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) InstanceRequest(org.apache.atlas.catalog.InstanceRequest) Result(org.apache.atlas.catalog.Result) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

AtlasPerfTracer (org.apache.atlas.utils.AtlasPerfTracer)50 Produces (javax.ws.rs.Produces)36 Path (javax.ws.rs.Path)30 JSONObject (org.codehaus.jettison.json.JSONObject)24 GET (javax.ws.rs.GET)18 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)17 HashMap (java.util.HashMap)14 Consumes (javax.ws.rs.Consumes)12 WebApplicationException (javax.ws.rs.WebApplicationException)10 JSONArray (org.codehaus.jettison.json.JSONArray)9 POST (javax.ws.rs.POST)7 DiscoveryException (org.apache.atlas.discovery.DiscoveryException)7 EntityNotFoundException (org.apache.atlas.typesystem.exception.EntityNotFoundException)7 DELETE (javax.ws.rs.DELETE)6 AtlasException (org.apache.atlas.AtlasException)6 PUT (javax.ws.rs.PUT)5 EntityMutationResponse (org.apache.atlas.model.instance.EntityMutationResponse)5 InstanceRequest (org.apache.atlas.catalog.InstanceRequest)4 Result (org.apache.atlas.catalog.Result)4 AtlasClassification (org.apache.atlas.model.instance.AtlasClassification)4