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
1fa05264
Commit
1fa05264
authored
Nov 21, 2016
by
Shwetha GS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1116 Performance monitoring of backend methods in API requests (shwethags)
parent
94a82722
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
641 additions
and
385 deletions
+641
-385
atlas-log4j.xml
distro/src/conf/atlas-log4j.xml
+13
-16
Configuration.twiki
docs/src/site/twiki/Configuration.twiki
+14
-2
InstallationSteps.twiki
docs/src/site/twiki/InstallationSteps.twiki
+4
-0
pom.xml
pom.xml
+33
-1
release-log.txt
release-log.txt
+1
-0
pom.xml
repository/pom.xml
+41
-0
FullTextMapper.java
...ava/org/apache/atlas/repository/graph/FullTextMapper.java
+3
-1
GraphHelper.java
...n/java/org/apache/atlas/repository/graph/GraphHelper.java
+36
-23
GraphToTypedInstanceMapper.java
...he/atlas/repository/graph/GraphToTypedInstanceMapper.java
+14
-11
TypedInstanceToGraphMapper.java
...he/atlas/repository/graph/TypedInstanceToGraphMapper.java
+17
-15
AtlasGraphUtilsV1.java
...he/atlas/repository/store/graph/v1/AtlasGraphUtilsV1.java
+1
-1
pom.xml
server-api/pom.xml
+53
-2
RequestContext.java
...er-api/src/main/java/org/apache/atlas/RequestContext.java
+6
-0
AtlasAspect.java
...pi/src/main/java/org/apache/atlas/aspect/AtlasAspect.java
+68
-0
Loggable.java
...r-api/src/main/java/org/apache/atlas/aspect/Loggable.java
+30
-0
Monitored.java
...-api/src/main/java/org/apache/atlas/aspect/Monitored.java
+30
-0
Metrics.java
...r-api/src/main/java/org/apache/atlas/metrics/Metrics.java
+68
-0
MonitoredAspectTest.java
...src/test/aspect/org/apache/atlas/MonitoredAspectTest.java
+47
-0
atlas-log4j.xml
typesystem/src/main/resources/atlas-log4j.xml
+0
-16
pom.xml
webapp/pom.xml
+51
-0
AuditFilter.java
...c/main/java/org/apache/atlas/web/filters/AuditFilter.java
+11
-0
AdminResource.java
...in/java/org/apache/atlas/web/resources/AdminResource.java
+54
-88
DataSetLineageResource.java
...rg/apache/atlas/web/resources/DataSetLineageResource.java
+4
-21
EntityResource.java
...n/java/org/apache/atlas/web/resources/EntityResource.java
+28
-110
LineageResource.java
.../java/org/apache/atlas/web/resources/LineageResource.java
+4
-21
MetadataDiscoveryResource.java
...apache/atlas/web/resources/MetadataDiscoveryResource.java
+5
-27
TypesResource.java
...in/java/org/apache/atlas/web/resources/TypesResource.java
+5
-30
No files found.
distro/src/conf/atlas-log4j.xml
View file @
1fa05264
...
@@ -43,6 +43,14 @@
...
@@ -43,6 +43,14 @@
</layout>
</layout>
</appender>
</appender>
<appender
name=
"METRICS"
class=
"org.apache.log4j.DailyRollingFileAppender"
>
<param
name=
"File"
value=
"${atlas.log.dir}/metric.log"
/>
<param
name=
"Append"
value=
"true"
/>
<layout
class=
"org.apache.log4j.PatternLayout"
>
<param
name=
"ConversionPattern"
value=
"%d %x %m%n"
/>
</layout>
</appender>
<appender
name=
"FAILED"
class=
"org.apache.log4j.DailyRollingFileAppender"
>
<appender
name=
"FAILED"
class=
"org.apache.log4j.DailyRollingFileAppender"
>
<param
name=
"File"
value=
"${atlas.log.dir}/failed.log"
/>
<param
name=
"File"
value=
"${atlas.log.dir}/failed.log"
/>
<param
name=
"Append"
value=
"true"
/>
<param
name=
"Append"
value=
"true"
/>
...
@@ -56,22 +64,6 @@
...
@@ -56,22 +64,6 @@
<appender-ref
ref=
"FILE"
/>
<appender-ref
ref=
"FILE"
/>
</logger>
</logger>
<!-- uncomment this block to generate performance traces
<appender name="perf_appender" class="org.apache.log4j.DailyRollingFileAppender">
<param name="file" value="${atlas.log.dir}/atlas_perf.log" />
<param name="datePattern" value="'.'yyyy-MM-dd" />
<param name="append" value="true" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d|%t|%m%n" />
</layout>
</appender>
<logger name="org.apache.atlas.perf" additivity="false">
<level value="debug" />
<appender-ref ref="perf_appender" />
</logger>
-->
<logger
name=
"com.thinkaurelius.titan"
additivity=
"false"
>
<logger
name=
"com.thinkaurelius.titan"
additivity=
"false"
>
<level
value=
"warn"
/>
<level
value=
"warn"
/>
<appender-ref
ref=
"FILE"
/>
<appender-ref
ref=
"FILE"
/>
...
@@ -88,6 +80,11 @@
...
@@ -88,6 +80,11 @@
<appender-ref
ref=
"AUDIT"
/>
<appender-ref
ref=
"AUDIT"
/>
</logger>
</logger>
<logger
name=
"METRICS"
additivity=
"false"
>
<level
value=
"debug"
/>
<appender-ref
ref=
"METRICS"
/>
</logger>
<logger
name=
"FAILED"
additivity=
"false"
>
<logger
name=
"FAILED"
additivity=
"false"
>
<level
value=
"info"
/>
<level
value=
"info"
/>
<appender-ref
ref=
"AUDIT"
/>
<appender-ref
ref=
"AUDIT"
/>
...
...
docs/src/site/twiki/Configuration.twiki
View file @
1fa05264
...
@@ -283,4 +283,17 @@ atlas.webserver.keepalivetimesecs=60
...
@@ -283,4 +283,17 @@ atlas.webserver.keepalivetimesecs=60
# Queue size for the requests(when max threads are busy) for the atlas web server
# Queue size for the requests(when max threads are busy) for the atlas web server
atlas.webserver.queuesize=100
atlas.webserver.queuesize=100
</verbatim>
</verbatim>
\ No newline at end of file
---+++ Recording performance metrics
Atlas package should be built with '-P perf' to instrument atlas code to collect metrics. The metrics will be recorded in
<atlas.log.dir>/metric.log, with one log line per API call. The metrics contain the number of times the instrumented methods
are called and the total time spent in the instrumented method. Logging to metric.log is controlled through log4j configuration
in atlas-log4j.xml. When the atlas code is instrumented, to disable logging to metric.log at runtime, set log level of METRICS logger to info level:
<verbatim>
<logger name="METRICS" additivity="false">
<level value="info"/>
<appender-ref ref="METRICS"/>
</logger>
</verbatim>
docs/src/site/twiki/InstallationSteps.twiki
View file @
1fa05264
...
@@ -18,6 +18,10 @@ mvn clean package -Pdist
...
@@ -18,6 +18,10 @@ mvn clean package -Pdist
</verbatim>
</verbatim>
NOTE:
1. Use option '-DskipTests' to skip running unit and integration tests
2. Use option '-P perf' to instrument atlas to collect performance metrics
To build a distribution that configures Atlas for external HBase and Solr, build with the external-hbase-solr profile.
To build a distribution that configures Atlas for external HBase and Solr, build with the external-hbase-solr profile.
<verbatim>
<verbatim>
...
...
pom.xml
View file @
1fa05264
...
@@ -491,9 +491,23 @@
...
@@ -491,9 +491,23 @@
<entity.repository.impl>
org.apache.atlas.repository.audit.InMemoryEntityAuditRepository
</entity.repository.impl>
<entity.repository.impl>
org.apache.atlas.repository.audit.InMemoryEntityAuditRepository
</entity.repository.impl>
<graphdb.backend.impl>
org.apache.atlas.repository.graphdb.titan0.Titan0GraphDatabase
</graphdb.backend.impl>
<graphdb.backend.impl>
org.apache.atlas.repository.graphdb.titan0.Titan0GraphDatabase
</graphdb.backend.impl>
<atlas.surefire.options></atlas.surefire.options>
<atlas.surefire.options></atlas.surefire.options>
<aspectj.runtime.version>
1.8.7
</aspectj.runtime.version>
<aspectj.skip>
true
</aspectj.skip>
</properties>
</properties>
<profiles>
<profiles>
<!-- Turn on this profile to instrument atlas server to collect performance metrics -->
<profile>
<id>
perf
</id>
<activation>
<activeByDefault>
false
</activeByDefault>
</activation>
<properties>
<aspectj.skip>
false
</aspectj.skip>
</properties>
</profile>
<!-- Turning on this profile affects only tests and does not affect packaging -->
<!-- Turning on this profile affects only tests and does not affect packaging -->
<profile>
<profile>
<id>
distributed
</id>
<id>
distributed
</id>
...
@@ -618,6 +632,18 @@
...
@@ -618,6 +632,18 @@
<dependencyManagement>
<dependencyManagement>
<dependencies>
<dependencies>
<!-- AOP dependencies. -->
<dependency>
<groupId>
org.aspectj
</groupId>
<artifactId>
aspectjrt
</artifactId>
<version>
${aspectj.runtime.version}
</version>
</dependency>
<dependency>
<groupId>
org.aspectj
</groupId>
<artifactId>
aspectjtools
</artifactId>
<version>
${aspectj.runtime.version}
</version>
</dependency>
<dependency>
<dependency>
<groupId>
org.eclipse.jetty
</groupId>
<groupId>
org.eclipse.jetty
</groupId>
<artifactId>
jetty-jsp
</artifactId>
<artifactId>
jetty-jsp
</artifactId>
...
@@ -1631,6 +1657,12 @@
...
@@ -1631,6 +1657,12 @@
<excludeGroupIds>
org.restlet.jee
</excludeGroupIds>
<excludeGroupIds>
org.restlet.jee
</excludeGroupIds>
</configuration>
</configuration>
</plugin>
</plugin>
<plugin>
<groupId>
org.codehaus.mojo
</groupId>
<artifactId>
aspectj-maven-plugin
</artifactId>
<version>
1.8
</version>
</plugin>
</plugins>
</plugins>
</pluginManagement>
</pluginManagement>
...
@@ -1783,7 +1815,7 @@
...
@@ -1783,7 +1815,7 @@
<excludeSubProjects>
true
</excludeSubProjects>
<excludeSubProjects>
true
</excludeSubProjects>
<excludes>
<excludes>
<exclude>
**/dependency-reduced-pom.xml
</exclude>
<exclude>
**/dependency-reduced-pom.xml
</exclude>
<exclude>
**/javax.script.ScriptEngineFactory
</exclude>
<exclude>
**/javax.script.ScriptEngineFactory
</exclude>
<exclude>
.reviewboardrc
</exclude>
<exclude>
.reviewboardrc
</exclude>
<exclude>
3party-licenses/**
</exclude>
<exclude>
3party-licenses/**
</exclude>
<exclude>
**/.cache
</exclude>
<exclude>
**/.cache
</exclude>
...
...
release-log.txt
View file @
1fa05264
...
@@ -9,6 +9,7 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
...
@@ -9,6 +9,7 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ALL CHANGES:
ALL CHANGES:
ATLAS-1116 Performance monitoring of backend methods in API requests (shwethags)
ATLAS-1310 attempt LDAP authentication only when enabled (mneethiraj)
ATLAS-1310 attempt LDAP authentication only when enabled (mneethiraj)
ATLAS-1309 updated HBase model with addition of column-family and column entity-defs (mneethiraj)
ATLAS-1309 updated HBase model with addition of column-family and column entity-defs (mneethiraj)
ATLAS-916 Return System Attributes in get entity definition (svimal2106)
ATLAS-916 Return System Attributes in get entity definition (svimal2106)
...
...
repository/pom.xml
View file @
1fa05264
...
@@ -219,6 +219,47 @@
...
@@ -219,6 +219,47 @@
<groupId>
net.alchim31.maven
</groupId>
<groupId>
net.alchim31.maven
</groupId>
<artifactId>
scala-maven-plugin
</artifactId>
<artifactId>
scala-maven-plugin
</artifactId>
</plugin>
</plugin>
<plugin>
<groupId>
org.codehaus.mojo
</groupId>
<artifactId>
aspectj-maven-plugin
</artifactId>
<configuration>
<complianceLevel>
1.7
</complianceLevel>
<includes>
<include>
**/*.java
</include>
<include>
**/*.aj
</include>
</includes>
<XaddSerialVersionUID>
true
</XaddSerialVersionUID>
<showWeaveInfo>
true
</showWeaveInfo>
<aspectLibraries>
<aspectLibrary>
<groupId>
org.apache.atlas
</groupId>
<artifactId>
atlas-server-api
</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<id>
compile_with_aspectj
</id>
<goals>
<goal>
compile
</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>
org.aspectj
</groupId>
<artifactId>
aspectjtools
</artifactId>
<version>
${aspectj.runtime.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.atlas
</groupId>
<artifactId>
atlas-server-api
</artifactId>
<version>
${project.version}
</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</plugins>
</build>
</build>
</project>
</project>
repository/src/main/java/org/apache/atlas/repository/graph/FullTextMapper.java
View file @
1fa05264
...
@@ -17,8 +17,9 @@
...
@@ -17,8 +17,9 @@
*/
*/
package
org
.
apache
.
atlas
.
repository
.
graph
;
package
org
.
apache
.
atlas
.
repository
.
graph
;
import
org.apache.atlas.repository.graphdb.AtlasVertex
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.aspect.Monitored
;
import
org.apache.atlas.repository.graphdb.AtlasVertex
;
import
org.apache.atlas.typesystem.ITypedInstance
;
import
org.apache.atlas.typesystem.ITypedInstance
;
import
org.apache.atlas.typesystem.ITypedReferenceableInstance
;
import
org.apache.atlas.typesystem.ITypedReferenceableInstance
;
import
org.apache.atlas.typesystem.types.AttributeInfo
;
import
org.apache.atlas.typesystem.types.AttributeInfo
;
...
@@ -49,6 +50,7 @@ public class FullTextMapper {
...
@@ -49,6 +50,7 @@ public class FullTextMapper {
instanceCache
=
new
HashMap
<>();
instanceCache
=
new
HashMap
<>();
}
}
@Monitored
public
String
mapRecursive
(
AtlasVertex
instanceVertex
,
boolean
followReferences
)
throws
AtlasException
{
public
String
mapRecursive
(
AtlasVertex
instanceVertex
,
boolean
followReferences
)
throws
AtlasException
{
String
guid
=
GraphHelper
.
getIdFromVertex
(
instanceVertex
);
String
guid
=
GraphHelper
.
getIdFromVertex
(
instanceVertex
);
ITypedReferenceableInstance
typedReference
;
ITypedReferenceableInstance
typedReference
;
...
...
repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
View file @
1fa05264
...
@@ -18,20 +18,13 @@
...
@@ -18,20 +18,13 @@
package
org
.
apache
.
atlas
.
repository
.
graph
;
package
org
.
apache
.
atlas
.
repository
.
graph
;
import
java.util.ArrayList
;
import
com.google.common.annotations.VisibleForTesting
;
import
java.util.Collection
;
import
com.google.common.collect.BiMap
;
import
java.util.HashMap
;
import
com.google.common.collect.HashBiMap
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Stack
;
import
java.util.UUID
;
import
java.util.Date
;
import
org.apache.atlas.ApplicationProperties
;
import
org.apache.atlas.ApplicationProperties
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.RequestContext
;
import
org.apache.atlas.RequestContext
;
import
org.apache.atlas.aspect.Monitored
;
import
org.apache.atlas.repository.Constants
;
import
org.apache.atlas.repository.Constants
;
import
org.apache.atlas.repository.RepositoryException
;
import
org.apache.atlas.repository.RepositoryException
;
import
org.apache.atlas.repository.graphdb.AtlasEdge
;
import
org.apache.atlas.repository.graphdb.AtlasEdge
;
...
@@ -65,9 +58,15 @@ import org.codehaus.jettison.json.JSONArray;
...
@@ -65,9 +58,15 @@ import org.codehaus.jettison.json.JSONArray;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
com.google.common.annotations.VisibleForTesting
;
import
java.util.ArrayList
;
import
com.google.common.collect.BiMap
;
import
java.util.Collection
;
import
com.google.common.collect.HashBiMap
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Stack
;
import
java.util.UUID
;
/**
/**
* Utility class for graph operations.
* Utility class for graph operations.
...
@@ -138,6 +137,7 @@ public final class GraphHelper {
...
@@ -138,6 +137,7 @@ public final class GraphHelper {
return
vertexWithIdentity
;
return
vertexWithIdentity
;
}
}
@Monitored
public
AtlasVertex
createVertexWithoutIdentity
(
String
typeName
,
Id
typedInstanceId
,
Set
<
String
>
superTypeNames
)
{
public
AtlasVertex
createVertexWithoutIdentity
(
String
typeName
,
Id
typedInstanceId
,
Set
<
String
>
superTypeNames
)
{
LOG
.
debug
(
"Creating AtlasVertex for type {} id {}"
,
typeName
,
LOG
.
debug
(
"Creating AtlasVertex for type {} id {}"
,
typeName
,
typedInstanceId
!=
null
?
typedInstanceId
.
_getId
()
:
null
);
typedInstanceId
!=
null
?
typedInstanceId
.
_getId
()
:
null
);
...
@@ -165,6 +165,7 @@ public final class GraphHelper {
...
@@ -165,6 +165,7 @@ public final class GraphHelper {
return
vertexWithoutIdentity
;
return
vertexWithoutIdentity
;
}
}
@Monitored
private
AtlasEdge
addEdge
(
AtlasVertex
fromVertex
,
AtlasVertex
toVertex
,
String
edgeLabel
)
{
private
AtlasEdge
addEdge
(
AtlasVertex
fromVertex
,
AtlasVertex
toVertex
,
String
edgeLabel
)
{
LOG
.
debug
(
"Adding edge for {} -> label {} -> {}"
,
string
(
fromVertex
),
edgeLabel
,
string
(
toVertex
));
LOG
.
debug
(
"Adding edge for {} -> label {} -> {}"
,
string
(
fromVertex
),
edgeLabel
,
string
(
toVertex
));
AtlasEdge
edge
=
graph
.
addEdge
(
fromVertex
,
toVertex
,
edgeLabel
);
AtlasEdge
edge
=
graph
.
addEdge
(
fromVertex
,
toVertex
,
edgeLabel
);
...
@@ -216,7 +217,7 @@ public final class GraphHelper {
...
@@ -216,7 +217,7 @@ public final class GraphHelper {
return
null
;
return
null
;
}
}
@Monitored
public
AtlasEdge
getEdgeByEdgeId
(
AtlasVertex
outVertex
,
String
edgeLabel
,
String
edgeId
)
{
public
AtlasEdge
getEdgeByEdgeId
(
AtlasVertex
outVertex
,
String
edgeLabel
,
String
edgeId
)
{
if
(
edgeId
==
null
)
{
if
(
edgeId
==
null
)
{
return
null
;
return
null
;
...
@@ -242,6 +243,7 @@ public final class GraphHelper {
...
@@ -242,6 +243,7 @@ public final class GraphHelper {
* @return AtlasVertex with the given property keys
* @return AtlasVertex with the given property keys
* @throws EntityNotFoundException
* @throws EntityNotFoundException
*/
*/
@Monitored
public
AtlasVertex
findVertex
(
Object
...
args
)
throws
EntityNotFoundException
{
public
AtlasVertex
findVertex
(
Object
...
args
)
throws
EntityNotFoundException
{
StringBuilder
condition
=
new
StringBuilder
();
StringBuilder
condition
=
new
StringBuilder
();
AtlasGraphQuery
query
=
graph
.
query
();
AtlasGraphQuery
query
=
graph
.
query
();
...
@@ -268,6 +270,7 @@ public final class GraphHelper {
...
@@ -268,6 +270,7 @@ public final class GraphHelper {
//In some cases of parallel APIs, the edge is added, but get edge by label doesn't return the edge. ATLAS-1104
//In some cases of parallel APIs, the edge is added, but get edge by label doesn't return the edge. ATLAS-1104
//So traversing all the edges
//So traversing all the edges
@Monitored
public
Iterator
<
AtlasEdge
>
getAdjacentEdgesByLabel
(
AtlasVertex
instanceVertex
,
AtlasEdgeDirection
direction
,
final
String
edgeLabel
)
{
public
Iterator
<
AtlasEdge
>
getAdjacentEdgesByLabel
(
AtlasVertex
instanceVertex
,
AtlasEdgeDirection
direction
,
final
String
edgeLabel
)
{
LOG
.
debug
(
"Finding edges for {} with label {}"
,
string
(
instanceVertex
),
edgeLabel
);
LOG
.
debug
(
"Finding edges for {} with label {}"
,
string
(
instanceVertex
),
edgeLabel
);
if
(
instanceVertex
!=
null
&&
edgeLabel
!=
null
)
{
if
(
instanceVertex
!=
null
&&
edgeLabel
!=
null
)
{
...
@@ -316,6 +319,7 @@ public final class GraphHelper {
...
@@ -316,6 +319,7 @@ public final class GraphHelper {
* @param edgeLabel
* @param edgeLabel
* @return
* @return
*/
*/
@Monitored
public
AtlasEdge
getEdgeForLabel
(
AtlasVertex
vertex
,
String
edgeLabel
)
{
public
AtlasEdge
getEdgeForLabel
(
AtlasVertex
vertex
,
String
edgeLabel
)
{
Iterator
<
AtlasEdge
>
iterator
=
getAdjacentEdgesByLabel
(
vertex
,
AtlasEdgeDirection
.
OUT
,
edgeLabel
);
Iterator
<
AtlasEdge
>
iterator
=
getAdjacentEdgesByLabel
(
vertex
,
AtlasEdgeDirection
.
OUT
,
edgeLabel
);
AtlasEdge
latestDeletedEdge
=
null
;
AtlasEdge
latestDeletedEdge
=
null
;
...
@@ -340,6 +344,7 @@ public final class GraphHelper {
...
@@ -340,6 +344,7 @@ public final class GraphHelper {
return
latestDeletedEdge
;
return
latestDeletedEdge
;
}
}
@Monitored
public
static
String
vertexString
(
final
AtlasVertex
vertex
)
{
public
static
String
vertexString
(
final
AtlasVertex
vertex
)
{
StringBuilder
properties
=
new
StringBuilder
();
StringBuilder
properties
=
new
StringBuilder
();
for
(
String
propertyKey
:
vertex
.
getPropertyKeys
())
{
for
(
String
propertyKey
:
vertex
.
getPropertyKeys
())
{
...
@@ -350,11 +355,13 @@ public final class GraphHelper {
...
@@ -350,11 +355,13 @@ public final class GraphHelper {
return
"v["
+
vertex
.
getIdForDisplay
()
+
"], Properties["
+
properties
+
"]"
;
return
"v["
+
vertex
.
getIdForDisplay
()
+
"], Properties["
+
properties
+
"]"
;
}
}
@Monitored
public
static
String
edgeString
(
final
AtlasEdge
edge
)
{
public
static
String
edgeString
(
final
AtlasEdge
edge
)
{
return
"e["
+
edge
.
getLabel
()
+
"], ["
+
edge
.
getOutVertex
()
+
" -> "
+
edge
.
getLabel
()
+
" -> "
return
"e["
+
edge
.
getLabel
()
+
"], ["
+
edge
.
getOutVertex
()
+
" -> "
+
edge
.
getLabel
()
+
" -> "
+
edge
.
getInVertex
()
+
"]"
;
+
edge
.
getInVertex
()
+
"]"
;
}
}
@Monitored
public
static
<
T
extends
AtlasElement
>
void
setProperty
(
T
element
,
String
propertyName
,
Object
value
)
{
public
static
<
T
extends
AtlasElement
>
void
setProperty
(
T
element
,
String
propertyName
,
Object
value
)
{
String
elementStr
=
string
(
element
);
String
elementStr
=
string
(
element
);
String
actualPropertyName
=
GraphHelper
.
encodePropertyKey
(
propertyName
);
String
actualPropertyName
=
GraphHelper
.
encodePropertyKey
(
propertyName
);
...
@@ -383,6 +390,7 @@ public final class GraphHelper {
...
@@ -383,6 +390,7 @@ public final class GraphHelper {
* @param clazz
* @param clazz
* @return
* @return
*/
*/
@Monitored
public
static
<
T
>
T
getSingleValuedProperty
(
AtlasElement
element
,
String
propertyName
,
Class
<
T
>
clazz
)
{
public
static
<
T
>
T
getSingleValuedProperty
(
AtlasElement
element
,
String
propertyName
,
Class
<
T
>
clazz
)
{
String
elementStr
=
string
(
element
);
String
elementStr
=
string
(
element
);
String
actualPropertyName
=
GraphHelper
.
encodePropertyKey
(
propertyName
);
String
actualPropertyName
=
GraphHelper
.
encodePropertyKey
(
propertyName
);
...
@@ -390,8 +398,9 @@ public final class GraphHelper {
...
@@ -390,8 +398,9 @@ public final class GraphHelper {
return
(
T
)
element
.
getProperty
(
actualPropertyName
,
clazz
);
return
(
T
)
element
.
getProperty
(
actualPropertyName
,
clazz
);
}
}
@Monitored
public
static
Object
getProperty
(
AtlasVertex
<?,?>
vertex
,
String
propertyName
)
{
public
static
Object
getProperty
(
AtlasVertex
<?,?>
vertex
,
String
propertyName
)
{
String
elementStr
=
string
(
vertex
);
String
elementStr
=
string
(
vertex
);
String
actualPropertyName
=
GraphHelper
.
encodePropertyKey
(
propertyName
);
String
actualPropertyName
=
GraphHelper
.
encodePropertyKey
(
propertyName
);
...
@@ -403,9 +412,9 @@ public final class GraphHelper {
...
@@ -403,9 +412,9 @@ public final class GraphHelper {
else
{
else
{
return
vertex
.
getProperty
(
actualPropertyName
,
Object
.
class
);
return
vertex
.
getProperty
(
actualPropertyName
,
Object
.
class
);
}
}
}
}
@Monitored
public
static
Object
getProperty
(
AtlasEdge
<?,?>
edge
,
String
propertyName
)
{
public
static
Object
getProperty
(
AtlasEdge
<?,?>
edge
,
String
propertyName
)
{
String
elementStr
=
string
(
edge
);
String
elementStr
=
string
(
edge
);
String
actualPropertyName
=
GraphHelper
.
encodePropertyKey
(
propertyName
);
String
actualPropertyName
=
GraphHelper
.
encodePropertyKey
(
propertyName
);
...
@@ -429,6 +438,7 @@ public final class GraphHelper {
...
@@ -429,6 +438,7 @@ public final class GraphHelper {
* @param propertyName
* @param propertyName
* @param value
* @param value
*/
*/
@Monitored
public
static
void
addProperty
(
AtlasVertex
vertex
,
String
propertyName
,
Object
value
)
{
public
static
void
addProperty
(
AtlasVertex
vertex
,
String
propertyName
,
Object
value
)
{
String
actualPropertyName
=
GraphHelper
.
encodePropertyKey
(
propertyName
);
String
actualPropertyName
=
GraphHelper
.
encodePropertyKey
(
propertyName
);
LOG
.
debug
(
"Adding property {} = \"{}\" to vertex {}"
,
actualPropertyName
,
value
,
string
(
vertex
));
LOG
.
debug
(
"Adding property {} = \"{}\" to vertex {}"
,
actualPropertyName
,
value
,
string
(
vertex
));
...
@@ -440,6 +450,7 @@ public final class GraphHelper {
...
@@ -440,6 +450,7 @@ public final class GraphHelper {
*
*
* @param edge
* @param edge
*/
*/
@Monitored
public
void
removeEdge
(
AtlasEdge
edge
)
{
public
void
removeEdge
(
AtlasEdge
edge
)
{
String
edgeString
=
string
(
edge
);
String
edgeString
=
string
(
edge
);
LOG
.
debug
(
"Removing {}"
,
edgeString
);
LOG
.
debug
(
"Removing {}"
,
edgeString
);
...
@@ -450,8 +461,9 @@ public final class GraphHelper {
...
@@ -450,8 +461,9 @@ public final class GraphHelper {
/**
/**
* Remove the specified AtlasVertex from the graph.
* Remove the specified AtlasVertex from the graph.
*
*
* @param
AtlasV
ertex
* @param
v
ertex
*/
*/
@Monitored
public
void
removeVertex
(
AtlasVertex
vertex
)
{
public
void
removeVertex
(
AtlasVertex
vertex
)
{
String
vertexString
=
string
(
vertex
);
String
vertexString
=
string
(
vertex
);
LOG
.
debug
(
"Removing {}"
,
vertexString
);
LOG
.
debug
(
"Removing {}"
,
vertexString
);
...
@@ -746,6 +758,7 @@ public final class GraphHelper {
...
@@ -746,6 +758,7 @@ public final class GraphHelper {
}
}
@Monitored
public
static
void
setArrayElementsProperty
(
IDataType
elementType
,
AtlasVertex
instanceVertex
,
String
propertyName
,
List
<
Object
>
values
)
{
public
static
void
setArrayElementsProperty
(
IDataType
elementType
,
AtlasVertex
instanceVertex
,
String
propertyName
,
List
<
Object
>
values
)
{
String
actualPropertyName
=
GraphHelper
.
encodePropertyKey
(
propertyName
);
String
actualPropertyName
=
GraphHelper
.
encodePropertyKey
(
propertyName
);
if
(
GraphHelper
.
isReference
(
elementType
))
{
if
(
GraphHelper
.
isReference
(
elementType
))
{
...
@@ -756,6 +769,7 @@ public final class GraphHelper {
...
@@ -756,6 +769,7 @@ public final class GraphHelper {
}
}
}
}
@Monitored
public
static
void
setMapValueProperty
(
IDataType
elementType
,
AtlasVertex
instanceVertex
,
String
propertyName
,
Object
value
)
{
public
static
void
setMapValueProperty
(
IDataType
elementType
,
AtlasVertex
instanceVertex
,
String
propertyName
,
Object
value
)
{
String
actualPropertyName
=
GraphHelper
.
encodePropertyKey
(
propertyName
);
String
actualPropertyName
=
GraphHelper
.
encodePropertyKey
(
propertyName
);
if
(
GraphHelper
.
isReference
(
elementType
))
{
if
(
GraphHelper
.
isReference
(
elementType
))
{
...
@@ -766,6 +780,7 @@ public final class GraphHelper {
...
@@ -766,6 +780,7 @@ public final class GraphHelper {
}
}
}
}
@Monitored
public
static
Object
getMapValueProperty
(
IDataType
elementType
,
AtlasVertex
instanceVertex
,
String
propertyName
)
{
public
static
Object
getMapValueProperty
(
IDataType
elementType
,
AtlasVertex
instanceVertex
,
String
propertyName
)
{
String
actualPropertyName
=
GraphHelper
.
encodePropertyKey
(
propertyName
);
String
actualPropertyName
=
GraphHelper
.
encodePropertyKey
(
propertyName
);
if
(
GraphHelper
.
isReference
(
elementType
))
{
if
(
GraphHelper
.
isReference
(
elementType
))
{
...
@@ -776,6 +791,7 @@ public final class GraphHelper {
...
@@ -776,6 +791,7 @@ public final class GraphHelper {
}
}
}
}
@Monitored
public
static
List
<
Object
>
getArrayElementsProperty
(
IDataType
elementType
,
AtlasVertex
instanceVertex
,
String
propertyName
)
{
public
static
List
<
Object
>
getArrayElementsProperty
(
IDataType
elementType
,
AtlasVertex
instanceVertex
,
String
propertyName
)
{
String
actualPropertyName
=
GraphHelper
.
encodePropertyKey
(
propertyName
);
String
actualPropertyName
=
GraphHelper
.
encodePropertyKey
(
propertyName
);
if
(
GraphHelper
.
isReference
(
elementType
))
{
if
(
GraphHelper
.
isReference
(
elementType
))
{
...
@@ -918,7 +934,4 @@ public final class GraphHelper {
...
@@ -918,7 +934,4 @@ public final class GraphHelper {
String
actualPropertyName
=
GraphHelper
.
encodePropertyKey
(
propertyName
);
String
actualPropertyName
=
GraphHelper
.
encodePropertyKey
(
propertyName
);
return
instanceVertex
.
getListProperty
(
actualPropertyName
);
return
instanceVertex
.
getListProperty
(
actualPropertyName
);
}
}
}
}
repository/src/main/java/org/apache/atlas/repository/graph/GraphToTypedInstanceMapper.java
View file @
1fa05264
...
@@ -17,17 +17,9 @@
...
@@ -17,17 +17,9 @@
*/
*/
package
org
.
apache
.
atlas
.
repository
.
graph
;
package
org
.
apache
.
atlas
.
repository
.
graph
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
string
;
import
com.google.inject.Singleton
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.aspect.Monitored
;
import
org.apache.atlas.repository.Constants
;
import
org.apache.atlas.repository.Constants
;
import
org.apache.atlas.repository.graphdb.AtlasEdge
;
import
org.apache.atlas.repository.graphdb.AtlasEdge
;
import
org.apache.atlas.repository.graphdb.AtlasEdgeDirection
;
import
org.apache.atlas.repository.graphdb.AtlasEdgeDirection
;
...
@@ -51,7 +43,15 @@ import org.apache.atlas.typesystem.types.TypeSystem;
...
@@ -51,7 +43,15 @@ import org.apache.atlas.typesystem.types.TypeSystem;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
com.google.inject.Singleton
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
string
;
@Singleton
@Singleton
public
final
class
GraphToTypedInstanceMapper
{
public
final
class
GraphToTypedInstanceMapper
{
...
@@ -66,6 +66,7 @@ public final class GraphToTypedInstanceMapper {
...
@@ -66,6 +66,7 @@ public final class GraphToTypedInstanceMapper {
this
.
graph
=
graph
;
this
.
graph
=
graph
;
}
}
@Monitored
public
ITypedReferenceableInstance
mapGraphToTypedInstance
(
String
guid
,
AtlasVertex
instanceVertex
)
public
ITypedReferenceableInstance
mapGraphToTypedInstance
(
String
guid
,
AtlasVertex
instanceVertex
)
throws
AtlasException
{
throws
AtlasException
{
...
@@ -95,6 +96,7 @@ public final class GraphToTypedInstanceMapper {
...
@@ -95,6 +96,7 @@ public final class GraphToTypedInstanceMapper {
return
typedInstance
;
return
typedInstance
;
}
}
@Monitored
private
void
mapVertexToInstanceTraits
(
AtlasVertex
instanceVertex
,
ITypedReferenceableInstance
typedInstance
,
private
void
mapVertexToInstanceTraits
(
AtlasVertex
instanceVertex
,
ITypedReferenceableInstance
typedInstance
,
List
<
String
>
traits
)
throws
AtlasException
{
List
<
String
>
traits
)
throws
AtlasException
{
for
(
String
traitName
:
traits
)
{
for
(
String
traitName
:
traits
)
{
...
@@ -104,6 +106,7 @@ public final class GraphToTypedInstanceMapper {
...
@@ -104,6 +106,7 @@ public final class GraphToTypedInstanceMapper {
}
}
}
}
@Monitored
public
void
mapVertexToInstance
(
AtlasVertex
instanceVertex
,
ITypedInstance
typedInstance
,
public
void
mapVertexToInstance
(
AtlasVertex
instanceVertex
,
ITypedInstance
typedInstance
,
Map
<
String
,
AttributeInfo
>
fields
)
throws
AtlasException
{
Map
<
String
,
AttributeInfo
>
fields
)
throws
AtlasException
{
...
...
repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java
View file @
1fa05264
...
@@ -17,21 +17,10 @@
...
@@ -17,21 +17,10 @@
*/
*/
package
org
.
apache
.
atlas
.
repository
.
graph
;
package
org
.
apache
.
atlas
.
repository
.
graph
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
string
;
import
com.google.inject.Inject
;
import
java.security.MessageDigest
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.RequestContext
;
import
org.apache.atlas.RequestContext
;
import
org.apache.atlas.aspect.Monitored
;
import
org.apache.atlas.repository.Constants
;
import
org.apache.atlas.repository.Constants
;
import
org.apache.atlas.repository.RepositoryException
;
import
org.apache.atlas.repository.RepositoryException
;
import
org.apache.atlas.repository.graphdb.AtlasEdge
;
import
org.apache.atlas.repository.graphdb.AtlasEdge
;
...
@@ -59,7 +48,18 @@ import org.apache.atlas.utils.MD5Utils;
...
@@ -59,7 +48,18 @@ import org.apache.atlas.utils.MD5Utils;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
com.google.inject.Inject
;
import
java.security.MessageDigest
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
string
;
public
final
class
TypedInstanceToGraphMapper
{
public
final
class
TypedInstanceToGraphMapper
{
...
@@ -85,9 +85,9 @@ public final class TypedInstanceToGraphMapper {
...
@@ -85,9 +85,9 @@ public final class TypedInstanceToGraphMapper {
UPDATE_FULL
UPDATE_FULL
}
}
@Monitored
void
mapTypedInstanceToGraph
(
Operation
operation
,
ITypedReferenceableInstance
...
typedInstances
)
void
mapTypedInstanceToGraph
(
Operation
operation
,
ITypedReferenceableInstance
...
typedInstances
)
throws
AtlasException
{
throws
AtlasException
{
RequestContext
requestContext
=
RequestContext
.
get
();
RequestContext
requestContext
=
RequestContext
.
get
();
for
(
ITypedReferenceableInstance
typedInstance
:
typedInstances
)
{
for
(
ITypedReferenceableInstance
typedInstance
:
typedInstances
)
{
LOG
.
debug
(
"Adding/updating entity {}"
,
typedInstance
);
LOG
.
debug
(
"Adding/updating entity {}"
,
typedInstance
);
...
@@ -150,6 +150,7 @@ public final class TypedInstanceToGraphMapper {
...
@@ -150,6 +150,7 @@ public final class TypedInstanceToGraphMapper {
return
guids
;
return
guids
;
}
}
@Monitored
private
String
addOrUpdateAttributesAndTraits
(
Operation
operation
,
ITypedReferenceableInstance
typedInstance
)
private
String
addOrUpdateAttributesAndTraits
(
Operation
operation
,
ITypedReferenceableInstance
typedInstance
)
throws
AtlasException
{
throws
AtlasException
{
LOG
.
debug
(
"Adding/Updating typed instance {}"
,
typedInstance
.
toShortString
());
LOG
.
debug
(
"Adding/Updating typed instance {}"
,
typedInstance
.
toShortString
());
...
@@ -235,6 +236,7 @@ public final class TypedInstanceToGraphMapper {
...
@@ -235,6 +236,7 @@ public final class TypedInstanceToGraphMapper {
}
}
}
}
@Monitored
private
TypeUtils
.
Pair
<
List
<
ITypedReferenceableInstance
>,
List
<
ITypedReferenceableInstance
>>
createVerticesAndDiscoverInstances
(
private
TypeUtils
.
Pair
<
List
<
ITypedReferenceableInstance
>,
List
<
ITypedReferenceableInstance
>>
createVerticesAndDiscoverInstances
(
Collection
<
IReferenceableInstance
>
instances
)
throws
AtlasException
{
Collection
<
IReferenceableInstance
>
instances
)
throws
AtlasException
{
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasGraphUtilsV1.java
View file @
1fa05264
...
@@ -142,7 +142,7 @@ public class AtlasGraphUtilsV1 {
...
@@ -142,7 +142,7 @@ public class AtlasGraphUtilsV1 {
return
returnType
.
cast
(
property
);
return
returnType
.
cast
(
property
);
}
}
private
static
<
T
extends
AtlasElement
>
String
toString
(
T
element
)
{
private
static
String
toString
(
AtlasElement
element
)
{
if
(
element
instanceof
AtlasVertex
)
{
if
(
element
instanceof
AtlasVertex
)
{
return
toString
((
AtlasVertex
)
element
);
return
toString
((
AtlasVertex
)
element
);
}
else
if
(
element
instanceof
AtlasEdge
)
{
}
else
if
(
element
instanceof
AtlasEdge
)
{
...
...
server-api/pom.xml
View file @
1fa05264
...
@@ -60,6 +60,58 @@
...
@@ -60,6 +60,58 @@
<groupId>
org.apache.atlas
</groupId>
<groupId>
org.apache.atlas
</groupId>
<artifactId>
atlas-client
</artifactId>
<artifactId>
atlas-client
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
org.aspectj
</groupId>
<artifactId>
aspectjrt
</artifactId>
</dependency>
</dependencies>
</dependencies>
</project>
<build>
\ No newline at end of file
<plugins>
<plugin>
<groupId>
org.codehaus.mojo
</groupId>
<artifactId>
aspectj-maven-plugin
</artifactId>
<configuration>
<complianceLevel>
1.7
</complianceLevel>
<showWeaveInfo>
true
</showWeaveInfo>
<verbose>
true
</verbose>
<forceAjcCompile>
true
</forceAjcCompile>
<includes>
<include>
**/*.java
</include>
<include>
**/*.aj
</include>
</includes>
</configuration>
<executions>
<execution>
<id>
compile_with_aspectj
</id>
<goals>
<goal>
compile
</goal>
</goals>
<configuration>
<aspectDirectory>
src/main/java
</aspectDirectory>
</configuration>
</execution>
<execution>
<id>
test-compile_with_aspectj
</id>
<goals>
<goal>
test-compile
</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>
org.aspectj
</groupId>
<artifactId>
aspectjrt
</artifactId>
<version>
${aspectj.runtime.version}
</version>
</dependency>
<dependency>
<groupId>
org.aspectj
</groupId>
<artifactId>
aspectjtools
</artifactId>
<version>
${aspectj.runtime.version}
</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
server-api/src/main/java/org/apache/atlas/RequestContext.java
View file @
1fa05264
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
package
org
.
apache
.
atlas
;
package
org
.
apache
.
atlas
;
import
org.apache.atlas.metrics.Metrics
;
import
org.apache.atlas.typesystem.ITypedReferenceableInstance
;
import
org.apache.atlas.typesystem.ITypedReferenceableInstance
;
import
org.apache.atlas.typesystem.persistence.Id
;
import
org.apache.atlas.typesystem.persistence.Id
;
import
org.apache.atlas.typesystem.types.ClassType
;
import
org.apache.atlas.typesystem.types.ClassType
;
...
@@ -45,6 +46,7 @@ public class RequestContext {
...
@@ -45,6 +46,7 @@ public class RequestContext {
private
long
requestTime
;
private
long
requestTime
;
TypeSystem
typeSystem
=
TypeSystem
.
getInstance
();
TypeSystem
typeSystem
=
TypeSystem
.
getInstance
();
private
Metrics
metrics
=
new
Metrics
();
private
RequestContext
()
{
private
RequestContext
()
{
}
}
...
@@ -124,4 +126,8 @@ public class RequestContext {
...
@@ -124,4 +126,8 @@ public class RequestContext {
public
boolean
isDeletedEntity
(
String
entityGuid
)
{
public
boolean
isDeletedEntity
(
String
entityGuid
)
{
return
deletedEntityIds
.
contains
(
entityGuid
);
return
deletedEntityIds
.
contains
(
entityGuid
);
}
}
public
static
Metrics
getMetrics
()
{
return
get
().
metrics
;
}
}
}
server-api/src/main/java/org/apache/atlas/aspect/AtlasAspect.java
0 → 100644
View file @
1fa05264
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
apache
.
atlas
.
aspect
;
import
org.apache.atlas.RequestContext
;
import
org.apache.atlas.metrics.Metrics
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.Signature
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.List
;
@Aspect
public
class
AtlasAspect
{
public
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
AtlasAspect
.
class
);
@Around
(
"@annotation(org.apache.atlas.aspect.Monitored) && execution(* *(..))"
)
public
Object
collectMetricsForMonitored
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
Signature
methodSign
=
joinPoint
.
getSignature
();
Metrics
metrics
=
RequestContext
.
getMetrics
();
String
metricName
=
methodSign
.
getDeclaringType
().
getSimpleName
()
+
"."
+
methodSign
.
getName
();
long
start
=
System
.
currentTimeMillis
();
try
{
Object
response
=
joinPoint
.
proceed
();
return
response
;
}
finally
{
metrics
.
record
(
metricName
,
(
System
.
currentTimeMillis
()
-
start
));
}
}
@Around
(
"@annotation(org.apache.atlas.aspect.Loggable) && execution(* *(..))"
)
public
Object
logAroundLoggable
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
Signature
methodSign
=
joinPoint
.
getSignature
();
String
methodName
=
methodSign
.
getDeclaringType
().
getSimpleName
()
+
"."
+
methodSign
.
getName
();
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
String
.
format
(
"==> %s(%s)"
,
methodName
,
joinPoint
.
getArgs
()));
}
Object
response
=
joinPoint
.
proceed
();
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
String
.
format
(
"<== %s(%s): %s"
,
methodName
,
joinPoint
.
getArgs
(),
response
instanceof
List
?
((
List
)
response
).
size
()
:
response
));
}
return
response
;
}
}
\ No newline at end of file
server-api/src/main/java/org/apache/atlas/aspect/Loggable.java
0 → 100644
View file @
1fa05264
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
apache
.
atlas
.
aspect
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
(
ElementType
.
METHOD
)
public
@interface
Loggable
{
}
\ No newline at end of file
server-api/src/main/java/org/apache/atlas/aspect/Monitored.java
0 → 100644
View file @
1fa05264
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
apache
.
atlas
.
aspect
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
(
ElementType
.
METHOD
)
public
@interface
Monitored
{
}
\ No newline at end of file
server-api/src/main/java/org/apache/atlas/metrics/Metrics.java
0 → 100644
View file @
1fa05264
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
apache
.
atlas
.
metrics
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
public
class
Metrics
{
public
static
class
Counters
{
private
short
invocations
=
0
;
private
long
totalTimeMSecs
=
0
;
@Override
public
String
toString
()
{
return
"[count="
+
invocations
+
", totalTimeMSec="
+
totalTimeMSecs
+
"]"
;
}
public
short
getInvocations
()
{
return
invocations
;
}
public
long
getTotalTimeMSecs
()
{
return
totalTimeMSecs
;
}
}
Map
<
String
,
Counters
>
countersMap
=
new
LinkedHashMap
<>();
public
void
record
(
String
name
,
long
timeMsecs
)
{
Counters
counter
=
countersMap
.
get
(
name
);
if
(
counter
==
null
)
{
counter
=
new
Counters
();
countersMap
.
put
(
name
,
counter
);
}
counter
.
invocations
++;
counter
.
totalTimeMSecs
+=
timeMsecs
;
}
@Override
public
String
toString
()
{
return
countersMap
.
toString
();
}
public
boolean
isEmpty
()
{
return
countersMap
.
isEmpty
();
}
public
Counters
getCounters
(
String
name
)
{
return
countersMap
.
get
(
name
);
}
}
server-api/src/test/aspect/org/apache/atlas/MonitoredAspectTest.java
0 → 100644
View file @
1fa05264
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
apache
.
atlas
;
import
org.apache.atlas.aspect.Monitored
;
import
org.apache.atlas.metrics.Metrics
;
import
org.testng.annotations.Test
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertNotNull
;
import
static
org
.
testng
.
Assert
.
assertTrue
;
public
class
MonitoredAspectTest
{
@Monitored
public
void
monitoredMethod
()
throws
InterruptedException
{
Thread
.
sleep
(
1
);
}
@Test
public
void
testMonitoredAspect
()
throws
Exception
{
RequestContext
.
clear
();
monitoredMethod
();
Metrics
metrics
=
RequestContext
.
getMetrics
();
Metrics
.
Counters
counters
=
metrics
.
getCounters
(
"MonitoredAspectTest.monitoredMethod"
);
assertNotNull
(
counters
);
assertEquals
(
counters
.
getInvocations
(),
1
);
assertTrue
(
counters
.
getTotalTimeMSecs
()
>
0
);
}
}
typesystem/src/main/resources/atlas-log4j.xml
View file @
1fa05264
...
@@ -41,22 +41,6 @@
...
@@ -41,22 +41,6 @@
<appender-ref
ref=
"console"
/>
<appender-ref
ref=
"console"
/>
</logger>
</logger>
<!-- uncomment this block to generate performance traces
<appender name="perf_appender" class="org.apache.log4j.DailyRollingFileAppender">
<param name="file" value="${atlas.log.dir}/atlas_perf.log" />
<param name="datePattern" value="'.'yyyy-MM-dd" />
<param name="append" value="true" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d|%t|%m%n" />
</layout>
</appender>
<logger name="org.apache.atlas.perf" additivity="false">
<level value="debug" />
<appender-ref ref="perf_appender" />
</logger>
-->
<appender
name=
"FAILED"
class=
"org.apache.log4j.DailyRollingFileAppender"
>
<appender
name=
"FAILED"
class=
"org.apache.log4j.DailyRollingFileAppender"
>
<param
name=
"File"
value=
"${atlas.log.dir}/failed.log"
/>
<param
name=
"File"
value=
"${atlas.log.dir}/failed.log"
/>
<param
name=
"Append"
value=
"true"
/>
<param
name=
"Append"
value=
"true"
/>
...
...
webapp/pom.xml
View file @
1fa05264
...
@@ -384,6 +384,16 @@
...
@@ -384,6 +384,16 @@
</exclusion>
</exclusion>
</exclusions>
</exclusions>
</dependency>
</dependency>
<dependency>
<groupId>
org.aspectj
</groupId>
<artifactId>
aspectjrt
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.atlas
</groupId>
<artifactId>
atlas-server-api
</artifactId>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
@@ -607,6 +617,47 @@
...
@@ -607,6 +617,47 @@
</execution>
</execution>
</executions>
</executions>
</plugin>
</plugin>
<plugin>
<groupId>
org.codehaus.mojo
</groupId>
<artifactId>
aspectj-maven-plugin
</artifactId>
<configuration>
<complianceLevel>
1.7
</complianceLevel>
<includes>
<include>
**/*.java
</include>
<include>
**/*.aj
</include>
</includes>
<XaddSerialVersionUID>
true
</XaddSerialVersionUID>
<showWeaveInfo>
true
</showWeaveInfo>
<aspectLibraries>
<aspectLibrary>
<groupId>
org.apache.atlas
</groupId>
<artifactId>
atlas-server-api
</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<id>
compile_with_aspectj
</id>
<goals>
<goal>
compile
</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>
org.aspectj
</groupId>
<artifactId>
aspectjtools
</artifactId>
<version>
${aspectj.runtime.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.atlas
</groupId>
<artifactId>
atlas-server-api
</artifactId>
<version>
${project.version}
</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</plugins>
</build>
</build>
</project>
</project>
webapp/src/main/java/org/apache/atlas/web/filters/AuditFilter.java
View file @
1fa05264
...
@@ -21,6 +21,7 @@ package org.apache.atlas.web.filters;
...
@@ -21,6 +21,7 @@ package org.apache.atlas.web.filters;
import
com.google.inject.Singleton
;
import
com.google.inject.Singleton
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.RequestContext
;
import
org.apache.atlas.RequestContext
;
import
org.apache.atlas.metrics.Metrics
;
import
org.apache.atlas.web.util.DateTimeHelper
;
import
org.apache.atlas.web.util.DateTimeHelper
;
import
org.apache.atlas.web.util.Servlets
;
import
org.apache.atlas.web.util.Servlets
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -47,6 +48,7 @@ public class AuditFilter implements Filter {
...
@@ -47,6 +48,7 @@ public class AuditFilter implements Filter {
private
static
final
Logger
AUDIT_LOG
=
LoggerFactory
.
getLogger
(
"AUDIT"
);
private
static
final
Logger
AUDIT_LOG
=
LoggerFactory
.
getLogger
(
"AUDIT"
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
AuditFilter
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
AuditFilter
.
class
);
private
static
final
Logger
METRICS_LOG
=
LoggerFactory
.
getLogger
(
"METRICS"
);
@Override
@Override
public
void
init
(
FilterConfig
filterConfig
)
throws
ServletException
{
public
void
init
(
FilterConfig
filterConfig
)
throws
ServletException
{
...
@@ -73,6 +75,7 @@ public class AuditFilter implements Filter {
...
@@ -73,6 +75,7 @@ public class AuditFilter implements Filter {
// put the request id into the response so users can trace logs for this request
// put the request id into the response so users can trace logs for this request
((
HttpServletResponse
)
response
).
setHeader
(
AtlasClient
.
REQUEST_ID
,
requestId
);
((
HttpServletResponse
)
response
).
setHeader
(
AtlasClient
.
REQUEST_ID
,
requestId
);
currentThread
.
setName
(
oldName
);
currentThread
.
setName
(
oldName
);
recordMetrics
();
RequestContext
.
clear
();
RequestContext
.
clear
();
}
}
}
}
...
@@ -103,6 +106,14 @@ public class AuditFilter implements Filter {
...
@@ -103,6 +106,14 @@ public class AuditFilter implements Filter {
whatAddrs
,
whenISO9601
);
whatAddrs
,
whenISO9601
);
}
}
public
static
void
recordMetrics
()
{
//record metrics
Metrics
requestMetrics
=
RequestContext
.
getMetrics
();
if
(!
requestMetrics
.
isEmpty
())
{
METRICS_LOG
.
info
(
"{}"
,
requestMetrics
);
}
}
@Override
@Override
public
void
destroy
()
{
public
void
destroy
()
{
// do nothing
// do nothing
...
...
webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
View file @
1fa05264
...
@@ -18,19 +18,9 @@
...
@@ -18,19 +18,9 @@
package
org
.
apache
.
atlas
.
web
.
resources
;
package
org
.
apache
.
atlas
.
web
.
resources
;
import
java.util.Collection
;
import
com.google.inject.Inject
;
import
java.util.HashSet
;
import
java.util.Set
;
import
javax.inject.Singleton
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.WebApplicationException
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.aspect.Monitored
;
import
org.apache.atlas.utils.AtlasPerfTracer
;
import
org.apache.atlas.utils.AtlasPerfTracer
;
import
org.apache.atlas.web.filters.AtlasCSRFPreventionFilter
;
import
org.apache.atlas.web.filters.AtlasCSRFPreventionFilter
;
import
org.apache.atlas.web.service.ServiceState
;
import
org.apache.atlas.web.service.ServiceState
;
...
@@ -45,7 +35,16 @@ import org.springframework.security.core.Authentication;
...
@@ -45,7 +35,16 @@ import org.springframework.security.core.Authentication;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
com.google.inject.Inject
;
import
javax.inject.Singleton
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.WebApplicationException
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
java.util.Collection
;
import
java.util.HashSet
;
import
java.util.Set
;
/**
/**
* Jersey Resource for admin operations.
* Jersey Resource for admin operations.
...
@@ -74,36 +73,27 @@ public class AdminResource {
...
@@ -74,36 +73,27 @@ public class AdminResource {
*
*
* @return json representing the thread stack dump.
* @return json representing the thread stack dump.
*/
*/
@Monitored
@GET
@GET
@Path
(
"stack"
)
@Path
(
"stack"
)
@Produces
(
MediaType
.
TEXT_PLAIN
)
@Produces
(
MediaType
.
TEXT_PLAIN
)
public
String
getThreadDump
()
{
public
String
getThreadDump
()
{
AtlasPerfTracer
perf
=
null
;
ThreadGroup
topThreadGroup
=
Thread
.
currentThread
().
getThreadGroup
()
;
try
{
while
(
topThreadGroup
.
getParent
()
!=
null
)
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
topThreadGroup
=
topThreadGroup
.
getParent
();
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"AdminResource.getThreadDump()"
);
}
ThreadGroup
topThreadGroup
=
Thread
.
currentThread
().
getThreadGroup
();
while
(
topThreadGroup
.
getParent
()
!=
null
)
{
topThreadGroup
=
topThreadGroup
.
getParent
();
}
Thread
[]
threads
=
new
Thread
[
topThreadGroup
.
activeCount
()];
int
nr
=
topThreadGroup
.
enumerate
(
threads
);
StringBuilder
builder
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
nr
;
i
++)
{
builder
.
append
(
threads
[
i
].
getName
()).
append
(
"\nState: "
).
append
(
threads
[
i
].
getState
()).
append
(
"\n"
);
String
stackTrace
=
StringUtils
.
join
(
threads
[
i
].
getStackTrace
(),
"\n"
);
builder
.
append
(
stackTrace
);
}
return
builder
.
toString
();
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
Thread
[]
threads
=
new
Thread
[
topThreadGroup
.
activeCount
()];
int
nr
=
topThreadGroup
.
enumerate
(
threads
);
StringBuilder
builder
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
nr
;
i
++)
{
builder
.
append
(
threads
[
i
].
getName
()).
append
(
"\nState: "
).
append
(
threads
[
i
].
getState
()).
append
(
"\n"
);
String
stackTrace
=
StringUtils
.
join
(
threads
[
i
].
getStackTrace
(),
"\n"
);
builder
.
append
(
stackTrace
);
}
return
builder
.
toString
();
}
}
/**
/**
...
@@ -111,77 +101,55 @@ public class AdminResource {
...
@@ -111,77 +101,55 @@ public class AdminResource {
*
*
* @return json representing the version.
* @return json representing the version.
*/
*/
@Monitored
@GET
@GET
@Path
(
"version"
)
@Path
(
"version"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
getVersion
()
{
public
Response
getVersion
()
{
AtlasPerfTracer
perf
=
null
;
if
(
version
==
null
)
{
try
{
try
{
PropertiesConfiguration
configProperties
=
new
PropertiesConfiguration
(
"atlas-buildinfo.properties"
);
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"AdminResource.getVersion()"
);
JSONObject
response
=
new
JSONObject
();
}
response
.
put
(
"Version"
,
configProperties
.
getString
(
"build.version"
,
"UNKNOWN"
));
response
.
put
(
"Name"
,
configProperties
.
getString
(
"project.name"
,
"apache-atlas"
));
if
(
version
==
null
)
{
response
.
put
(
"Description"
,
configProperties
.
getString
(
"project.description"
,
try
{
"Metadata Management and Data Governance Platform over Hadoop"
));
PropertiesConfiguration
configProperties
=
new
PropertiesConfiguration
(
"atlas-buildinfo.properties"
);
// todo: add hadoop version?
JSONObject
response
=
new
JSONObject
();
// response.put("Hadoop", VersionInfo.getVersion() + "-r" + VersionInfo.getRevision());
response
.
put
(
"Version"
,
configProperties
.
getString
(
"build.version"
,
"UNKNOWN"
));
version
=
Response
.
ok
(
response
).
build
();
response
.
put
(
"Name"
,
configProperties
.
getString
(
"project.name"
,
"apache-atlas"
));
}
catch
(
JSONException
|
ConfigurationException
e
)
{
response
.
put
(
"Description"
,
configProperties
.
getString
(
"project.description"
,
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
"Metadata Management and Data Governance Platform over Hadoop"
));
// todo: add hadoop version?
// response.put("Hadoop", VersionInfo.getVersion() + "-r" + VersionInfo.getRevision());
version
=
Response
.
ok
(
response
).
build
();
}
catch
(
JSONException
|
ConfigurationException
e
)
{
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
}
}
return
version
;
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
return
version
;
}
}
@Monitored
@GET
@GET
@Path
(
"status"
)
@Path
(
"status"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
getStatus
()
{
public
Response
getStatus
()
{
AtlasPerfTracer
perf
=
null
;
JSONObject
responseData
=
new
JSONObject
();
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
responseData
.
put
(
AtlasClient
.
STATUS
,
serviceState
.
getState
().
toString
());
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"AdminResource.getStatus()"
);
Response
response
=
Response
.
ok
(
responseData
).
build
();
}
return
response
;
}
catch
(
JSONException
e
)
{
JSONObject
responseData
=
new
JSONObject
();
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
try
{
responseData
.
put
(
AtlasClient
.
STATUS
,
serviceState
.
getState
().
toString
());
Response
response
=
Response
.
ok
(
responseData
).
build
();
return
response
;
}
catch
(
JSONException
e
)
{
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
@Monitored
@GET
@GET
@Path
(
"session"
)
@Path
(
"session"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
getUserProfile
()
{
public
Response
getUserProfile
()
{
JSONObject
responseData
=
new
JSONObject
();
JSONObject
responseData
=
new
JSONObject
();
Boolean
enableTaxonomy
=
null
;
Boolean
enableTaxonomy
=
null
;
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"AdminResource.getUserProfile()"
);
}
PropertiesConfiguration
configProperties
=
new
PropertiesConfiguration
(
"atlas-application.properties"
);
PropertiesConfiguration
configProperties
=
new
PropertiesConfiguration
(
"atlas-application.properties"
);
enableTaxonomy
=
new
Boolean
(
configProperties
.
getString
(
isTaxonomyEnabled
,
"false"
));
enableTaxonomy
=
new
Boolean
(
configProperties
.
getString
(
isTaxonomyEnabled
,
"false"
));
Authentication
auth
=
SecurityContextHolder
.
getContext
().
getAuthentication
();
Authentication
auth
=
SecurityContextHolder
.
getContext
().
getAuthentication
();
...
@@ -208,8 +176,6 @@ public class AdminResource {
...
@@ -208,8 +176,6 @@ public class AdminResource {
return
response
;
return
response
;
}
catch
(
JSONException
|
ConfigurationException
e
)
{
}
catch
(
JSONException
|
ConfigurationException
e
)
{
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
}
}
webapp/src/main/java/org/apache/atlas/web/resources/DataSetLineageResource.java
View file @
1fa05264
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
package
org
.
apache
.
atlas
.
web
.
resources
;
package
org
.
apache
.
atlas
.
web
.
resources
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.aspect.Monitored
;
import
org.apache.atlas.discovery.DiscoveryException
;
import
org.apache.atlas.discovery.DiscoveryException
;
import
org.apache.atlas.discovery.LineageService
;
import
org.apache.atlas.discovery.LineageService
;
import
org.apache.atlas.typesystem.exception.EntityNotFoundException
;
import
org.apache.atlas.typesystem.exception.EntityNotFoundException
;
...
@@ -68,6 +69,7 @@ public class DataSetLineageResource {
...
@@ -68,6 +69,7 @@ public class DataSetLineageResource {
*
*
* @param tableName table name
* @param tableName table name
*/
*/
@Monitored
@GET
@GET
@Path
(
"table/{tableName}/inputs/graph"
)
@Path
(
"table/{tableName}/inputs/graph"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
...
@@ -75,12 +77,7 @@ public class DataSetLineageResource {
...
@@ -75,12 +77,7 @@ public class DataSetLineageResource {
public
Response
inputsGraph
(
@Context
HttpServletRequest
request
,
@PathParam
(
"tableName"
)
String
tableName
)
{
public
Response
inputsGraph
(
@Context
HttpServletRequest
request
,
@PathParam
(
"tableName"
)
String
tableName
)
{
LOG
.
info
(
"Fetching lineage inputs graph for tableName={}"
,
tableName
);
LOG
.
info
(
"Fetching lineage inputs graph for tableName={}"
,
tableName
);
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"DataSetLineageResource.inputsGraph("
+
tableName
+
")"
);
}
final
String
jsonResult
=
lineageService
.
getInputsGraph
(
tableName
);
final
String
jsonResult
=
lineageService
.
getInputsGraph
(
tableName
);
JSONObject
response
=
new
JSONObject
();
JSONObject
response
=
new
JSONObject
();
...
@@ -98,8 +95,6 @@ public class DataSetLineageResource {
...
@@ -98,8 +95,6 @@ public class DataSetLineageResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get lineage inputs graph for table {}"
,
tableName
,
e
);
LOG
.
error
(
"Unable to get lineage inputs graph for table {}"
,
tableName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
@@ -108,6 +103,7 @@ public class DataSetLineageResource {
...
@@ -108,6 +103,7 @@ public class DataSetLineageResource {
*
*
* @param tableName table name
* @param tableName table name
*/
*/
@Monitored
@GET
@GET
@Path
(
"table/{tableName}/outputs/graph"
)
@Path
(
"table/{tableName}/outputs/graph"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
...
@@ -115,12 +111,7 @@ public class DataSetLineageResource {
...
@@ -115,12 +111,7 @@ public class DataSetLineageResource {
public
Response
outputsGraph
(
@Context
HttpServletRequest
request
,
@PathParam
(
"tableName"
)
String
tableName
)
{
public
Response
outputsGraph
(
@Context
HttpServletRequest
request
,
@PathParam
(
"tableName"
)
String
tableName
)
{
LOG
.
info
(
"Fetching lineage outputs graph for tableName={}"
,
tableName
);
LOG
.
info
(
"Fetching lineage outputs graph for tableName={}"
,
tableName
);
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"DataSetLineageResource.outputsGraph("
+
tableName
+
")"
);
}
final
String
jsonResult
=
lineageService
.
getOutputsGraph
(
tableName
);
final
String
jsonResult
=
lineageService
.
getOutputsGraph
(
tableName
);
JSONObject
response
=
new
JSONObject
();
JSONObject
response
=
new
JSONObject
();
...
@@ -138,8 +129,6 @@ public class DataSetLineageResource {
...
@@ -138,8 +129,6 @@ public class DataSetLineageResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get lineage outputs graph for table {}"
,
tableName
,
e
);
LOG
.
error
(
"Unable to get lineage outputs graph for table {}"
,
tableName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
@@ -148,6 +137,7 @@ public class DataSetLineageResource {
...
@@ -148,6 +137,7 @@ public class DataSetLineageResource {
*
*
* @param tableName table name
* @param tableName table name
*/
*/
@Monitored
@GET
@GET
@Path
(
"table/{tableName}/schema"
)
@Path
(
"table/{tableName}/schema"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
...
@@ -155,12 +145,7 @@ public class DataSetLineageResource {
...
@@ -155,12 +145,7 @@ public class DataSetLineageResource {
public
Response
schema
(
@Context
HttpServletRequest
request
,
@PathParam
(
"tableName"
)
String
tableName
)
{
public
Response
schema
(
@Context
HttpServletRequest
request
,
@PathParam
(
"tableName"
)
String
tableName
)
{
LOG
.
info
(
"Fetching schema for tableName={}"
,
tableName
);
LOG
.
info
(
"Fetching schema for tableName={}"
,
tableName
);
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"DataSetLineageResource.schema("
+
tableName
+
")"
);
}
final
String
jsonResult
=
lineageService
.
getSchema
(
tableName
);
final
String
jsonResult
=
lineageService
.
getSchema
(
tableName
);
JSONObject
response
=
new
JSONObject
();
JSONObject
response
=
new
JSONObject
();
...
@@ -178,8 +163,6 @@ public class DataSetLineageResource {
...
@@ -178,8 +163,6 @@ public class DataSetLineageResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get schema for table {}"
,
tableName
,
e
);
LOG
.
error
(
"Unable to get schema for table {}"
,
tableName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
}
}
webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java
View file @
1fa05264
...
@@ -24,6 +24,7 @@ import org.apache.atlas.AtlasClient;
...
@@ -24,6 +24,7 @@ import org.apache.atlas.AtlasClient;
import
org.apache.atlas.AtlasConstants
;
import
org.apache.atlas.AtlasConstants
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.EntityAuditEvent
;
import
org.apache.atlas.EntityAuditEvent
;
import
org.apache.atlas.aspect.Monitored
;
import
org.apache.atlas.services.MetadataService
;
import
org.apache.atlas.services.MetadataService
;
import
org.apache.atlas.typesystem.IStruct
;
import
org.apache.atlas.typesystem.IStruct
;
import
org.apache.atlas.typesystem.Referenceable
;
import
org.apache.atlas.typesystem.Referenceable
;
...
@@ -33,8 +34,8 @@ import org.apache.atlas.typesystem.exception.TraitNotFoundException;
...
@@ -33,8 +34,8 @@ import org.apache.atlas.typesystem.exception.TraitNotFoundException;
import
org.apache.atlas.typesystem.exception.TypeNotFoundException
;
import
org.apache.atlas.typesystem.exception.TypeNotFoundException
;
import
org.apache.atlas.typesystem.json.InstanceSerialization
;
import
org.apache.atlas.typesystem.json.InstanceSerialization
;
import
org.apache.atlas.typesystem.types.ValueConversionException
;
import
org.apache.atlas.typesystem.types.ValueConversionException
;
import
org.apache.atlas.utils.ParamChecker
;
import
org.apache.atlas.utils.AtlasPerfTracer
;
import
org.apache.atlas.utils.AtlasPerfTracer
;
import
org.apache.atlas.utils.ParamChecker
;
import
org.apache.atlas.web.util.Servlets
;
import
org.apache.atlas.web.util.Servlets
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.codehaus.jettison.json.JSONArray
;
import
org.codehaus.jettison.json.JSONArray
;
...
@@ -104,18 +105,13 @@ public class EntityResource {
...
@@ -104,18 +105,13 @@ public class EntityResource {
* The body contains the JSONArray of entity json. The service takes care of de-duping the entities based on any
* The body contains the JSONArray of entity json. The service takes care of de-duping the entities based on any
* unique attribute for the give type.
* unique attribute for the give type.
*/
*/
@Monitored
@POST
@POST
@Consumes
({
Servlets
.
JSON_MEDIA_TYPE
,
MediaType
.
APPLICATION_JSON
})
@Consumes
({
Servlets
.
JSON_MEDIA_TYPE
,
MediaType
.
APPLICATION_JSON
})
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
submit
(
@Context
HttpServletRequest
request
)
{
public
Response
submit
(
@Context
HttpServletRequest
request
)
{
String
entityJson
=
null
;
String
entityJson
=
null
;
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"EntityResource.submit()"
);
}
String
entities
=
Servlets
.
getRequestPayload
(
request
);
String
entities
=
Servlets
.
getRequestPayload
(
request
);
//Handle backward compatibility - if entities is not JSONArray, convert to JSONArray
//Handle backward compatibility - if entities is not JSONArray, convert to JSONArray
...
@@ -151,8 +147,6 @@ public class EntityResource {
...
@@ -151,8 +147,6 @@ public class EntityResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to persist entity instance entityDef={}"
,
entityJson
,
e
);
LOG
.
error
(
"Unable to persist entity instance entityDef={}"
,
entityJson
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
@@ -190,18 +184,13 @@ public class EntityResource {
...
@@ -190,18 +184,13 @@ public class EntityResource {
* Adds/Updates given entities identified by its GUID or unique attribute
* Adds/Updates given entities identified by its GUID or unique attribute
* @return response payload as json
* @return response payload as json
*/
*/
@Monitored
@PUT
@PUT
@Consumes
({
Servlets
.
JSON_MEDIA_TYPE
,
MediaType
.
APPLICATION_JSON
})
@Consumes
({
Servlets
.
JSON_MEDIA_TYPE
,
MediaType
.
APPLICATION_JSON
})
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
updateEntities
(
@Context
HttpServletRequest
request
)
{
public
Response
updateEntities
(
@Context
HttpServletRequest
request
)
{
String
entityJson
=
null
;
String
entityJson
=
null
;
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"EntityResource.updateEntities()"
);
}
final
String
entities
=
Servlets
.
getRequestPayload
(
request
);
final
String
entities
=
Servlets
.
getRequestPayload
(
request
);
entityJson
=
AtlasClient
.
toString
(
new
JSONArray
(
entities
));
entityJson
=
AtlasClient
.
toString
(
new
JSONArray
(
entities
));
...
@@ -224,8 +213,6 @@ public class EntityResource {
...
@@ -224,8 +213,6 @@ public class EntityResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to persist entity instance entityDef={}"
,
entityJson
,
e
);
LOG
.
error
(
"Unable to persist entity instance entityDef={}"
,
entityJson
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
@@ -258,6 +245,7 @@ public class EntityResource {
...
@@ -258,6 +245,7 @@ public class EntityResource {
* The body contains the JSONArray of entity json. The service takes care of de-duping the entities based on any
* The body contains the JSONArray of entity json. The service takes care of de-duping the entities based on any
* unique attribute for the give type.
* unique attribute for the give type.
*/
*/
@Monitored
@POST
@POST
@Path
(
"qualifiedName"
)
@Path
(
"qualifiedName"
)
@Consumes
({
Servlets
.
JSON_MEDIA_TYPE
,
MediaType
.
APPLICATION_JSON
})
@Consumes
({
Servlets
.
JSON_MEDIA_TYPE
,
MediaType
.
APPLICATION_JSON
})
...
@@ -265,14 +253,8 @@ public class EntityResource {
...
@@ -265,14 +253,8 @@ public class EntityResource {
public
Response
updateByUniqueAttribute
(
@QueryParam
(
"type"
)
String
entityType
,
public
Response
updateByUniqueAttribute
(
@QueryParam
(
"type"
)
String
entityType
,
@QueryParam
(
"property"
)
String
attribute
,
@QueryParam
(
"property"
)
String
attribute
,
@QueryParam
(
"value"
)
String
value
,
@Context
HttpServletRequest
request
)
{
@QueryParam
(
"value"
)
String
value
,
@Context
HttpServletRequest
request
)
{
String
entityJson
=
null
;
String
entityJson
=
null
;
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"EntityResource.updateByUniqueAttribute()"
);
}
entityJson
=
Servlets
.
getRequestPayload
(
request
);
entityJson
=
Servlets
.
getRequestPayload
(
request
);
LOG
.
info
(
"Partially updating entity by unique attribute {} {} {} {} "
,
entityType
,
attribute
,
value
,
entityJson
);
LOG
.
info
(
"Partially updating entity by unique attribute {} {} {} {} "
,
entityType
,
attribute
,
value
,
entityJson
);
...
@@ -301,8 +283,6 @@ public class EntityResource {
...
@@ -301,8 +283,6 @@ public class EntityResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to partially update entity {} {} "
+
entityType
+
":"
+
attribute
+
"."
+
value
,
entityJson
,
e
);
LOG
.
error
(
"Unable to partially update entity {} {} "
+
entityType
+
":"
+
attribute
+
"."
+
value
,
entityJson
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
@@ -321,22 +301,14 @@ public class EntityResource {
...
@@ -321,22 +301,14 @@ public class EntityResource {
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
updateEntityByGuid
(
@PathParam
(
"guid"
)
String
guid
,
@QueryParam
(
"property"
)
String
attribute
,
public
Response
updateEntityByGuid
(
@PathParam
(
"guid"
)
String
guid
,
@QueryParam
(
"property"
)
String
attribute
,
@Context
HttpServletRequest
request
)
{
@Context
HttpServletRequest
request
)
{
AtlasPerfTracer
perf
=
null
;
if
(
StringUtils
.
isEmpty
(
attribute
))
{
try
{
return
updateEntityPartialByGuid
(
guid
,
request
);
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
}
else
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"EntityResource.updateEntityByGuid()"
);
return
updateEntityAttributeByGuid
(
guid
,
attribute
,
request
);
}
if
(
StringUtils
.
isEmpty
(
attribute
))
{
return
updateEntityPartialByGuid
(
guid
,
request
);
}
else
{
return
updateEntityAttributeByGuid
(
guid
,
attribute
,
request
);
}
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
@Monitored
private
Response
updateEntityPartialByGuid
(
String
guid
,
HttpServletRequest
request
)
{
private
Response
updateEntityPartialByGuid
(
String
guid
,
HttpServletRequest
request
)
{
String
entityJson
=
null
;
String
entityJson
=
null
;
try
{
try
{
...
@@ -374,6 +346,7 @@ public class EntityResource {
...
@@ -374,6 +346,7 @@ public class EntityResource {
* @postbody property's value
* @postbody property's value
* @return response payload as json
* @return response payload as json
*/
*/
@Monitored
private
Response
updateEntityAttributeByGuid
(
String
guid
,
String
property
,
HttpServletRequest
request
)
{
private
Response
updateEntityAttributeByGuid
(
String
guid
,
String
property
,
HttpServletRequest
request
)
{
String
value
=
null
;
String
value
=
null
;
try
{
try
{
...
@@ -411,19 +384,14 @@ public class EntityResource {
...
@@ -411,19 +384,14 @@ public class EntityResource {
* @param value the unique attribute value used to identify the entity
* @param value the unique attribute value used to identify the entity
* @return response payload as json - including guids of entities(including composite references from that entity) that were deleted
* @return response payload as json - including guids of entities(including composite references from that entity) that were deleted
*/
*/
@Monitored
@DELETE
@DELETE
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
deleteEntities
(
@QueryParam
(
"guid"
)
List
<
String
>
guids
,
public
Response
deleteEntities
(
@QueryParam
(
"guid"
)
List
<
String
>
guids
,
@QueryParam
(
"type"
)
String
entityType
,
@QueryParam
(
"type"
)
String
entityType
,
@QueryParam
(
"property"
)
String
attribute
,
@QueryParam
(
"property"
)
String
attribute
,
@QueryParam
(
"value"
)
String
value
)
{
@QueryParam
(
"value"
)
String
value
)
{
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"EntityResource.deleteEntities()"
);
}
AtlasClient
.
EntityResult
entityResult
;
AtlasClient
.
EntityResult
entityResult
;
if
(
guids
!=
null
&&
!
guids
.
isEmpty
())
{
if
(
guids
!=
null
&&
!
guids
.
isEmpty
())
{
LOG
.
info
(
"Deleting entities {}"
,
guids
);
LOG
.
info
(
"Deleting entities {}"
,
guids
);
...
@@ -448,8 +416,6 @@ public class EntityResource {
...
@@ -448,8 +416,6 @@ public class EntityResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to delete entities {} {} {} {} "
,
guids
,
entityType
,
attribute
,
value
,
e
);
LOG
.
error
(
"Unable to delete entities {} {} {} {} "
,
guids
,
entityType
,
attribute
,
value
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
@@ -458,16 +424,12 @@ public class EntityResource {
...
@@ -458,16 +424,12 @@ public class EntityResource {
*
*
* @param guid GUID for the entity
* @param guid GUID for the entity
*/
*/
@Monitored
@GET
@GET
@Path
(
"{guid}"
)
@Path
(
"{guid}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
getEntityDefinition
(
@PathParam
(
"guid"
)
String
guid
)
{
public
Response
getEntityDefinition
(
@PathParam
(
"guid"
)
String
guid
)
{
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"EntityResource.getEntityDefinition()"
);
}
LOG
.
debug
(
"Fetching entity definition for guid={} "
,
guid
);
LOG
.
debug
(
"Fetching entity definition for guid={} "
,
guid
);
guid
=
ParamChecker
.
notEmpty
(
guid
,
"guid cannot be null"
);
guid
=
ParamChecker
.
notEmpty
(
guid
,
"guid cannot be null"
);
final
String
entityDefinition
=
metadataService
.
getEntityDefinitionJson
(
guid
);
final
String
entityDefinition
=
metadataService
.
getEntityDefinitionJson
(
guid
);
...
@@ -495,8 +457,6 @@ public class EntityResource {
...
@@ -495,8 +457,6 @@ public class EntityResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get instance definition for GUID {}"
,
guid
,
e
);
LOG
.
error
(
"Unable to get instance definition for GUID {}"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
@@ -505,6 +465,7 @@ public class EntityResource {
...
@@ -505,6 +465,7 @@ public class EntityResource {
*
*
* @param entityType name of a type which is unique
* @param entityType name of a type which is unique
*/
*/
@Monitored
public
Response
getEntityListByType
(
String
entityType
)
{
public
Response
getEntityListByType
(
String
entityType
)
{
try
{
try
{
Preconditions
.
checkNotNull
(
entityType
,
"Entity type cannot be null"
);
Preconditions
.
checkNotNull
(
entityType
,
"Entity type cannot be null"
);
...
@@ -537,21 +498,12 @@ public class EntityResource {
...
@@ -537,21 +498,12 @@ public class EntityResource {
public
Response
getEntity
(
@QueryParam
(
"type"
)
String
entityType
,
public
Response
getEntity
(
@QueryParam
(
"type"
)
String
entityType
,
@QueryParam
(
"property"
)
String
attribute
,
@QueryParam
(
"property"
)
String
attribute
,
@QueryParam
(
"value"
)
String
value
)
{
@QueryParam
(
"value"
)
String
value
)
{
AtlasPerfTracer
perf
=
null
;
if
(
StringUtils
.
isEmpty
(
attribute
))
{
try
{
//List API
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
return
getEntityListByType
(
entityType
);
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"EntityResource.getEntity("
+
entityType
+
", "
+
attribute
+
", "
+
value
+
")"
);
}
else
{
}
//Get entity by unique attribute
return
getEntityDefinitionByAttribute
(
entityType
,
attribute
,
value
);
if
(
StringUtils
.
isEmpty
(
attribute
))
{
//List API
return
getEntityListByType
(
entityType
);
}
else
{
//Get entity by unique attribute
return
getEntityDefinitionByAttribute
(
entityType
,
attribute
,
value
);
}
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
@@ -562,6 +514,7 @@ public class EntityResource {
...
@@ -562,6 +514,7 @@ public class EntityResource {
* @param attribute
* @param attribute
* @param value
* @param value
*/
*/
@Monitored
public
Response
getEntityDefinitionByAttribute
(
String
entityType
,
String
attribute
,
String
value
)
{
public
Response
getEntityDefinitionByAttribute
(
String
entityType
,
String
attribute
,
String
value
)
{
try
{
try
{
LOG
.
debug
(
"Fetching entity definition for type={}, qualified name={}"
,
entityType
,
value
);
LOG
.
debug
(
"Fetching entity definition for type={}, qualified name={}"
,
entityType
,
value
);
...
@@ -606,16 +559,12 @@ public class EntityResource {
...
@@ -606,16 +559,12 @@ public class EntityResource {
* @param guid globally unique identifier for the entity
* @param guid globally unique identifier for the entity
* @return a list of trait names for the given entity guid
* @return a list of trait names for the given entity guid
*/
*/
@Monitored
@GET
@GET
@Path
(
"{guid}/traits"
)
@Path
(
"{guid}/traits"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
getTraitNames
(
@PathParam
(
"guid"
)
String
guid
)
{
public
Response
getTraitNames
(
@PathParam
(
"guid"
)
String
guid
)
{
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"EntityResource.getTraitNames("
+
guid
+
")"
);
}
LOG
.
debug
(
"Fetching trait names for entity={}"
,
guid
);
LOG
.
debug
(
"Fetching trait names for entity={}"
,
guid
);
final
List
<
String
>
traitNames
=
metadataService
.
getTraitNames
(
guid
);
final
List
<
String
>
traitNames
=
metadataService
.
getTraitNames
(
guid
);
...
@@ -634,8 +583,6 @@ public class EntityResource {
...
@@ -634,8 +583,6 @@ public class EntityResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get trait names for entity {}"
,
guid
,
e
);
LOG
.
error
(
"Unable to get trait names for entity {}"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
@@ -643,15 +590,12 @@ public class EntityResource {
...
@@ -643,15 +590,12 @@ public class EntityResource {
* Fetches the trait definitions of all the traits associated to the given entity
* Fetches the trait definitions of all the traits associated to the given entity
* @param guid globally unique identifier for the entity
* @param guid globally unique identifier for the entity
*/
*/
@Monitored
@GET
@GET
@Path
(
"{guid}/traitDefinitions"
)
@Path
(
"{guid}/traitDefinitions"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
getTraitDefinitionsForEntity
(
@PathParam
(
"guid"
)
String
guid
){
public
Response
getTraitDefinitionsForEntity
(
@PathParam
(
"guid"
)
String
guid
){
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"EntityResource.getTraitDefinitionsForEntity("
+
guid
+
")"
);
}
LOG
.
debug
(
"Fetching all trait definitions for entity={}"
,
guid
);
LOG
.
debug
(
"Fetching all trait definitions for entity={}"
,
guid
);
final
String
entityDefinition
=
metadataService
.
getEntityDefinitionJson
(
guid
);
final
String
entityDefinition
=
metadataService
.
getEntityDefinitionJson
(
guid
);
...
@@ -677,10 +621,7 @@ public class EntityResource {
...
@@ -677,10 +621,7 @@ public class EntityResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get trait definitions for entity {}"
,
guid
,
e
);
LOG
.
error
(
"Unable to get trait definitions for entity {}"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
/**
/**
...
@@ -689,15 +630,12 @@ public class EntityResource {
...
@@ -689,15 +630,12 @@ public class EntityResource {
* @param guid globally unique identifier for the entity
* @param guid globally unique identifier for the entity
* @param traitName name of the trait
* @param traitName name of the trait
*/
*/
@Monitored
@GET
@GET
@Path
(
"{guid}/traitDefinitions/{traitName}"
)
@Path
(
"{guid}/traitDefinitions/{traitName}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
getTraitDefinitionForEntity
(
@PathParam
(
"guid"
)
String
guid
,
@PathParam
(
"traitName"
)
String
traitName
){
public
Response
getTraitDefinitionForEntity
(
@PathParam
(
"guid"
)
String
guid
,
@PathParam
(
"traitName"
)
String
traitName
){
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"EntityResource.getTraitDefinitionForEntity("
+
guid
+
", "
+
traitName
+
")"
);
}
LOG
.
debug
(
"Fetching trait definition for entity {} and trait name {}"
,
guid
,
traitName
);
LOG
.
debug
(
"Fetching trait definition for entity {} and trait name {}"
,
guid
,
traitName
);
final
IStruct
traitDefinition
=
metadataService
.
getTraitDefinition
(
guid
,
traitName
);
final
IStruct
traitDefinition
=
metadataService
.
getTraitDefinition
(
guid
,
traitName
);
...
@@ -716,8 +654,6 @@ public class EntityResource {
...
@@ -716,8 +654,6 @@ public class EntityResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get trait definition for entity {} and trait {}"
,
guid
,
traitName
,
e
);
LOG
.
error
(
"Unable to get trait definition for entity {} and trait {}"
,
guid
,
traitName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
@@ -726,18 +662,14 @@ public class EntityResource {
...
@@ -726,18 +662,14 @@ public class EntityResource {
*
*
* @param guid globally unique identifier for the entity
* @param guid globally unique identifier for the entity
*/
*/
@Monitored
@POST
@POST
@Path
(
"{guid}/traits"
)
@Path
(
"{guid}/traits"
)
@Consumes
({
Servlets
.
JSON_MEDIA_TYPE
,
MediaType
.
APPLICATION_JSON
})
@Consumes
({
Servlets
.
JSON_MEDIA_TYPE
,
MediaType
.
APPLICATION_JSON
})
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
addTrait
(
@Context
HttpServletRequest
request
,
@PathParam
(
"guid"
)
final
String
guid
)
{
public
Response
addTrait
(
@Context
HttpServletRequest
request
,
@PathParam
(
"guid"
)
final
String
guid
)
{
String
traitDefinition
=
null
;
String
traitDefinition
=
null
;
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"EntityResource.addTrait("
+
guid
+
")"
);
}
traitDefinition
=
Servlets
.
getRequestPayload
(
request
);
traitDefinition
=
Servlets
.
getRequestPayload
(
request
);
LOG
.
info
(
"Adding trait={} for entity={} "
,
traitDefinition
,
guid
);
LOG
.
info
(
"Adding trait={} for entity={} "
,
traitDefinition
,
guid
);
metadataService
.
addTrait
(
guid
,
traitDefinition
);
metadataService
.
addTrait
(
guid
,
traitDefinition
);
...
@@ -759,8 +691,6 @@ public class EntityResource {
...
@@ -759,8 +691,6 @@ public class EntityResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to add trait for entity={} traitDef={}"
,
guid
,
traitDefinition
,
e
);
LOG
.
error
(
"Unable to add trait for entity={} traitDef={}"
,
guid
,
traitDefinition
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
@@ -770,6 +700,7 @@ public class EntityResource {
...
@@ -770,6 +700,7 @@ public class EntityResource {
* @param guid globally unique identifier for the entity
* @param guid globally unique identifier for the entity
* @param traitName name of the trait
* @param traitName name of the trait
*/
*/
@Monitored
@DELETE
@DELETE
@Path
(
"{guid}/traits/{traitName}"
)
@Path
(
"{guid}/traits/{traitName}"
)
@Consumes
({
Servlets
.
JSON_MEDIA_TYPE
,
MediaType
.
APPLICATION_JSON
})
@Consumes
({
Servlets
.
JSON_MEDIA_TYPE
,
MediaType
.
APPLICATION_JSON
})
...
@@ -777,12 +708,7 @@ public class EntityResource {
...
@@ -777,12 +708,7 @@ public class EntityResource {
public
Response
deleteTrait
(
@Context
HttpServletRequest
request
,
@PathParam
(
"guid"
)
String
guid
,
public
Response
deleteTrait
(
@Context
HttpServletRequest
request
,
@PathParam
(
"guid"
)
String
guid
,
@PathParam
(
TRAIT_NAME
)
String
traitName
)
{
@PathParam
(
TRAIT_NAME
)
String
traitName
)
{
LOG
.
info
(
"Deleting trait={} from entity={} "
,
traitName
,
guid
);
LOG
.
info
(
"Deleting trait={} from entity={} "
,
traitName
,
guid
);
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"EntityResource.deleteTrait("
+
guid
+
", "
+
traitName
+
")"
);
}
metadataService
.
deleteTrait
(
guid
,
traitName
);
metadataService
.
deleteTrait
(
guid
,
traitName
);
JSONObject
response
=
new
JSONObject
();
JSONObject
response
=
new
JSONObject
();
...
@@ -802,8 +728,6 @@ public class EntityResource {
...
@@ -802,8 +728,6 @@ public class EntityResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to delete trait name={} for entity={}"
,
traitName
,
guid
,
e
);
LOG
.
error
(
"Unable to delete trait name={} for entity={}"
,
traitName
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
@@ -817,6 +741,7 @@ public class EntityResource {
...
@@ -817,6 +741,7 @@ public class EntityResource {
* @param count number of events required
* @param count number of events required
* @return
* @return
*/
*/
@Monitored
@GET
@GET
@Path
(
"{guid}/audit"
)
@Path
(
"{guid}/audit"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
...
@@ -824,12 +749,7 @@ public class EntityResource {
...
@@ -824,12 +749,7 @@ public class EntityResource {
@QueryParam
(
"count"
)
@DefaultValue
(
"100"
)
short
count
)
{
@QueryParam
(
"count"
)
@DefaultValue
(
"100"
)
short
count
)
{
LOG
.
debug
(
"Audit events request for entity {}, start key {}, number of results required {}"
,
guid
,
startKey
,
LOG
.
debug
(
"Audit events request for entity {}, start key {}, number of results required {}"
,
guid
,
startKey
,
count
);
count
);
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"EntityResource.getAuditEvents("
+
guid
+
", "
+
startKey
+
", "
+
count
+
")"
);
}
List
<
EntityAuditEvent
>
events
=
metadataService
.
getAuditEvents
(
guid
,
startKey
,
count
);
List
<
EntityAuditEvent
>
events
=
metadataService
.
getAuditEvents
(
guid
,
startKey
,
count
);
JSONObject
response
=
new
JSONObject
();
JSONObject
response
=
new
JSONObject
();
...
@@ -842,8 +762,6 @@ public class EntityResource {
...
@@ -842,8 +762,6 @@ public class EntityResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get audit events for entity guid={} startKey={}"
,
guid
,
startKey
,
e
);
LOG
.
error
(
"Unable to get audit events for entity guid={} startKey={}"
,
guid
,
startKey
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
...
webapp/src/main/java/org/apache/atlas/web/resources/LineageResource.java
View file @
1fa05264
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
package
org
.
apache
.
atlas
.
web
.
resources
;
package
org
.
apache
.
atlas
.
web
.
resources
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.aspect.Monitored
;
import
org.apache.atlas.discovery.DiscoveryException
;
import
org.apache.atlas.discovery.DiscoveryException
;
import
org.apache.atlas.discovery.LineageService
;
import
org.apache.atlas.discovery.LineageService
;
import
org.apache.atlas.typesystem.exception.EntityNotFoundException
;
import
org.apache.atlas.typesystem.exception.EntityNotFoundException
;
...
@@ -63,6 +64,7 @@ public class LineageResource {
...
@@ -63,6 +64,7 @@ public class LineageResource {
* @param guid dataset entity id
* @param guid dataset entity id
* @return
* @return
*/
*/
@Monitored
@GET
@GET
@Path
(
"{guid}/inputs/graph"
)
@Path
(
"{guid}/inputs/graph"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
...
@@ -70,12 +72,7 @@ public class LineageResource {
...
@@ -70,12 +72,7 @@ public class LineageResource {
public
Response
inputsGraph
(
@PathParam
(
"guid"
)
String
guid
)
{
public
Response
inputsGraph
(
@PathParam
(
"guid"
)
String
guid
)
{
LOG
.
info
(
"Fetching lineage inputs graph for guid={}"
,
guid
);
LOG
.
info
(
"Fetching lineage inputs graph for guid={}"
,
guid
);
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"LineageResource.inputsGraph("
+
guid
+
")"
);
}
final
String
jsonResult
=
lineageService
.
getInputsGraphForEntity
(
guid
);
final
String
jsonResult
=
lineageService
.
getInputsGraphForEntity
(
guid
);
JSONObject
response
=
new
JSONObject
();
JSONObject
response
=
new
JSONObject
();
...
@@ -92,8 +89,6 @@ public class LineageResource {
...
@@ -92,8 +89,6 @@ public class LineageResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get lineage inputs graph for entity guid={}"
,
guid
,
e
);
LOG
.
error
(
"Unable to get lineage inputs graph for entity guid={}"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
@@ -102,6 +97,7 @@ public class LineageResource {
...
@@ -102,6 +97,7 @@ public class LineageResource {
*
*
* @param guid dataset entity id
* @param guid dataset entity id
*/
*/
@Monitored
@GET
@GET
@Path
(
"{guid}/outputs/graph"
)
@Path
(
"{guid}/outputs/graph"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
...
@@ -109,12 +105,7 @@ public class LineageResource {
...
@@ -109,12 +105,7 @@ public class LineageResource {
public
Response
outputsGraph
(
@PathParam
(
"guid"
)
String
guid
)
{
public
Response
outputsGraph
(
@PathParam
(
"guid"
)
String
guid
)
{
LOG
.
info
(
"Fetching lineage outputs graph for entity guid={}"
,
guid
);
LOG
.
info
(
"Fetching lineage outputs graph for entity guid={}"
,
guid
);
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"LineageResource.outputsGraph("
+
guid
+
")"
);
}
final
String
jsonResult
=
lineageService
.
getOutputsGraphForEntity
(
guid
);
final
String
jsonResult
=
lineageService
.
getOutputsGraphForEntity
(
guid
);
JSONObject
response
=
new
JSONObject
();
JSONObject
response
=
new
JSONObject
();
...
@@ -131,8 +122,6 @@ public class LineageResource {
...
@@ -131,8 +122,6 @@ public class LineageResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get lineage outputs graph for entity guid={}"
,
guid
,
e
);
LOG
.
error
(
"Unable to get lineage outputs graph for entity guid={}"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
@@ -141,6 +130,7 @@ public class LineageResource {
...
@@ -141,6 +130,7 @@ public class LineageResource {
*
*
* @param guid dataset entity id
* @param guid dataset entity id
*/
*/
@Monitored
@GET
@GET
@Path
(
"{guid}/schema"
)
@Path
(
"{guid}/schema"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
...
@@ -148,12 +138,7 @@ public class LineageResource {
...
@@ -148,12 +138,7 @@ public class LineageResource {
public
Response
schema
(
@PathParam
(
"guid"
)
String
guid
)
{
public
Response
schema
(
@PathParam
(
"guid"
)
String
guid
)
{
LOG
.
info
(
"Fetching schema for entity guid={}"
,
guid
);
LOG
.
info
(
"Fetching schema for entity guid={}"
,
guid
);
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"LineageResource.schema("
+
guid
+
")"
);
}
final
String
jsonResult
=
lineageService
.
getSchemaForEntity
(
guid
);
final
String
jsonResult
=
lineageService
.
getSchemaForEntity
(
guid
);
JSONObject
response
=
new
JSONObject
();
JSONObject
response
=
new
JSONObject
();
...
@@ -173,8 +158,6 @@ public class LineageResource {
...
@@ -173,8 +158,6 @@ public class LineageResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get schema for entity={}"
,
guid
,
e
);
LOG
.
error
(
"Unable to get schema for entity={}"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
}
}
webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
View file @
1fa05264
...
@@ -21,6 +21,7 @@ package org.apache.atlas.web.resources;
...
@@ -21,6 +21,7 @@ package org.apache.atlas.web.resources;
import
com.google.common.base.Preconditions
;
import
com.google.common.base.Preconditions
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasConfiguration
;
import
org.apache.atlas.AtlasConfiguration
;
import
org.apache.atlas.aspect.Monitored
;
import
org.apache.atlas.classification.InterfaceAudience
;
import
org.apache.atlas.classification.InterfaceAudience
;
import
org.apache.atlas.discovery.DiscoveryException
;
import
org.apache.atlas.discovery.DiscoveryException
;
import
org.apache.atlas.discovery.DiscoveryService
;
import
org.apache.atlas.discovery.DiscoveryService
;
...
@@ -82,6 +83,7 @@ public class MetadataDiscoveryResource {
...
@@ -82,6 +83,7 @@ public class MetadataDiscoveryResource {
* @param offset offset to the results returned, used for pagination. offset >= 0. -1 maps to offset 0
* @param offset offset to the results returned, used for pagination. offset >= 0. -1 maps to offset 0
* @return JSON representing the type and results.
* @return JSON representing the type and results.
*/
*/
@Monitored
@GET
@GET
@Path
(
"search"
)
@Path
(
"search"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
...
@@ -89,11 +91,6 @@ public class MetadataDiscoveryResource {
...
@@ -89,11 +91,6 @@ public class MetadataDiscoveryResource {
public
Response
search
(
@QueryParam
(
"query"
)
String
query
,
public
Response
search
(
@QueryParam
(
"query"
)
String
query
,
@DefaultValue
(
LIMIT_OFFSET_DEFAULT
)
@QueryParam
(
"limit"
)
int
limit
,
@DefaultValue
(
LIMIT_OFFSET_DEFAULT
)
@QueryParam
(
"limit"
)
int
limit
,
@DefaultValue
(
LIMIT_OFFSET_DEFAULT
)
@QueryParam
(
"offset"
)
int
offset
)
{
@DefaultValue
(
LIMIT_OFFSET_DEFAULT
)
@QueryParam
(
"offset"
)
int
offset
)
{
AtlasPerfTracer
perf
=
null
;
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"MetadataDiscoveryResource.search("
+
query
+
", "
+
limit
+
", "
+
offset
+
")"
);
}
boolean
dslQueryFailed
=
false
;
boolean
dslQueryFailed
=
false
;
Response
response
=
null
;
Response
response
=
null
;
try
{
try
{
...
@@ -109,7 +106,6 @@ public class MetadataDiscoveryResource {
...
@@ -109,7 +106,6 @@ public class MetadataDiscoveryResource {
if
(
dslQueryFailed
)
{
if
(
dslQueryFailed
)
{
response
=
searchUsingFullText
(
query
,
limit
,
offset
);
response
=
searchUsingFullText
(
query
,
limit
,
offset
);
}
}
AtlasPerfTracer
.
log
(
perf
);
return
response
;
return
response
;
}
}
...
@@ -125,6 +121,7 @@ public class MetadataDiscoveryResource {
...
@@ -125,6 +121,7 @@ public class MetadataDiscoveryResource {
*
*
* @return JSON representing the type and results.
* @return JSON representing the type and results.
*/
*/
@Monitored
@GET
@GET
@Path
(
"search/dsl"
)
@Path
(
"search/dsl"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
...
@@ -132,12 +129,7 @@ public class MetadataDiscoveryResource {
...
@@ -132,12 +129,7 @@ public class MetadataDiscoveryResource {
public
Response
searchUsingQueryDSL
(
@QueryParam
(
"query"
)
String
dslQuery
,
public
Response
searchUsingQueryDSL
(
@QueryParam
(
"query"
)
String
dslQuery
,
@DefaultValue
(
LIMIT_OFFSET_DEFAULT
)
@QueryParam
(
"limit"
)
int
limit
,
@DefaultValue
(
LIMIT_OFFSET_DEFAULT
)
@QueryParam
(
"limit"
)
int
limit
,
@DefaultValue
(
LIMIT_OFFSET_DEFAULT
)
@QueryParam
(
"offset"
)
int
offset
)
{
@DefaultValue
(
LIMIT_OFFSET_DEFAULT
)
@QueryParam
(
"offset"
)
int
offset
)
{
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"MetadataDiscoveryResource.searchUsingQueryDSL("
+
dslQuery
+
", "
+
limit
+
", "
+
offset
+
")"
);
}
dslQuery
=
ParamChecker
.
notEmpty
(
dslQuery
,
"dslQuery cannot be null"
);
dslQuery
=
ParamChecker
.
notEmpty
(
dslQuery
,
"dslQuery cannot be null"
);
QueryParams
queryParams
=
validateQueryParams
(
limit
,
offset
);
QueryParams
queryParams
=
validateQueryParams
(
limit
,
offset
);
final
String
jsonResultStr
=
discoveryService
.
searchByDSL
(
dslQuery
,
queryParams
);
final
String
jsonResultStr
=
discoveryService
.
searchByDSL
(
dslQuery
,
queryParams
);
...
@@ -151,8 +143,6 @@ public class MetadataDiscoveryResource {
...
@@ -151,8 +143,6 @@ public class MetadataDiscoveryResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get entity list for dslQuery {}"
,
dslQuery
,
e
);
LOG
.
error
(
"Unable to get entity list for dslQuery {}"
,
dslQuery
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
@@ -184,18 +174,14 @@ public class MetadataDiscoveryResource {
...
@@ -184,18 +174,14 @@ public class MetadataDiscoveryResource {
* @param gremlinQuery search query in raw gremlin format.
* @param gremlinQuery search query in raw gremlin format.
* @return JSON representing the type and results.
* @return JSON representing the type and results.
*/
*/
@Monitored
@GET
@GET
@Path
(
"search/gremlin"
)
@Path
(
"search/gremlin"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@InterfaceAudience
.
Private
@InterfaceAudience
.
Private
public
Response
searchUsingGremlinQuery
(
@QueryParam
(
"query"
)
String
gremlinQuery
)
{
public
Response
searchUsingGremlinQuery
(
@QueryParam
(
"query"
)
String
gremlinQuery
)
{
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"MetadataDiscoveryResource.searchUsingGremlinQuery("
+
gremlinQuery
+
")"
);
}
gremlinQuery
=
ParamChecker
.
notEmpty
(
gremlinQuery
,
"gremlinQuery cannot be null or empty"
);
gremlinQuery
=
ParamChecker
.
notEmpty
(
gremlinQuery
,
"gremlinQuery cannot be null or empty"
);
final
List
<
Map
<
String
,
String
>>
results
=
discoveryService
.
searchByGremlin
(
gremlinQuery
);
final
List
<
Map
<
String
,
String
>>
results
=
discoveryService
.
searchByGremlin
(
gremlinQuery
);
...
@@ -218,8 +204,6 @@ public class MetadataDiscoveryResource {
...
@@ -218,8 +204,6 @@ public class MetadataDiscoveryResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get entity list for gremlinQuery {}"
,
gremlinQuery
,
e
);
LOG
.
error
(
"Unable to get entity list for gremlinQuery {}"
,
gremlinQuery
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
@@ -231,6 +215,7 @@ public class MetadataDiscoveryResource {
...
@@ -231,6 +215,7 @@ public class MetadataDiscoveryResource {
* @param offset offset to the results returned, used for pagination. offset >= 0. -1 maps to offset 0
* @param offset offset to the results returned, used for pagination. offset >= 0. -1 maps to offset 0
* @return JSON representing the type and results.
* @return JSON representing the type and results.
*/
*/
@Monitored
@GET
@GET
@Path
(
"search/fulltext"
)
@Path
(
"search/fulltext"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
...
@@ -238,12 +223,7 @@ public class MetadataDiscoveryResource {
...
@@ -238,12 +223,7 @@ public class MetadataDiscoveryResource {
public
Response
searchUsingFullText
(
@QueryParam
(
"query"
)
String
query
,
public
Response
searchUsingFullText
(
@QueryParam
(
"query"
)
String
query
,
@DefaultValue
(
LIMIT_OFFSET_DEFAULT
)
@QueryParam
(
"limit"
)
int
limit
,
@DefaultValue
(
LIMIT_OFFSET_DEFAULT
)
@QueryParam
(
"limit"
)
int
limit
,
@DefaultValue
(
LIMIT_OFFSET_DEFAULT
)
@QueryParam
(
"offset"
)
int
offset
)
{
@DefaultValue
(
LIMIT_OFFSET_DEFAULT
)
@QueryParam
(
"offset"
)
int
offset
)
{
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"MetadataDiscoveryResource.searchUsingFullText("
+
query
+
", "
+
limit
+
", "
+
offset
+
")"
);
}
query
=
ParamChecker
.
notEmpty
(
query
,
"query cannot be null or empty"
);
query
=
ParamChecker
.
notEmpty
(
query
,
"query cannot be null or empty"
);
QueryParams
queryParams
=
validateQueryParams
(
limit
,
offset
);
QueryParams
queryParams
=
validateQueryParams
(
limit
,
offset
);
final
String
jsonResultStr
=
discoveryService
.
searchByFullText
(
query
,
queryParams
);
final
String
jsonResultStr
=
discoveryService
.
searchByFullText
(
query
,
queryParams
);
...
@@ -257,8 +237,6 @@ public class MetadataDiscoveryResource {
...
@@ -257,8 +237,6 @@ public class MetadataDiscoveryResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get entity list for query {}"
,
query
,
e
);
LOG
.
error
(
"Unable to get entity list for query {}"
,
query
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
...
webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java
View file @
1fa05264
...
@@ -20,10 +20,9 @@ package org.apache.atlas.web.resources;
...
@@ -20,10 +20,9 @@ package org.apache.atlas.web.resources;
import
com.sun.jersey.api.client.ClientResponse
;
import
com.sun.jersey.api.client.ClientResponse
;
import
com.sun.jersey.api.core.ResourceContext
;
import
com.sun.jersey.api.core.ResourceContext
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.aspect.Monitored
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.TypeCategory
;
import
org.apache.atlas.model.TypeCategory
;
import
org.apache.atlas.model.typedef.AtlasClassificationDef
;
import
org.apache.atlas.model.typedef.AtlasClassificationDef
;
...
@@ -89,19 +88,15 @@ public class TypesResource {
...
@@ -89,19 +88,15 @@ public class TypesResource {
* Submits a type definition corresponding to a given type representing a meta model of a
* Submits a type definition corresponding to a given type representing a meta model of a
* domain. Could represent things like Hive Database, Hive Table, etc.
* domain. Could represent things like Hive Database, Hive Table, etc.
*/
*/
@Monitored
@POST
@POST
@Consumes
({
Servlets
.
JSON_MEDIA_TYPE
,
MediaType
.
APPLICATION_JSON
})
@Consumes
({
Servlets
.
JSON_MEDIA_TYPE
,
MediaType
.
APPLICATION_JSON
})
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
submit
(
@Context
HttpServletRequest
request
)
{
public
Response
submit
(
@Context
HttpServletRequest
request
)
{
TypesREST
typesRest
=
resourceContext
.
getResource
(
TypesREST
.
class
);
TypesREST
typesRest
=
resourceContext
.
getResource
(
TypesREST
.
class
);
AtlasPerfTracer
perf
=
null
;
JSONArray
typesResponse
=
new
JSONArray
();
JSONArray
typesResponse
=
new
JSONArray
();
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"TypesResource.submit()"
);
}
final
String
typeDefinition
=
Servlets
.
getRequestPayload
(
request
);
final
String
typeDefinition
=
Servlets
.
getRequestPayload
(
request
);
LOG
.
info
(
"Creating type with definition {} "
,
typeDefinition
);
LOG
.
info
(
"Creating type with definition {} "
,
typeDefinition
);
...
@@ -129,8 +124,6 @@ public class TypesResource {
...
@@ -129,8 +124,6 @@ public class TypesResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to persist types"
,
e
);
LOG
.
error
(
"Unable to persist types"
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
@@ -143,18 +136,14 @@ public class TypesResource {
...
@@ -143,18 +136,14 @@ public class TypesResource {
* @param request
* @param request
* @return
* @return
*/
*/
@Monitored
@PUT
@PUT
@Consumes
({
Servlets
.
JSON_MEDIA_TYPE
,
MediaType
.
APPLICATION_JSON
})
@Consumes
({
Servlets
.
JSON_MEDIA_TYPE
,
MediaType
.
APPLICATION_JSON
})
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
update
(
@Context
HttpServletRequest
request
)
{
public
Response
update
(
@Context
HttpServletRequest
request
)
{
TypesREST
typesRest
=
resourceContext
.
getResource
(
TypesREST
.
class
);
TypesREST
typesRest
=
resourceContext
.
getResource
(
TypesREST
.
class
);
AtlasPerfTracer
perf
=
null
;
JSONArray
typesResponse
=
new
JSONArray
();
JSONArray
typesResponse
=
new
JSONArray
();
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"TypesResource.update()"
);
}
final
String
typeDefinition
=
Servlets
.
getRequestPayload
(
request
);
final
String
typeDefinition
=
Servlets
.
getRequestPayload
(
request
);
LOG
.
info
(
"Updating type with definition {} "
,
typeDefinition
);
LOG
.
info
(
"Updating type with definition {} "
,
typeDefinition
);
...
@@ -182,8 +171,6 @@ public class TypesResource {
...
@@ -182,8 +171,6 @@ public class TypesResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to persist types"
,
e
);
LOG
.
error
(
"Unable to persist types"
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
@@ -192,19 +179,15 @@ public class TypesResource {
...
@@ -192,19 +179,15 @@ public class TypesResource {
*
*
* @param typeName name of a type which is unique.
* @param typeName name of a type which is unique.
*/
*/
@Monitored
@GET
@GET
@Path
(
"{typeName}"
)
@Path
(
"{typeName}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
getDefinition
(
@Context
HttpServletRequest
request
,
@PathParam
(
"typeName"
)
String
typeName
)
{
public
Response
getDefinition
(
@Context
HttpServletRequest
request
,
@PathParam
(
"typeName"
)
String
typeName
)
{
TypesREST
typesRest
=
resourceContext
.
getResource
(
TypesREST
.
class
);
TypesREST
typesRest
=
resourceContext
.
getResource
(
TypesREST
.
class
);
JSONObject
response
=
new
JSONObject
();
JSONObject
response
=
new
JSONObject
();
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"TypesResource.getDefinition("
+
typeName
+
")"
);
}
TypeCategory
typeCategory
=
typeRegistry
.
getType
(
typeName
).
getTypeCategory
();
TypeCategory
typeCategory
=
typeRegistry
.
getType
(
typeName
).
getTypeCategory
();
TypesDef
typesDef
=
null
;
TypesDef
typesDef
=
null
;
...
@@ -247,8 +230,6 @@ public class TypesResource {
...
@@ -247,8 +230,6 @@ public class TypesResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get type definition for type {}"
,
typeName
,
e
);
LOG
.
error
(
"Unable to get type definition for type {}"
,
typeName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
@@ -264,6 +245,7 @@ public class TypesResource {
...
@@ -264,6 +245,7 @@ public class TypesResource {
* For example, typeCategory = TRAIT && supertype contains 'X' && supertype !contains 'Y'
* For example, typeCategory = TRAIT && supertype contains 'X' && supertype !contains 'Y'
* If there is no filter, all the types are returned
* If there is no filter, all the types are returned
*/
*/
@Monitored
@GET
@GET
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
getTypesByFilter
(
@Context
HttpServletRequest
request
,
@QueryParam
(
"type"
)
String
typeCategory
,
public
Response
getTypesByFilter
(
@Context
HttpServletRequest
request
,
@QueryParam
(
"type"
)
String
typeCategory
,
...
@@ -271,12 +253,7 @@ public class TypesResource {
...
@@ -271,12 +253,7 @@ public class TypesResource {
@QueryParam
(
"notsupertype"
)
String
notsupertype
)
throws
AtlasBaseException
{
@QueryParam
(
"notsupertype"
)
String
notsupertype
)
throws
AtlasBaseException
{
TypesREST
typesRest
=
resourceContext
.
getResource
(
TypesREST
.
class
);
TypesREST
typesRest
=
resourceContext
.
getResource
(
TypesREST
.
class
);
JSONObject
response
=
new
JSONObject
();
JSONObject
response
=
new
JSONObject
();
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"TypesResource.getTypesByFilter("
+
typeCategory
+
")"
);
}
List
<
String
>
result
=
RestUtils
.
getTypeNames
(
typesRest
.
getTypeDefHeaders
());
List
<
String
>
result
=
RestUtils
.
getTypeNames
(
typesRest
.
getTypeDefHeaders
());
response
.
put
(
AtlasClient
.
RESULTS
,
new
JSONArray
(
result
));
response
.
put
(
AtlasClient
.
RESULTS
,
new
JSONArray
(
result
));
...
@@ -291,8 +268,6 @@ public class TypesResource {
...
@@ -291,8 +268,6 @@ public class TypesResource {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get types list"
,
e
);
LOG
.
error
(
"Unable to get types list"
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
}
}
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