atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject incubator-atlas git commit: ATALS-1634: added perf trace logs to REST APIs
Date Sun, 05 Mar 2017 02:00:32 GMT
Repository: incubator-atlas
Updated Branches:
  refs/heads/master 571f8d4e5 -> df7d76896


ATALS-1634: added perf trace logs to REST APIs


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/df7d7689
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/df7d7689
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/df7d7689

Branch: refs/heads/master
Commit: df7d76896cd59e30acca611a708facf4356c6902
Parents: 571f8d4
Author: Madhan Neethiraj <madhan@apache.org>
Authored: Sat Mar 4 13:21:32 2017 -0800
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Sat Mar 4 15:50:26 2017 -0800

----------------------------------------------------------------------
 .../org/apache/atlas/type/AtlasTypeUtil.java    |  40 +++
 .../apache/atlas/web/rest/DiscoveryREST.java    |  81 ++++--
 .../org/apache/atlas/web/rest/EntityREST.java   | 258 ++++++++++++++-----
 .../org/apache/atlas/web/rest/LineageREST.java  |  16 +-
 .../org/apache/atlas/web/rest/TypesREST.java    |  45 +++-
 5 files changed, 346 insertions(+), 94 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/df7d7689/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java b/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
index 068fdba..6d3a9f5 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
@@ -378,4 +378,44 @@ public class AtlasTypeUtil {
 
         return false;
     }
