Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
df7d7689
Commit
df7d7689
authored
Mar 04, 2017
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATALS-1634: added perf trace logs to REST APIs
parent
571f8d4e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
151 additions
and
34 deletions
+151
-34
AtlasTypeUtil.java
intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
+41
-0
DiscoveryREST.java
...rc/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
+56
-26
EntityREST.java
...p/src/main/java/org/apache/atlas/web/rest/EntityREST.java
+0
-0
LineageREST.java
.../src/main/java/org/apache/atlas/web/rest/LineageREST.java
+15
-2
TypesREST.java
...pp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
+39
-6
No files found.
intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
View file @
df7d7689
...
@@ -378,4 +378,44 @@ public class AtlasTypeUtil {
...
@@ -378,4 +378,44 @@ public class AtlasTypeUtil {
return
false
;
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
webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
View file @
df7d7689
...
@@ -20,8 +20,10 @@ package org.apache.atlas.web.rest;
...
@@ -20,8 +20,10 @@ package org.apache.atlas.web.rest;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.discovery.AtlasDiscoveryService
;
import
org.apache.atlas.discovery.AtlasDiscoveryService
;
import
org.apache.atlas.model.discovery.AtlasSearchResult
;
import
org.apache.atlas.model.discovery.AtlasSearchResult
;
import
org.apache.atlas.utils.AtlasPerfTracer
;
import
org.apache.atlas.web.util.Servlets
;
import
org.apache.atlas.web.util.Servlets
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
javax.inject.Singleton
;
import
javax.inject.Singleton
;
...
@@ -37,6 +39,8 @@ import javax.ws.rs.QueryParam;
...
@@ -37,6 +39,8 @@ import javax.ws.rs.QueryParam;
@Path
(
"v2/search"
)
@Path
(
"v2/search"
)
@Singleton
@Singleton
public
class
DiscoveryREST
{
public
class
DiscoveryREST
{
private
static
final
Logger
PERF_LOG
=
AtlasPerfTracer
.
getPerfLogger
(
"rest.DiscoveryREST"
);
private
final
AtlasDiscoveryService
atlasDiscoveryService
;
private
final
AtlasDiscoveryService
atlasDiscoveryService
;
@Inject
@Inject
...
@@ -61,27 +65,36 @@ public class DiscoveryREST {
...
@@ -61,27 +65,36 @@ public class DiscoveryREST {
@Path
(
"/dsl"
)
@Path
(
"/dsl"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasSearchResult
searchUsingDSL
(
@QueryParam
(
"query"
)
String
query
,
public
AtlasSearchResult
searchUsingDSL
(
@QueryParam
(
"query"
)
String
query
,
@QueryParam
(
"type"
)
String
type
,
@QueryParam
(
"type"
)
String
type
,
@QueryParam
(
"classification"
)
String
classification
,
@QueryParam
(
"classification"
)
String
classification
,
@QueryParam
(
"limit"
)
int
limit
,
@QueryParam
(
"limit"
)
int
limit
,
@QueryParam
(
"offset"
)
int
offset
)
throws
AtlasBaseException
{
@QueryParam
(
"offset"
)
int
offset
)
throws
AtlasBaseException
{
String
queryStr
=
query
==
null
?
""
:
query
;
AtlasPerfTracer
perf
=
null
;
if
(
StringUtils
.
isNoneEmpty
(
type
))
{
try
{
queryStr
=
type
+
" "
+
queryStr
;
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
}
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"DiscoveryREST.searchUsingDSL("
+
query
+
","
+
type
+
","
+
classification
+
","
+
limit
+
","
+
offset
+
")"
);
}
if
(
StringUtils
.
isNoneEmpty
(
classification
))
{
String
queryStr
=
query
==
null
?
""
:
query
;
// isa works with a type name only - like hive_column isa PII; it doesn't work with more complex query
if
(
StringUtils
.
is
Empty
(
query
))
{
if
(
StringUtils
.
is
NoneEmpty
(
type
))
{
queryStr
+=
(
" isa "
+
classification
)
;
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 {
...
@@ -99,13 +112,21 @@ public class DiscoveryREST {
@Path
(
"/fulltext"
)
@Path
(
"/fulltext"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasSearchResult
searchUsingFullText
(
@QueryParam
(
"query"
)
String
query
,
public
AtlasSearchResult
searchUsingFullText
(
@QueryParam
(
"query"
)
String
query
,
@QueryParam
(
"limit"
)
int
limit
,
@QueryParam
(
"limit"
)
int
limit
,
@QueryParam
(
"offset"
)
int
offset
)
throws
AtlasBaseException
{
@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 {
...
@@ -125,14 +146,22 @@ public class DiscoveryREST {
@Path
(
"/basic"
)
@Path
(
"/basic"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasSearchResult
searchUsingBasic
(
@QueryParam
(
"query"
)
String
query
,
public
AtlasSearchResult
searchUsingBasic
(
@QueryParam
(
"query"
)
String
query
,
@QueryParam
(
"type"
)
String
type
,
@QueryParam
(
"type"
)
String
type
,
@QueryParam
(
"classification"
)
String
classification
,
@QueryParam
(
"classification"
)
String
classification
,
@QueryParam
(
"limit"
)
int
limit
,
@QueryParam
(
"limit"
)
int
limit
,
@QueryParam
(
"offset"
)
int
offset
)
throws
AtlasBaseException
{
@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
webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java
View file @
df7d7689
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/rest/LineageREST.java
View file @
df7d7689
...
@@ -23,7 +23,9 @@ import org.apache.atlas.discovery.AtlasLineageService;
...
@@ -23,7 +23,9 @@ import org.apache.atlas.discovery.AtlasLineageService;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.lineage.AtlasLineageInfo
;
import
org.apache.atlas.model.lineage.AtlasLineageInfo
;
import
org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection
;
import
org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection
;
import
org.apache.atlas.utils.AtlasPerfTracer
;
import
org.apache.atlas.web.util.Servlets
;
import
org.apache.atlas.web.util.Servlets
;
import
org.slf4j.Logger
;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
javax.inject.Singleton
;
import
javax.inject.Singleton
;
...
@@ -43,6 +45,8 @@ import javax.ws.rs.core.Context;
...
@@ -43,6 +45,8 @@ import javax.ws.rs.core.Context;
@Path
(
"v2/lineage"
)
@Path
(
"v2/lineage"
)
@Singleton
@Singleton
public
class
LineageREST
{
public
class
LineageREST
{
private
static
final
Logger
PERF_LOG
=
AtlasPerfTracer
.
getPerfLogger
(
"rest.LineageREST"
);
private
final
AtlasLineageService
atlasLineageService
;
private
final
AtlasLineageService
atlasLineageService
;
private
static
final
String
DEFAULT_DIRECTION
=
"BOTH"
;
private
static
final
String
DEFAULT_DIRECTION
=
"BOTH"
;
private
static
final
String
DEFAULT_DEPTH
=
"3"
;
private
static
final
String
DEFAULT_DEPTH
=
"3"
;
...
@@ -73,9 +77,17 @@ public class LineageREST {
...
@@ -73,9 +77,17 @@ public class LineageREST {
public
AtlasLineageInfo
getLineageGraph
(
@PathParam
(
"guid"
)
String
guid
,
public
AtlasLineageInfo
getLineageGraph
(
@PathParam
(
"guid"
)
String
guid
,
@QueryParam
(
"direction"
)
@DefaultValue
(
DEFAULT_DIRECTION
)
LineageDirection
direction
,
@QueryParam
(
"direction"
)
@DefaultValue
(
DEFAULT_DIRECTION
)
LineageDirection
direction
,
@QueryParam
(
"depth"
)
@DefaultValue
(
DEFAULT_DEPTH
)
int
depth
)
throws
AtlasBaseException
{
@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
webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
View file @
df7d7689
...
@@ -29,8 +29,10 @@ import org.apache.atlas.model.typedef.AtlasTypeDefHeader;
...
@@ -29,8 +29,10 @@ import org.apache.atlas.model.typedef.AtlasTypeDefHeader;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
org.apache.atlas.store.AtlasTypeDefStore
;
import
org.apache.atlas.store.AtlasTypeDefStore
;
import
org.apache.atlas.type.AtlasTypeUtil
;
import
org.apache.atlas.type.AtlasTypeUtil
;
import
org.apache.atlas.utils.AtlasPerfTracer
;
import
org.apache.atlas.web.util.Servlets
;
import
org.apache.atlas.web.util.Servlets
;
import
org.apache.http.annotation.Experimental
;
import
org.apache.http.annotation.Experimental
;
import
org.slf4j.Logger
;
import
javax.inject.Singleton
;
import
javax.inject.Singleton
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -52,6 +54,7 @@ import java.util.Set;
...
@@ -52,6 +54,7 @@ import java.util.Set;
@Path
(
"v2/types"
)
@Path
(
"v2/types"
)
@Singleton
@Singleton
public
class
TypesREST
{
public
class
TypesREST
{
private
static
final
Logger
PERF_LOG
=
AtlasPerfTracer
.
getPerfLogger
(
"rest.TypesREST"
);
private
final
AtlasTypeDefStore
typeDefStore
;
private
final
AtlasTypeDefStore
typeDefStore
;
...
@@ -282,9 +285,18 @@ public class TypesREST {
...
@@ -282,9 +285,18 @@ public class TypesREST {
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasTypesDef
createAtlasTypeDefs
(
final
AtlasTypesDef
typesDef
)
throws
AtlasBaseException
{
public
AtlasTypesDef
createAtlasTypeDefs
(
final
AtlasTypesDef
typesDef
)
throws
AtlasBaseException
{
Atlas
TypesDef
ret
=
typeDefStore
.
createTypesDef
(
typesDef
)
;
Atlas
PerfTracer
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 {
...
@@ -301,9 +313,18 @@ public class TypesREST {
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Experimental
@Experimental
public
AtlasTypesDef
updateAtlasTypeDefs
(
final
AtlasTypesDef
typesDef
)
throws
AtlasBaseException
{
public
AtlasTypesDef
updateAtlasTypeDefs
(
final
AtlasTypesDef
typesDef
)
throws
AtlasBaseException
{
Atlas
TypesDef
ret
=
typeDefStore
.
updateTypesDef
(
typesDef
)
;
Atlas
PerfTracer
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 {
...
@@ -319,7 +340,18 @@ public class TypesREST {
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Experimental
@Experimental
public
void
deleteAtlasTypeDefs
(
final
AtlasTypesDef
typesDef
)
throws
AtlasBaseException
{
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 {
...
@@ -334,4 +366,5 @@ public class TypesREST {
}
}
return
ret
;
return
ret
;
}}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment