use of org.apache.atlas.utils.AtlasPerfTracer in project incubator-atlas by apache.
the class TaxonomyService method getTaxonomyTerms.
@GET
@Path("{taxonomyName}/terms")
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response getTaxonomyTerms(@Context HttpHeaders headers, @Context UriInfo ui, @PathParam("taxonomyName") String taxonomyName) throws CatalogException {
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "TaxonomyService.getTaxonomyTerms(" + taxonomyName + ")");
}
String queryString = decode(getQueryString(ui));
TermPath termPath = new TermPath(taxonomyName, null);
Request request = new CollectionRequest(Collections.<String, Object>singletonMap("termPath", termPath), queryString);
Result result = getResources(termResourceProvider, request);
return Response.status(Response.Status.OK).entity(getSerializer().serialize(result, ui)).build();
} finally {
AtlasPerfTracer.log(perf);
}
}
use of org.apache.atlas.utils.AtlasPerfTracer in project incubator-atlas by apache.
the class EntityREST method partialUpdateEntityByUniqueAttrs.
/*******
* Entity Partial Update - Allows a subset of attributes to be updated on
* an entity which is identified by its type and unique attribute eg: Referenceable.qualifiedName.
* Null updates are not possible
*******/
@PUT
@Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
@Path("/uniqueAttribute/type/{typeName}")
public EntityMutationResponse partialUpdateEntityByUniqueAttrs(@PathParam("typeName") String typeName, @Context HttpServletRequest servletRequest, AtlasEntityWithExtInfo entityInfo) throws Exception {
AtlasPerfTracer perf = null;
try {
Map<String, Object> uniqueAttributes = getAttributes(servletRequest);
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.partialUpdateEntityByUniqueAttrs(" + typeName + "," + uniqueAttributes + ")");
}
AtlasEntityType entityType = ensureEntityType(typeName);
validateUniqueAttribute(entityType, uniqueAttributes);
return entitiesStore.updateByUniqueAttributes(entityType, uniqueAttributes, entityInfo);
} finally {
AtlasPerfTracer.log(perf);
}
}
use of org.apache.atlas.utils.AtlasPerfTracer in project incubator-atlas by apache.
the class EntityREST method deleteClassification.
/**
* Deletes a given classification from an existing entity represented by a guid.
* @param guid globally unique identifier for the entity
* @param classificationName name of the classifcation
*/
@DELETE
@Path("/guid/{guid}/classification/{classificationName}")
@Produces(Servlets.JSON_MEDIA_TYPE)
public void deleteClassification(@PathParam("guid") String guid, @PathParam("classificationName") final String classificationName) throws AtlasBaseException {
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.deleteClassification(" + guid + "," + classificationName + ")");
}
if (StringUtils.isEmpty(guid)) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
}
ensureClassificationType(classificationName);
entitiesStore.deleteClassifications(guid, new ArrayList<String>() {
{
add(classificationName);
}
});
} finally {
AtlasPerfTracer.log(perf);
}
}
use of org.apache.atlas.utils.AtlasPerfTracer in project incubator-atlas by apache.
the class TypesResource method update.
/**
* Update of existing types - if the given type doesn't exist, creates new type
* Allowed updates are:
* 1. Add optional attribute
* 2. Change required to optional attribute
* 3. Add super types - super types shouldn't contain any required attributes
* @param request
* @return
*/
@PUT
@Consumes({ Servlets.JSON_MEDIA_TYPE, MediaType.APPLICATION_JSON })
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response update(@Context HttpServletRequest request) {
if (LOG.isDebugEnabled()) {
LOG.debug("==> TypesResource.update()");
}
AtlasPerfTracer perf = null;
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "TypesResource.update()");
}
JSONArray typesResponse = new JSONArray();
try {
final String typeDefinition = Servlets.getRequestPayload(request);
if (LOG.isDebugEnabled()) {
LOG.debug("Updating type with definition {} ", typeDefinition);
}
AtlasTypesDef updateTypesDef = TypeConverterUtil.toAtlasTypesDef(typeDefinition, typeRegistry);
AtlasTypesDef updatedTypesDef = typesREST.updateAtlasTypeDefs(updateTypesDef);
List<String> typeNames = TypeConverterUtil.getTypeNames(updatedTypesDef);
for (int i = 0; i < typeNames.size(); i++) {
final String name = typeNames.get(i);
typesResponse.put(new JSONObject() {
{
put(AtlasClient.NAME, name);
}
});
}
JSONObject response = new JSONObject();
response.put(AtlasClient.REQUEST_ID, Servlets.getRequestId());
response.put(AtlasClient.TYPES, typesResponse);
return Response.ok().entity(response).build();
} catch (AtlasBaseException e) {
LOG.error("Unable to persist types", e);
throw new WebApplicationException(Servlets.getErrorResponse(e));
} catch (IllegalArgumentException e) {
LOG.error("Unable to persist types", e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
} catch (WebApplicationException e) {
LOG.error("Unable to persist types", e);
throw e;
} catch (Throwable e) {
LOG.error("Unable to persist types", e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
} finally {
AtlasPerfTracer.log(perf);
if (LOG.isDebugEnabled()) {
LOG.debug("<== TypesResource.update()");
}
}
}
use of org.apache.atlas.utils.AtlasPerfTracer in project incubator-atlas by apache.
the class TypesResource method getTypesByFilter.
/**
* Return the list of type names in the type system which match the specified filter.
*
* @return list of type names
* @param typeCategory returns types whose category is the given typeCategory
* @param supertype returns types which contain the given supertype
* @param notsupertype returns types which do not contain the given supertype
*
* Its possible to specify combination of these filters in one request and the conditions are combined with AND
* For example, typeCategory = TRAIT && supertype contains 'X' && supertype !contains 'Y'
* If there is no filter, all the types are returned
*/
@GET
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response getTypesByFilter(@Context HttpServletRequest request, @QueryParam("type") String typeCategory, @QueryParam("supertype") String supertype, @QueryParam("notsupertype") String notsupertype) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> TypesResource.getTypesByFilter({}, {}, {})", typeCategory, supertype, notsupertype);
}
AtlasPerfTracer perf = null;
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "TypesResource.getTypesByFilter(" + typeCategory + ", " + supertype + ", " + notsupertype + ")");
}
JSONObject response = new JSONObject();
try {
List<String> result = TypeConverterUtil.getTypeNames(typesREST.getTypeDefHeaders(request));
response.put(AtlasClient.RESULTS, new JSONArray(result));
response.put(AtlasClient.COUNT, result.size());
response.put(AtlasClient.REQUEST_ID, Servlets.getRequestId());
return Response.ok(response).build();
} catch (AtlasBaseException e) {
LOG.warn("TypesREST exception: {} {}", e.getClass().getSimpleName(), e.getMessage());
throw new WebApplicationException(Servlets.getErrorResponse(e));
} catch (WebApplicationException e) {
LOG.error("Unable to get types list", e);
throw e;
} catch (Throwable e) {
LOG.error("Unable to get types list", e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
} finally {
AtlasPerfTracer.log(perf);
if (LOG.isDebugEnabled()) {
LOG.debug("<== TypesResource.getTypesByFilter({}, {}, {})", typeCategory, supertype, notsupertype);
}
}
}
Aggregations