+
+    public static String toDebugString(AtlasTypesDef typesDef) {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append("typesDef={");
+        if (typesDef != null) {
+            sb.append("enumDefs=[");
+            dumpTypeNames(typesDef.getEnumDefs(), sb);
+            sb.append("],");
+
+            sb.append("structDefs=[");
+            dumpTypeNames(typesDef.getStructDefs(), sb);
+            sb.append("],");
+
+            sb.append("classificationDefs=[");
+            dumpTypeNames(typesDef.getClassificationDefs(), sb);
+            sb.append("],");
+
+            sb.append("entityDefs=[");
+            dumpTypeNames(typesDef.getEntityDefs(), sb);
+            sb.append("]");
+        }
+        sb.append("}");
+
+        return sb.toString();
+    }
+
+    private static void dumpTypeNames(List<? extends AtlasBaseTypeDef> typeDefs, StringBuilder
sb) {
+        if (CollectionUtils.isNotEmpty(typeDefs)) {
+            for (int i = 0; i < typeDefs.size(); i++) {
+                AtlasBaseTypeDef typeDef = typeDefs.get(i);
+
+                if (i > 0) {
+                    sb.append(",");
+                }
+
+                sb.append(typeDef.getName());
+            }
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/df7d7689/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
index ecb8d30..4801b5e 100644
--- a/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
+++ b/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
@@ -20,8 +20,10 @@ package org.apache.atlas.web.rest;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.discovery.AtlasDiscoveryService;
 import org.apache.atlas.model.discovery.AtlasSearchResult;
+import org.apache.atlas.utils.AtlasPerfTracer;
 import org.apache.atlas.web.util.Servlets;
 import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
 
 import javax.inject.Inject;
 import javax.inject.Singleton;
@@ -37,6 +39,8 @@ import javax.ws.rs.QueryParam;
 @Path("v2/search")
 @Singleton
 public class DiscoveryREST {
+    private static final Logger PERF_LOG = AtlasPerfTracer.getPerfLogger("rest.DiscoveryREST");
+
     private final AtlasDiscoveryService atlasDiscoveryService;
 
     @Inject
@@ -61,27 +65,36 @@ public class DiscoveryREST {
     @Path("/dsl")
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasSearchResult searchUsingDSL(@QueryParam("query") String query,
-                                            @QueryParam("type") String type,
+    public AtlasSearchResult searchUsingDSL(@QueryParam("query")          String query,
+                                            @QueryParam("type")           String type,
                                             @QueryParam("classification") String classification,
-                                            @QueryParam("limit") int limit,
-                                            @QueryParam("offset") int offset) throws AtlasBaseException
{
-        String queryStr = query == null ? "" : query;
+                                            @QueryParam("limit")          int    limit,
+                                            @QueryParam("offset")         int    offset)
throws AtlasBaseException {
+        AtlasPerfTracer perf = null;
 
-        if (StringUtils.isNoneEmpty(type)) {
-            queryStr = type + " " + queryStr;
-        }
+        try {
+            if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+                perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "DiscoveryREST.searchUsingDSL("
+ query + "," + type +
+                                                               "," + classification + ","
+ limit + "," + offset + ")");
+            }
 
-        if (StringUtils.isNoneEmpty(classification)) {
-            // isa works with a type name only - like hive_column isa PII; it doesn't work
with more complex query
-            if (StringUtils.isEmpty(query)) {
-                queryStr += (" isa " + classification);
+            String queryStr = query == null ? "" : query;
+
+            if (StringUtils.isNoneEmpty(type)) {
+                queryStr = type + " " + queryStr;
             }
-        }
 
-        AtlasSearchResult ret = atlasDiscoveryService.searchUsingDslQuery(queryStr, limit,
offset);
+            if (StringUtils.isNoneEmpty(classification)) {
+                // isa works with a type name only - like hive_column isa PII; it doesn't
work with more complex query
+                if (StringUtils.isEmpty(query)) {
+                    queryStr += (" isa " + classification);
+                }
+            }
 
-        return ret;
+            return atlasDiscoveryService.searchUsingDslQuery(queryStr, limit, offset);
+        } finally {
+            AtlasPerfTracer.log(perf);
+        }
     }
 
     /**
@@ -99,13 +112,21 @@ public class DiscoveryREST {
     @Path("/fulltext")
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasSearchResult searchUsingFullText(@QueryParam("query") String query,
-                                                 @QueryParam("limit") int limit,
-                                                 @QueryParam("offset") int offset) throws
AtlasBaseException {
+    public AtlasSearchResult searchUsingFullText(@QueryParam("query")  String query,
+                                                 @QueryParam("limit")  int    limit,
+                                                 @QueryParam("offset") int    offset) throws
AtlasBaseException {
+        AtlasPerfTracer perf = null;
 
-        AtlasSearchResult ret = atlasDiscoveryService.searchUsingFullTextQuery(query, limit,
offset);
+        try {
+            if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+                perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "DiscoveryREST.searchUsingFullText("
+ query + "," +
+                                                               limit + "," + offset + ")");
+            }
 
-        return ret;
+            return atlasDiscoveryService.searchUsingFullTextQuery(query, limit, offset);
+        } finally {
+            AtlasPerfTracer.log(perf);
+        }
     }
 
     /**
@@ -125,14 +146,22 @@ public class DiscoveryREST {
     @Path("/basic")
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasSearchResult searchUsingBasic(@QueryParam("query") String query,
-                                              @QueryParam("type") String type,
+    public AtlasSearchResult searchUsingBasic(@QueryParam("query")          String query,
+                                              @QueryParam("type")           String type,
                                               @QueryParam("classification") String classification,
-                                              @QueryParam("limit") int limit,
-                                              @QueryParam("offset") int offset) throws AtlasBaseException
{
+                                              @QueryParam("limit")          int    limit,
+                                              @QueryParam("offset")         int    offset)
throws AtlasBaseException {
+        AtlasPerfTracer perf = null;
 
-        AtlasSearchResult ret = atlasDiscoveryService.searchUsingBasicQuery(query, type,
classification, limit, offset);
+        try {
+            if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+                perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "DiscoveryREST.searchUsingBasic("
+ query + "," + type +
+                                                               "," + classification + ","
+ limit + "," + offset + ")");
+            }
 
-        return ret;
+            return atlasDiscoveryService.searchUsingBasicQuery(query, type, classification,
limit, offset);
+        } finally {
+            AtlasPerfTracer.log(perf);
+        }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/df7d7689/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java
index 4f7fd0c..98dc918 100644
--- a/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java
+++ b/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java
@@ -18,11 +18,9 @@
 package org.apache.atlas.web.rest;
 
 import org.apache.atlas.AtlasErrorCode;
-import org.apache.atlas.AtlasException;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.TypeCategory;
 import org.apache.atlas.model.instance.AtlasClassification;
-import org.apache.atlas.model.instance.AtlasEntity;
 import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
 import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
 import org.apache.atlas.model.instance.ClassificationAssociateRequest;
@@ -36,12 +34,12 @@ import org.apache.atlas.services.MetadataService;
 import org.apache.atlas.type.AtlasClassificationType;
 import org.apache.atlas.type.AtlasEntityType;
 import org.apache.atlas.type.AtlasTypeRegistry;
-import org.apache.atlas.typesystem.IStruct;
-import org.apache.atlas.typesystem.ITypedStruct;
+import org.apache.atlas.utils.AtlasPerfTracer;
 import org.apache.atlas.web.util.Servlets;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
 
 import javax.inject.Inject;
 import javax.inject.Singleton;
@@ -62,7 +60,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import static org.apache.atlas.repository.converters.AtlasInstanceConverter.toAtlasBaseException;
 
 /**
  * REST for a single entity
@@ -70,6 +67,7 @@ import static org.apache.atlas.repository.converters.AtlasInstanceConverter.toAt
 @Path("v2/entity")
 @Singleton
 public class EntityREST {
+    private static final Logger PERF_LOG = AtlasPerfTracer.getPerfLogger("rest.EntityREST");
 
     public static final String PREFIX_ATTR = "attr:";
 
@@ -98,7 +96,17 @@ public class EntityREST {
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
     public AtlasEntityWithExtInfo getById(@PathParam("guid") String guid) throws AtlasBaseException
{
-        return entitiesStore.getById(guid);
+        AtlasPerfTracer perf = null;
+
+        try {
+            if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+                perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getById(" + guid
+ ")");
+            }
+
+            return entitiesStore.getById(guid);
+        } finally {
+            AtlasPerfTracer.log(perf);
+        }
     }
 
     /**
@@ -113,12 +121,23 @@ public class EntityREST {
     @Produces(Servlets.JSON_MEDIA_TYPE)
     public AtlasEntityWithExtInfo getByUniqueAttributes(@PathParam("typeName") String typeName,
                                                         @Context HttpServletRequest servletRequest)
throws AtlasBaseException {
-        AtlasEntityType     entityType = ensureEntityType(typeName);
-        Map<String, Object> attributes = getAttributes(servletRequest);
+        AtlasPerfTracer perf = null;
 
-        validateUniqueAttribute(entityType, attributes);
+        try {
+            Map<String, Object> attributes = getAttributes(servletRequest);
 
-        return entitiesStore.getByUniqueAttributes(entityType, attributes);
+            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);
+        }
     }
 
     /**
@@ -132,7 +151,17 @@ public class EntityREST {
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
     public EntityMutationResponse createOrUpdate(AtlasEntityWithExtInfo entity) throws AtlasBaseException
{
-        return entitiesStore.createOrUpdate(new AtlasEntityStream(entity), false);
+        AtlasPerfTracer perf = null;
+
+        try {
+            if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+                perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.createOrUpdate()");
+            }
+
+            return entitiesStore.createOrUpdate(new AtlasEntityStream(entity), false);
+        } finally {
+            AtlasPerfTracer.log(perf);
+        }
     }
 
     /*******
@@ -147,12 +176,23 @@ public class EntityREST {
     public EntityMutationResponse partialUpdateEntityByUniqueAttrs(@PathParam("typeName")
String typeName,
                                                                    @Context HttpServletRequest
servletRequest,
                                                                    AtlasEntityWithExtInfo
entityInfo) throws Exception {
-        AtlasEntityType     entityType       = ensureEntityType(typeName);
-        Map<String, Object> uniqueAttributes = getAttributes(servletRequest);
+        AtlasPerfTracer perf = null;
 
-        validateUniqueAttribute(entityType, uniqueAttributes);
+        try {
+            Map<String, Object> uniqueAttributes = getAttributes(servletRequest);
 
-        return entitiesStore.updateByUniqueAttributes(entityType, uniqueAttributes, entityInfo);
+            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);
+        }
     }
 
     /*******
@@ -168,8 +208,17 @@ public class EntityREST {
     public EntityMutationResponse partialUpdateEntityAttrByGuid(@PathParam("guid") String
guid,
                                                                 @QueryParam("name") String
attrName,
                                                                 Object attrValue) throws
Exception {
+        AtlasPerfTracer perf = null;
 
-        return entitiesStore.updateEntityAttributeByGuid(guid, attrName, attrValue);
+        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);
+        }
     }
 
     /**
@@ -182,7 +231,17 @@ public class EntityREST {
     @Consumes({Servlets.JSON_MEDIA_TYPE, MediaType.APPLICATION_JSON})
     @Produces(Servlets.JSON_MEDIA_TYPE)
     public EntityMutationResponse deleteByGuid(@PathParam("guid") final String guid) throws
AtlasBaseException {
-        return entitiesStore.deleteById(guid);
+        AtlasPerfTracer perf = null;
+
+        try {
+            if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+                perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.deleteByGuid("
+ guid + ")");
+            }
+
+            return entitiesStore.deleteById(guid);
+        } finally {
+            AtlasPerfTracer.log(perf);
+        }
     }
 
     /**
@@ -197,10 +256,21 @@ public class EntityREST {
     @Path("/uniqueAttribute/type/{typeName}")
     public EntityMutationResponse deleteByUniqueAttribute(@PathParam("typeName") String typeName,
                                                           @Context HttpServletRequest servletRequest)
throws AtlasBaseException {
-        AtlasEntityType     entityType = ensureEntityType(typeName);
-        Map<String, Object> attributes = getAttributes(servletRequest);
+        AtlasPerfTracer perf = null;
 
-        return entitiesStore.deleteByUniqueAttributes(entityType, attributes);
+        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);
+        }
     }
 
     /**
@@ -212,13 +282,22 @@ public class EntityREST {
     @Path("/guid/{guid}/classification/{classificationName}")
     @Produces(Servlets.JSON_MEDIA_TYPE)
     public AtlasClassification getClassification(@PathParam("guid") String guid, @PathParam("classificationName")
final String classificationName) throws AtlasBaseException {
+        AtlasPerfTracer perf = null;
 
-        if (StringUtils.isEmpty(guid)) {
-            throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
-        }
+        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);
+            ensureClassificationType(classificationName);
+            return entitiesStore.getClassification(guid, classificationName);
+        } finally {
+            AtlasPerfTracer.log(perf);
+        }
     }
 
     /**
@@ -230,17 +309,21 @@ public class EntityREST {
     @Path("/guid/{guid}/classifications")
     @Produces(Servlets.JSON_MEDIA_TYPE)
     public AtlasClassification.AtlasClassifications getClassifications(@PathParam("guid")
String guid) throws AtlasBaseException {
+        AtlasPerfTracer perf = null;
 
-        if (StringUtils.isEmpty(guid)) {
-            throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
-        }
-
-        AtlasClassification.AtlasClassifications classifications = new AtlasClassification.AtlasClassifications();
+        try {
+            if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+                perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getClassifications("
+ guid + ")");
+            }
 
-        final List<AtlasClassification> classificationList = entitiesStore.getClassifications(guid);
-        classifications.setList(classificationList);
+            if (StringUtils.isEmpty(guid)) {
+                throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
+            }
 
-        return classifications;
+            return new AtlasClassification.AtlasClassifications(entitiesStore.getClassifications(guid));
+        } finally {
+            AtlasPerfTracer.log(perf);
+        }
     }
 
     /**
@@ -252,12 +335,21 @@ public class EntityREST {
     @Consumes({Servlets.JSON_MEDIA_TYPE, MediaType.APPLICATION_JSON})
     @Produces(Servlets.JSON_MEDIA_TYPE)
     public void addClassifications(@PathParam("guid") final String guid, List<AtlasClassification>
classifications) throws AtlasBaseException {
+        AtlasPerfTracer perf = null;
 
-        if (StringUtils.isEmpty(guid)) {
-            throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
-        }
+        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);
+            entitiesStore.addClassifications(guid, classifications);
+        } finally {
+            AtlasPerfTracer.log(perf);
+        }
     }
 
     /**
@@ -269,15 +361,24 @@ public class EntityREST {
     @Path("/guid/{guid}/classification/{classificationName}")
     @Produces(Servlets.JSON_MEDIA_TYPE)
     public void deleteClassification(@PathParam("guid") String guid,
-        @PathParam("classificationName") final String classificationName) throws AtlasBaseException
{
+                                     @PathParam("classificationName") final String classificationName)
throws AtlasBaseException {
+        AtlasPerfTracer perf = null;
 
-        if (StringUtils.isEmpty(guid)) {
-            throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
-        }
+        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);
+            ensureClassificationType(classificationName);
 
-        entitiesStore.deleteClassifications(guid, new ArrayList<String>() {{ add(classificationName);}}
);
+            entitiesStore.deleteClassifications(guid, new ArrayList<String>() {{ add(classificationName);}}
);
+        } finally {
+            AtlasPerfTracer.log(perf);
+        }
     }
 
     /******************************************************************/
@@ -292,14 +393,21 @@ public class EntityREST {
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
     public AtlasEntitiesWithExtInfo getByGuids(@QueryParam("guid") List<String> guids)
throws AtlasBaseException {
+        AtlasPerfTracer perf = null;
 
-        if (CollectionUtils.isEmpty(guids)) {
-            throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guids);
-        }
+        try {
+            if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+                perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getByGuids(" +
guids + ")");
+            }
 
-        AtlasEntitiesWithExtInfo entities = entitiesStore.getByIds(guids);
+            if (CollectionUtils.isEmpty(guids)) {
+                throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guids);
+            }
 
-        return entities;
+            return entitiesStore.getByIds(guids);
+        } finally {
+            AtlasPerfTracer.log(perf);
+        }
     }
 
     /**
@@ -311,10 +419,20 @@ public class EntityREST {
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
     public EntityMutationResponse createOrUpdate(AtlasEntitiesWithExtInfo entities) throws
AtlasBaseException {
+        AtlasPerfTracer perf = null;
 
-        EntityStream entityStream = new AtlasEntityStream(entities);
+        try {
+            if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+                perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.createOrUpdate(entityCount="
+
+                                                               (entities == null || entities.getEntities()
== null ? 0 : entities.getEntities().size()) + ")");
+            }
 
-        return entitiesStore.createOrUpdate(entityStream, false);
+            EntityStream entityStream = new AtlasEntityStream(entities);
+
+            return entitiesStore.createOrUpdate(entityStream, false);
+        } finally {
+            AtlasPerfTracer.log(perf);
+        }
     }
 
     /**
@@ -325,7 +443,17 @@ public class EntityREST {
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
     public EntityMutationResponse deleteByGuids(@QueryParam("guid") final List<String>
guids) throws AtlasBaseException {
-        return entitiesStore.deleteByIds(guids);
+        AtlasPerfTracer perf = null;
+
+        try {
+            if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+                perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.deleteByGuids("
+ guids  + ")");
+            }
+
+            return entitiesStore.deleteByIds(guids);
+        } finally {
+            AtlasPerfTracer.log(perf);
+        }
     }
 
     /**
@@ -336,18 +464,28 @@ public class EntityREST {
     @Consumes({Servlets.JSON_MEDIA_TYPE, MediaType.APPLICATION_JSON})
     @Produces(Servlets.JSON_MEDIA_TYPE)
     public void addClassification(ClassificationAssociateRequest request) throws AtlasBaseException
{
-        AtlasClassification classification = request == null ? null : request.getClassification();
-        List<String>        entityGuids    = request == null ? null : request.getEntityGuids();
+        AtlasPerfTracer perf = null;
 
-        if (classification == null || org.apache.commons.lang.StringUtils.isEmpty(classification.getTypeName()))
{
-            throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS, "no classification");
-        }
+        try {
+            if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+                perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.addClassification("
+ request  + ")");
+            }
 
-        if (CollectionUtils.isEmpty(entityGuids)) {
-            throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS, "empty guid list");
-        }
+            AtlasClassification classification = request == null ? null : request.getClassification();
+            List<String>        entityGuids    = request == null ? null : request.getEntityGuids();
+
+            if (classification == null || org.apache.commons.lang.StringUtils.isEmpty(classification.getTypeName()))
{
+                throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS, "no classification");
+            }
+
+            if (CollectionUtils.isEmpty(entityGuids)) {
+                throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS, "empty guid
list");
+            }
 
-        entitiesStore.addClassification(entityGuids, classification);
+            entitiesStore.addClassification(entityGuids, classification);
+        } finally {
+            AtlasPerfTracer.log(perf);
+        }
     }
 
     private AtlasEntityType ensureEntityType(String typeName) throws AtlasBaseException {

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/df7d7689/webapp/src/main/java/org/apache/atlas/web/rest/LineageREST.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/LineageREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/LineageREST.java
index c75b596..2b19e73 100644
--- a/webapp/src/main/java/org/apache/atlas/web/rest/LineageREST.java
+++ b/webapp/src/main/java/org/apache/atlas/web/rest/LineageREST.java
@@ -23,7 +23,9 @@ import org.apache.atlas.discovery.AtlasLineageService;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.lineage.AtlasLineageInfo;
 import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection;
+import org.apache.atlas.utils.AtlasPerfTracer;
 import org.apache.atlas.web.util.Servlets;
+import org.slf4j.Logger;
 
 import javax.inject.Inject;
 import javax.inject.Singleton;
@@ -43,6 +45,8 @@ import javax.ws.rs.core.Context;
 @Path("v2/lineage")
 @Singleton
 public class LineageREST {
+    private static final Logger PERF_LOG = AtlasPerfTracer.getPerfLogger("rest.LineageREST");
+
     private final AtlasLineageService atlasLineageService;
     private static final String DEFAULT_DIRECTION = "BOTH";
     private static final String DEFAULT_DEPTH     = "3";
@@ -73,9 +77,17 @@ public class LineageREST {
     public AtlasLineageInfo getLineageGraph(@PathParam("guid") String guid,
                                             @QueryParam("direction") @DefaultValue(DEFAULT_DIRECTION)
 LineageDirection direction,
                                             @QueryParam("depth") @DefaultValue(DEFAULT_DEPTH)
int depth) throws AtlasBaseException {
+        AtlasPerfTracer perf = null;
 
-        AtlasLineageInfo ret = atlasLineageService.getAtlasLineageInfo(guid, direction, depth);
+        try {
+            if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+                perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "LineageREST.getLineageGraph("
+ guid + "," + direction +
+                                                               "," + depth + ")");
+            }
 
-        return ret;
+            return atlasLineageService.getAtlasLineageInfo(guid, direction, depth);
+        } finally {
+            AtlasPerfTracer.log(perf);
+        }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/df7d7689/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
index f2d97b3..5d846cf 100644
--- a/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
+++ b/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
@@ -29,8 +29,10 @@ import org.apache.atlas.model.typedef.AtlasTypeDefHeader;
 import org.apache.atlas.model.typedef.AtlasTypesDef;
 import org.apache.atlas.store.AtlasTypeDefStore;
 import org.apache.atlas.type.AtlasTypeUtil;
+import org.apache.atlas.utils.AtlasPerfTracer;
 import org.apache.atlas.web.util.Servlets;
 import org.apache.http.annotation.Experimental;
+import org.slf4j.Logger;
 
 import javax.inject.Singleton;
 import javax.servlet.http.HttpServletRequest;
@@ -52,6 +54,7 @@ import java.util.Set;
 @Path("v2/types")
 @Singleton
 public class TypesREST {
+    private static final Logger PERF_LOG = AtlasPerfTracer.getPerfLogger("rest.TypesREST");
 
     private final AtlasTypeDefStore typeDefStore;
 
@@ -282,9 +285,18 @@ public class TypesREST {
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
     public AtlasTypesDef createAtlasTypeDefs(final AtlasTypesDef typesDef) throws AtlasBaseException
{
-        AtlasTypesDef ret = typeDefStore.createTypesDef(typesDef);
+        AtlasPerfTracer perf = null;
 
-        return ret;
+        try {
+            if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+                perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "TypesREST.createAtlasTypeDefs("
+
+                                                               AtlasTypeUtil.toDebugString(typesDef)
+ ")");
+            }
+
+            return typeDefStore.createTypesDef(typesDef);
+        } finally {
+            AtlasPerfTracer.log(perf);
+        }
     }
 
     /**
@@ -301,9 +313,18 @@ public class TypesREST {
     @Produces(Servlets.JSON_MEDIA_TYPE)
     @Experimental
     public AtlasTypesDef updateAtlasTypeDefs(final AtlasTypesDef typesDef) throws AtlasBaseException
{
-        AtlasTypesDef ret = typeDefStore.updateTypesDef(typesDef);
+        AtlasPerfTracer perf = null;
 
-        return ret;
+        try {
+            if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+                perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "TypesREST.updateAtlasTypeDefs("
+
+                                                               AtlasTypeUtil.toDebugString(typesDef)
+ ")");
+            }
+
+            return typeDefStore.updateTypesDef(typesDef);
+        } finally {
+            AtlasPerfTracer.log(perf);
+        }
     }
 
     /**
@@ -319,7 +340,18 @@ public class TypesREST {
     @Produces(Servlets.JSON_MEDIA_TYPE)
     @Experimental
     public void deleteAtlasTypeDefs(final AtlasTypesDef typesDef) throws AtlasBaseException
{
-        typeDefStore.deleteTypesDef(typesDef);
+        AtlasPerfTracer perf = null;
+
+        try {
+            if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+                perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "TypesREST.deleteAtlasTypeDefs("
+
+                                                               AtlasTypeUtil.toDebugString(typesDef)
+ ")");
+            }
+
+            typeDefStore.deleteTypesDef(typesDef);
+        } finally {
+            AtlasPerfTracer.log(perf);
+        }
     }
 
     /**
@@ -334,4 +366,5 @@ public class TypesREST {
         }
 
         return ret;
-    }}
+    }
+}


Mime
View raw message