use of org.apache.atlas.annotation.Timed in project atlas by apache.
the class EntityREST method setLabels.
@POST
@Path("/uniqueAttribute/type/{typeName}/labels")
@Timed
public void setLabels(@PathParam("typeName") String typeName, Set<String> labels, @Context HttpServletRequest servletRequest) throws AtlasBaseException {
Servlets.validateQueryParamLength("typeName", typeName);
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.setLabels(" + typeName + ")");
}
AtlasEntityType entityType = ensureEntityType(typeName);
Map<String, Object> attributes = getAttributes(servletRequest);
String guid = entitiesStore.getGuidByUniqueAttributes(entityType, attributes);
if (guid == null) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND, typeName, attributes.toString());
}
entitiesStore.setLabels(guid, labels);
} finally {
AtlasPerfTracer.log(perf);
}
}
use of org.apache.atlas.annotation.Timed in project atlas by apache.
the class EntityREST method addClassificationsByUniqueAttribute.
/**
* Adds classification to the entity identified by its type and unique attributes.
* @param typeName
*/
@POST
@Path("/uniqueAttribute/type/{typeName}/classifications")
@Timed
public void addClassificationsByUniqueAttribute(@PathParam("typeName") String typeName, @Context HttpServletRequest servletRequest, List<AtlasClassification> classifications) throws AtlasBaseException {
Servlets.validateQueryParamLength("typeName", typeName);
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.addClassificationsByUniqueAttribute(" + typeName + ")");
}
AtlasEntityType entityType = ensureEntityType(typeName);
Map<String, Object> attributes = getAttributes(servletRequest);
String guid = entitiesStore.getGuidByUniqueAttributes(entityType, attributes);
if (guid == null) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND, typeName, attributes.toString());
}
entitiesStore.addClassifications(guid, classifications);
} finally {
AtlasPerfTracer.log(perf);
}
}
use of org.apache.atlas.annotation.Timed in project atlas by apache.
the class EntityREST method addClassifications.
/**
* Adds classifications to an existing entity represented by a guid.
* @param guid globally unique identifier for the entity
*/
@POST
@Path("/guid/{guid}/classifications")
@Timed
public void addClassifications(@PathParam("guid") final String guid, List<AtlasClassification> classifications) throws AtlasBaseException {
Servlets.validateQueryParamLength("guid", guid);
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.addClassifications(" + guid + ")");
}
if (StringUtils.isEmpty(guid)) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
}
entitiesStore.addClassifications(guid, classifications);
} finally {
AtlasPerfTracer.log(perf);
}
}
use of org.apache.atlas.annotation.Timed in project atlas by apache.
the class EntityREST method partialUpdateEntityAttrByGuid.
/**
*****
* Entity Partial Update - Add/Update entity attribute identified by its GUID.
* Supports only uprimitive attribute type and entity references.
* does not support updation of complex types like arrays, maps
* Null updates are not possible
******
*/
@PUT
@Path("/guid/{guid}")
@Timed
public EntityMutationResponse partialUpdateEntityAttrByGuid(@PathParam("guid") String guid, @QueryParam("name") String attrName, Object attrValue) throws Exception {
Servlets.validateQueryParamLength("guid", guid);
Servlets.validateQueryParamLength("name", attrName);
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.partialUpdateEntityAttrByGuid(" + guid + "," + attrName + ")");
}
return entitiesStore.updateEntityAttributeByGuid(guid, attrName, attrValue);
} finally {
AtlasPerfTracer.log(perf);
}
}
use of org.apache.atlas.annotation.Timed in project atlas by apache.
the class EntityREST method getClassification.
/**
* Gets the list of classifications for a given entity represented by a guid.
* @param guid globally unique identifier for the entity
* @return classification for the given entity guid
*/
@GET
@Path("/guid/{guid}/classification/{classificationName}")
@Timed
public AtlasClassification getClassification(@PathParam("guid") String guid, @PathParam("classificationName") final String classificationName) throws AtlasBaseException {
Servlets.validateQueryParamLength("guid", guid);
Servlets.validateQueryParamLength("classificationName", classificationName);
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getClassification(" + guid + "," + classificationName + ")");
}
if (StringUtils.isEmpty(guid)) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
}
ensureClassificationType(classificationName);
return entitiesStore.getClassification(guid, classificationName);
} finally {
AtlasPerfTracer.log(perf);
}
}
Aggregations