Search in sources :

Example 16 with Timed

use of org.apache.atlas.annotation.Timed in project atlas by apache.

the class EntityREST method updateClassificationsByUniqueAttribute.

/**
 * Updates classification on an entity identified by its type and unique attributes.
 * @param  typeName
 */
@PUT
@Path("/uniqueAttribute/type/{typeName}/classifications")
@Timed
public void updateClassificationsByUniqueAttribute(@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.updateClassificationsByUniqueAttribute(" + 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.updateClassifications(guid, classifications);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) AtlasEntityType(org.apache.atlas.type.AtlasEntityType) Path(javax.ws.rs.Path) Timed(org.apache.atlas.annotation.Timed) PUT(javax.ws.rs.PUT)

Example 17 with Timed

use of org.apache.atlas.annotation.Timed in project atlas by apache.

the class EntityREST method getEntityHeaders.

@GET
@Path("bulk/headers")
@Produces(Servlets.JSON_MEDIA_TYPE)
@Timed
public AtlasEntityHeaders getEntityHeaders(@QueryParam("tagUpdateStartTime") long tagUpdateStartTime) throws AtlasBaseException {
    AtlasPerfTracer perf = null;
    try {
        long tagUpdateEndTime = System.currentTimeMillis();
        if (tagUpdateStartTime > tagUpdateEndTime) {
            throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "fromTimestamp should be less than toTimestamp");
        }
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getEntityHeaders(" + tagUpdateStartTime + ", " + tagUpdateEndTime + ")");
        }
        ClassificationAssociator.Retriever associator = new ClassificationAssociator.Retriever(typeRegistry, auditRepository);
        return associator.get(tagUpdateStartTime, tagUpdateEndTime);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : ClassificationAssociator(org.apache.atlas.repository.store.graph.v2.ClassificationAssociator) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Timed(org.apache.atlas.annotation.Timed) GET(javax.ws.rs.GET)

Example 18 with Timed

use of org.apache.atlas.annotation.Timed in project atlas by apache.

the class EntityREST method getHeaderById.

/**
 * Get entity header given its GUID.
 * @param guid GUID for the entity
 * @return AtlasEntity
 * @throws AtlasBaseException
 */
@GET
@Path("/guid/{guid}/header")
@Timed
public AtlasEntityHeader getHeaderById(@PathParam("guid") String guid) throws AtlasBaseException {
    Servlets.validateQueryParamLength("guid", guid);
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getHeaderById(" + guid + ")");
        }
        return entitiesStore.getHeaderById(guid);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) Path(javax.ws.rs.Path) Timed(org.apache.atlas.annotation.Timed) GET(javax.ws.rs.GET)

Example 19 with Timed

use of org.apache.atlas.annotation.Timed in project 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}")
@Timed
public void deleteClassification(@PathParam("guid") String guid, @PathParam("classificationName") final String classificationName, @QueryParam("associatedEntityGuid") final String associatedEntityGuid) throws AtlasBaseException {
    Servlets.validateQueryParamLength("guid", guid);
    Servlets.validateQueryParamLength("classificationName", classificationName);
    Servlets.validateQueryParamLength("associatedEntityGuid", associatedEntityGuid);
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.deleteClassification(" + guid + "," + classificationName + "," + associatedEntityGuid + ")");
        }
        if (StringUtils.isEmpty(guid)) {
            throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
        }
        ensureClassificationType(classificationName);
        entitiesStore.deleteClassification(guid, classificationName, associatedEntityGuid);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Timed(org.apache.atlas.annotation.Timed)

Example 20 with Timed

use of org.apache.atlas.annotation.Timed in project atlas by apache.

the class EntityREST method getById.

/**
 * Fetch complete definition of an entity given its GUID.
 * @param guid GUID for the entity
 * @return AtlasEntity
 * @throws AtlasBaseException
 */
@GET
@Path("/guid/{guid}")
@Timed
public AtlasEntityWithExtInfo getById(@PathParam("guid") String guid, @QueryParam("minExtInfo") @DefaultValue("false") boolean minExtInfo, @QueryParam("ignoreRelationships") @DefaultValue("false") boolean ignoreRelationships) throws AtlasBaseException {
    Servlets.validateQueryParamLength("guid", guid);
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getById(" + guid + ", " + minExtInfo + " )");
        }
        return entitiesStore.getById(guid, minExtInfo, ignoreRelationships);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) Path(javax.ws.rs.Path) Timed(org.apache.atlas.annotation.Timed) GET(javax.ws.rs.GET)

Aggregations

Timed (org.apache.atlas.annotation.Timed)74 Path (javax.ws.rs.Path)72 AtlasPerfTracer (org.apache.atlas.utils.AtlasPerfTracer)58 GET (javax.ws.rs.GET)45 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)23 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)14 PUT (javax.ws.rs.PUT)12 DELETE (javax.ws.rs.DELETE)9 POST (javax.ws.rs.POST)6 Map (java.util.Map)5 AtlasGlossary (org.apache.atlas.model.glossary.AtlasGlossary)3 HashMap (java.util.HashMap)2 Produces (javax.ws.rs.Produces)2 SearchFilter (org.apache.atlas.model.SearchFilter)2 AtlasGlossaryCategory (org.apache.atlas.model.glossary.AtlasGlossaryCategory)2 AtlasGlossaryTerm (org.apache.atlas.model.glossary.AtlasGlossaryTerm)2 AtlasUserSavedSearch (org.apache.atlas.model.profile.AtlasUserSavedSearch)2 AtlasBaseTypeDef (org.apache.atlas.model.typedef.AtlasBaseTypeDef)2 AtlasBusinessMetadataDef (org.apache.atlas.model.typedef.AtlasBusinessMetadataDef)2 AtlasClassificationDef (org.apache.atlas.model.typedef.AtlasClassificationDef)2