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
bff013f0
Commit
bff013f0
authored
9 years ago
by
Madhan Neethiraj
Committed by
Suma Shivaprasad
9 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1030: performance trace instrumentation for REST APIs
parent
e895819f
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
320 additions
and
1 deletion
+320
-1
AtlasPerfTracer.java
...src/main/java/org/apache/atlas/utils/AtlasPerfTracer.java
+80
-0
atlas-log4j.xml
distro/src/conf/atlas-log4j.xml
+16
-0
atlas-log4j.xml
typesystem/src/main/resources/atlas-log4j.xml
+16
-0
AdminResource.java
...in/java/org/apache/atlas/web/resources/AdminResource.java
+40
-0
DataSetLineageResource.java
...rg/apache/atlas/web/resources/DataSetLineageResource.java
+23
-0
EntityResource.java
...n/java/org/apache/atlas/web/resources/EntityResource.java
+0
-0
EntityService.java
...in/java/org/apache/atlas/web/resources/EntityService.java
+62
-1
LineageResource.java
.../java/org/apache/atlas/web/resources/LineageResource.java
+23
-0
MetadataDiscoveryResource.java
...apache/atlas/web/resources/MetadataDiscoveryResource.java
+30
-0
TaxonomyService.java
.../java/org/apache/atlas/web/resources/TaxonomyService.java
+0
-0
TypesResource.java
...in/java/org/apache/atlas/web/resources/TypesResource.java
+30
-0
No files found.
common/src/main/java/org/apache/atlas/utils/AtlasPerfTracer.java
0 → 100644
View file @
bff013f0
/**
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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
.
utils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* Handles logging of performance measurements.
*/
public
final
class
AtlasPerfTracer
{
protected
final
Logger
logger
;
protected
final
String
tag
;
private
final
long
startTimeMs
;
private
static
long
reportingThresholdMs
=
0L
;
public
static
Logger
getPerfLogger
(
String
name
)
{
return
LoggerFactory
.
getLogger
(
"org.apache.atlas.perf."
+
name
);
}
public
static
Logger
getPerfLogger
(
Class
<?>
cls
)
{
return
AtlasPerfTracer
.
getPerfLogger
(
cls
.
getName
());
}
public
static
boolean
isPerfTraceEnabled
(
Logger
logger
)
{
return
logger
.
isDebugEnabled
();
}
public
static
AtlasPerfTracer
getPerfTracer
(
Logger
logger
,
String
tag
)
{
return
new
AtlasPerfTracer
(
logger
,
tag
);
}
public
static
void
log
(
AtlasPerfTracer
tracer
)
{
if
(
tracer
!=
null
)
{
tracer
.
log
();
}
}
private
AtlasPerfTracer
(
Logger
logger
,
String
tag
)
{
this
.
logger
=
logger
;
this
.
tag
=
tag
;
startTimeMs
=
System
.
currentTimeMillis
();
}
public
String
getTag
()
{
return
tag
;
}
public
long
getStartTime
()
{
return
startTimeMs
;
}
public
long
getElapsedTime
()
{
return
System
.
currentTimeMillis
()
-
startTimeMs
;
}
public
void
log
()
{
long
elapsedTime
=
getElapsedTime
();
if
(
elapsedTime
>
reportingThresholdMs
)
{
logger
.
debug
(
"PERF|"
+
tag
+
"|"
+
elapsedTime
);
}
}
}
This diff is collapsed.
Click to expand it.
distro/src/conf/atlas-log4j.xml
View file @
bff013f0
...
@@ -48,6 +48,22 @@
...
@@ -48,6 +48,22 @@
<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"
/>
...
...
This diff is collapsed.
Click to expand it.
typesystem/src/main/resources/atlas-log4j.xml
View file @
bff013f0
...
@@ -41,6 +41,22 @@
...
@@ -41,6 +41,22 @@
<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>
-->
<logger
name=
"com.thinkaurelius.titan"
additivity=
"false"
>
<logger
name=
"com.thinkaurelius.titan"
additivity=
"false"
>
<level
value=
"info"
/>
<level
value=
"info"
/>
<appender-ref
ref=
"console"
/>
<appender-ref
ref=
"console"
/>
...
...
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
View file @
bff013f0
...
@@ -31,6 +31,7 @@ import javax.ws.rs.core.MediaType;
...
@@ -31,6 +31,7 @@ import javax.ws.rs.core.MediaType;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasClient
;
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
;
import
org.apache.atlas.web.util.Servlets
;
import
org.apache.atlas.web.util.Servlets
;
...
@@ -39,6 +40,7 @@ import org.apache.commons.configuration.PropertiesConfiguration;
...
@@ -39,6 +40,7 @@ import org.apache.commons.configuration.PropertiesConfiguration;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.codehaus.jettison.json.JSONException
;
import
org.codehaus.jettison.json.JSONException
;
import
org.codehaus.jettison.json.JSONObject
;
import
org.codehaus.jettison.json.JSONObject
;
import
org.slf4j.Logger
;
import
org.springframework.security.core.Authentication
;
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
;
...
@@ -51,6 +53,7 @@ import com.google.inject.Inject;
...
@@ -51,6 +53,7 @@ import com.google.inject.Inject;
@Path
(
"admin"
)
@Path
(
"admin"
)
@Singleton
@Singleton
public
class
AdminResource
{
public
class
AdminResource
{
private
static
final
Logger
PERF_LOG
=
AtlasPerfTracer
.
getPerfLogger
(
"rest.AdminResource"
);
private
static
final
String
isCSRF_ENABLED
=
"atlas.rest-csrf.enabled"
;
private
static
final
String
isCSRF_ENABLED
=
"atlas.rest-csrf.enabled"
;
private
static
final
String
BROWSER_USER_AGENT_PARAM
=
"atlas.rest-csrf.browser-useragents-regex"
;
private
static
final
String
BROWSER_USER_AGENT_PARAM
=
"atlas.rest-csrf.browser-useragents-regex"
;
...
@@ -75,6 +78,13 @@ public class AdminResource {
...
@@ -75,6 +78,13 @@ public class AdminResource {
@Path
(
"stack"
)
@Path
(
"stack"
)
@Produces
(
MediaType
.
TEXT_PLAIN
)
@Produces
(
MediaType
.
TEXT_PLAIN
)
public
String
getThreadDump
()
{
public
String
getThreadDump
()
{
AtlasPerfTracer
perf
=
null
;
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"AdminResource.getThreadDump()"
);
}
ThreadGroup
topThreadGroup
=
Thread
.
currentThread
().
getThreadGroup
();
ThreadGroup
topThreadGroup
=
Thread
.
currentThread
().
getThreadGroup
();
while
(
topThreadGroup
.
getParent
()
!=
null
)
{
while
(
topThreadGroup
.
getParent
()
!=
null
)
{
...
@@ -91,6 +101,9 @@ public class AdminResource {
...
@@ -91,6 +101,9 @@ public class AdminResource {
builder
.
append
(
stackTrace
);
builder
.
append
(
stackTrace
);
}
}
return
builder
.
toString
();
return
builder
.
toString
();
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
/**
/**
...
@@ -102,6 +115,13 @@ public class AdminResource {
...
@@ -102,6 +115,13 @@ public class AdminResource {
@Path
(
"version"
)
@Path
(
"version"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
getVersion
()
{
public
Response
getVersion
()
{
AtlasPerfTracer
perf
=
null
;
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"AdminResource.getVersion()"
);
}
if
(
version
==
null
)
{
if
(
version
==
null
)
{
try
{
try
{
PropertiesConfiguration
configProperties
=
new
PropertiesConfiguration
(
"atlas-buildinfo.properties"
);
PropertiesConfiguration
configProperties
=
new
PropertiesConfiguration
(
"atlas-buildinfo.properties"
);
...
@@ -121,12 +141,22 @@ public class AdminResource {
...
@@ -121,12 +141,22 @@ public class AdminResource {
}
}
return
version
;
return
version
;
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
@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
;
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"AdminResource.getStatus()"
);
}
JSONObject
responseData
=
new
JSONObject
();
JSONObject
responseData
=
new
JSONObject
();
try
{
try
{
responseData
.
put
(
AtlasClient
.
STATUS
,
serviceState
.
getState
().
toString
());
responseData
.
put
(
AtlasClient
.
STATUS
,
serviceState
.
getState
().
toString
());
...
@@ -135,6 +165,9 @@ public class AdminResource {
...
@@ -135,6 +165,9 @@ public class AdminResource {
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
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
);
}
}
}
@GET
@GET
...
@@ -143,7 +176,12 @@ public class AdminResource {
...
@@ -143,7 +176,12 @@ public class AdminResource {
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
();
...
@@ -170,6 +208,8 @@ public class AdminResource {
...
@@ -170,6 +208,8 @@ 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
);
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/resources/DataSetLineageResource.java
View file @
bff013f0
...
@@ -22,6 +22,7 @@ import org.apache.atlas.AtlasClient;
...
@@ -22,6 +22,7 @@ import org.apache.atlas.AtlasClient;
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
;
import
org.apache.atlas.utils.AtlasPerfTracer
;
import
org.apache.atlas.web.util.Servlets
;
import
org.apache.atlas.web.util.Servlets
;
import
org.codehaus.jettison.json.JSONObject
;
import
org.codehaus.jettison.json.JSONObject
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -47,6 +48,7 @@ import javax.ws.rs.core.Response;
...
@@ -47,6 +48,7 @@ import javax.ws.rs.core.Response;
public
class
DataSetLineageResource
{
public
class
DataSetLineageResource
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
DataSetLineageResource
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
DataSetLineageResource
.
class
);
private
static
final
Logger
PERF_LOG
=
AtlasPerfTracer
.
getPerfLogger
(
"rest.DataSetLineageResource"
);
private
final
LineageService
lineageService
;
private
final
LineageService
lineageService
;
...
@@ -73,7 +75,12 @@ public class DataSetLineageResource {
...
@@ -73,7 +75,12 @@ 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
();
...
@@ -91,6 +98,8 @@ public class DataSetLineageResource {
...
@@ -91,6 +98,8 @@ 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
);
}
}
}
}
...
@@ -106,7 +115,12 @@ public class DataSetLineageResource {
...
@@ -106,7 +115,12 @@ 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
();
...
@@ -124,6 +138,8 @@ public class DataSetLineageResource {
...
@@ -124,6 +138,8 @@ 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
);
}
}
}
}
...
@@ -139,7 +155,12 @@ public class DataSetLineageResource {
...
@@ -139,7 +155,12 @@ 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
();
...
@@ -157,6 +178,8 @@ public class DataSetLineageResource {
...
@@ -157,6 +178,8 @@ 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
);
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java
View file @
bff013f0
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/resources/EntityService.java
View file @
bff013f0
...
@@ -22,7 +22,9 @@ import org.apache.atlas.AtlasException;
...
@@ -22,7 +22,9 @@ import org.apache.atlas.AtlasException;
import
org.apache.atlas.catalog.*
;
import
org.apache.atlas.catalog.*
;
import
org.apache.atlas.catalog.exception.CatalogException
;
import
org.apache.atlas.catalog.exception.CatalogException
;
import
org.apache.atlas.services.MetadataService
;
import
org.apache.atlas.services.MetadataService
;
import
org.apache.atlas.utils.AtlasPerfTracer
;
import
org.apache.atlas.web.util.Servlets
;
import
org.apache.atlas.web.util.Servlets
;
import
org.slf4j.Logger
;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
javax.inject.Singleton
;
import
javax.inject.Singleton
;
...
@@ -36,6 +38,7 @@ import java.util.*;
...
@@ -36,6 +38,7 @@ import java.util.*;
@Path
(
"v1/entities"
)
@Path
(
"v1/entities"
)
@Singleton
@Singleton
public
class
EntityService
extends
BaseService
{
public
class
EntityService
extends
BaseService
{
private
static
final
Logger
PERF_LOG
=
AtlasPerfTracer
.
getPerfLogger
(
"rest.EntityService"
);
private
final
EntityResourceProvider
entityResourceProvider
;
private
final
EntityResourceProvider
entityResourceProvider
;
private
final
EntityTagResourceProvider
entityTagResourceProvider
;
private
final
EntityTagResourceProvider
entityTagResourceProvider
;
...
@@ -50,12 +53,21 @@ public class EntityService extends BaseService {
...
@@ -50,12 +53,21 @@ public class EntityService extends BaseService {
@GET
@GET
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
getEntities
(
@Context
HttpHeaders
headers
,
@Context
UriInfo
ui
)
throws
CatalogException
{
public
Response
getEntities
(
@Context
HttpHeaders
headers
,
@Context
UriInfo
ui
)
throws
CatalogException
{
AtlasPerfTracer
perf
=
null
;
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"EntityService.getEntities()"
);
}
String
queryString
=
decode
(
getQueryString
(
ui
));
String
queryString
=
decode
(
getQueryString
(
ui
));
BaseRequest
request
=
new
CollectionRequest
(
Collections
.<
String
,
Object
>
emptyMap
(),
queryString
);
BaseRequest
request
=
new
CollectionRequest
(
Collections
.<
String
,
Object
>
emptyMap
(),
queryString
);
Result
result
=
getResources
(
entityResourceProvider
,
request
);
Result
result
=
getResources
(
entityResourceProvider
,
request
);
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
getSerializer
().
serialize
(
result
,
ui
)).
build
();
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
getSerializer
().
serialize
(
result
,
ui
)).
build
();
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
@GET
@GET
...
@@ -64,11 +76,19 @@ public class EntityService extends BaseService {
...
@@ -64,11 +76,19 @@ public class EntityService extends BaseService {
public
Response
getEntity
(
@Context
HttpHeaders
headers
,
public
Response
getEntity
(
@Context
HttpHeaders
headers
,
@Context
UriInfo
ui
,
@Context
UriInfo
ui
,
@PathParam
(
"entityId"
)
String
entityId
)
throws
CatalogException
{
@PathParam
(
"entityId"
)
String
entityId
)
throws
CatalogException
{
AtlasPerfTracer
perf
=
null
;
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"EntityService.getEntity("
+
entityId
+
")"
);
}
BaseRequest
request
=
new
InstanceRequest
(
Collections
.<
String
,
Object
>
singletonMap
(
"id"
,
entityId
));
BaseRequest
request
=
new
InstanceRequest
(
Collections
.<
String
,
Object
>
singletonMap
(
"id"
,
entityId
));
Result
result
=
getResource
(
entityResourceProvider
,
request
);
Result
result
=
getResource
(
entityResourceProvider
,
request
);
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
getSerializer
().
serialize
(
result
,
ui
)).
build
();
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
getSerializer
().
serialize
(
result
,
ui
)).
build
();
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
@GET
@GET
...
@@ -78,6 +98,11 @@ public class EntityService extends BaseService {
...
@@ -78,6 +98,11 @@ public class EntityService extends BaseService {
@Context
UriInfo
ui
,
@Context
UriInfo
ui
,
@PathParam
(
"entityId"
)
String
entityId
,
@PathParam
(
"entityId"
)
String
entityId
,
@PathParam
(
"tag"
)
String
tagName
)
throws
CatalogException
{
@PathParam
(
"tag"
)
String
tagName
)
throws
CatalogException
{
AtlasPerfTracer
perf
=
null
;
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"EntityService.getEntityTag("
+
entityId
+
", "
+
tagName
+
")"
);
}
Map
<
String
,
Object
>
properties
=
new
HashMap
<>();
Map
<
String
,
Object
>
properties
=
new
HashMap
<>();
properties
.
put
(
"id"
,
entityId
);
properties
.
put
(
"id"
,
entityId
);
...
@@ -85,6 +110,9 @@ public class EntityService extends BaseService {
...
@@ -85,6 +110,9 @@ public class EntityService extends BaseService {
Result
result
=
getResource
(
entityTagResourceProvider
,
new
InstanceRequest
(
properties
));
Result
result
=
getResource
(
entityTagResourceProvider
,
new
InstanceRequest
(
properties
));
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
getSerializer
().
serialize
(
result
,
ui
)).
build
();
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
getSerializer
().
serialize
(
result
,
ui
)).
build
();
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
@GET
@GET
...
@@ -93,12 +121,20 @@ public class EntityService extends BaseService {
...
@@ -93,12 +121,20 @@ public class EntityService extends BaseService {
public
Response
getEntityTags
(
@Context
HttpHeaders
headers
,
public
Response
getEntityTags
(
@Context
HttpHeaders
headers
,
@Context
UriInfo
ui
,
@Context
UriInfo
ui
,
@PathParam
(
"entityId"
)
String
entityGuid
)
throws
CatalogException
{
@PathParam
(
"entityId"
)
String
entityGuid
)
throws
CatalogException
{
AtlasPerfTracer
perf
=
null
;
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"EntityService.getEntityTags("
+
entityGuid
+
")"
);
}
BaseRequest
request
=
new
CollectionRequest
(
Collections
.<
String
,
Object
>
singletonMap
(
"id"
,
entityGuid
),
BaseRequest
request
=
new
CollectionRequest
(
Collections
.<
String
,
Object
>
singletonMap
(
"id"
,
entityGuid
),
decode
(
getQueryString
(
ui
)));
decode
(
getQueryString
(
ui
)));
Result
result
=
getResources
(
entityTagResourceProvider
,
request
);
Result
result
=
getResources
(
entityTagResourceProvider
,
request
);
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
getSerializer
().
serialize
(
result
,
ui
)).
build
();
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
getSerializer
().
serialize
(
result
,
ui
)).
build
();
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
@POST
@POST
...
@@ -109,6 +145,11 @@ public class EntityService extends BaseService {
...
@@ -109,6 +145,11 @@ public class EntityService extends BaseService {
@Context
UriInfo
ui
,
@Context
UriInfo
ui
,
@PathParam
(
"entityId"
)
String
entityId
,
@PathParam
(
"entityId"
)
String
entityId
,
@PathParam
(
"tag"
)
String
tagName
)
throws
CatalogException
{
@PathParam
(
"tag"
)
String
tagName
)
throws
CatalogException
{
AtlasPerfTracer
perf
=
null
;
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"EntityService.tagEntity("
+
entityId
+
", "
+
tagName
+
")"
);
}
Map
<
String
,
Object
>
properties
=
new
HashMap
<>();
Map
<
String
,
Object
>
properties
=
new
HashMap
<>();
properties
.
put
(
"id"
,
entityId
);
properties
.
put
(
"id"
,
entityId
);
...
@@ -117,6 +158,9 @@ public class EntityService extends BaseService {
...
@@ -117,6 +158,9 @@ public class EntityService extends BaseService {
return
Response
.
status
(
Response
.
Status
.
CREATED
).
entity
(
return
Response
.
status
(
Response
.
Status
.
CREATED
).
entity
(
new
Results
(
ui
.
getRequestUri
().
toString
(),
201
)).
build
();
new
Results
(
ui
.
getRequestUri
().
toString
(),
201
)).
build
();
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
@POST
@POST
...
@@ -124,6 +168,11 @@ public class EntityService extends BaseService {
...
@@ -124,6 +168,11 @@ public class EntityService extends BaseService {
public
Response
tagEntities
(
String
body
,
public
Response
tagEntities
(
String
body
,
@Context
HttpHeaders
headers
,
@Context
HttpHeaders
headers
,
@Context
UriInfo
ui
)
throws
CatalogException
{
@Context
UriInfo
ui
)
throws
CatalogException
{
AtlasPerfTracer
perf
=
null
;
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"EntityService.tagEntities()"
);
}
Map
<
String
,
Object
>
properties
=
parsePayload
(
body
);
Map
<
String
,
Object
>
properties
=
parsePayload
(
body
);
...
@@ -142,7 +191,11 @@ public class EntityService extends BaseService {
...
@@ -142,7 +191,11 @@ public class EntityService extends BaseService {
}
}
return
Response
.
status
(
Response
.
Status
.
CREATED
).
entity
(
return
Response
.
status
(
Response
.
Status
.
CREATED
).
entity
(
new
GenericEntity
<
Collection
<
Results
>>(
result
)
{}).
build
();
new
GenericEntity
<
Collection
<
Results
>>(
result
)
{
}).
build
();
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
@DELETE
@DELETE
...
@@ -152,6 +205,11 @@ public class EntityService extends BaseService {
...
@@ -152,6 +205,11 @@ public class EntityService extends BaseService {
@Context
UriInfo
ui
,
@Context
UriInfo
ui
,
@PathParam
(
"entityId"
)
String
entityId
,
@PathParam
(
"entityId"
)
String
entityId
,
@PathParam
(
"tag"
)
String
tagName
)
throws
CatalogException
{
@PathParam
(
"tag"
)
String
tagName
)
throws
CatalogException
{
AtlasPerfTracer
perf
=
null
;
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"EntityService.deleteEntityTag()"
);
}
Map
<
String
,
Object
>
properties
=
new
HashMap
<>();
Map
<
String
,
Object
>
properties
=
new
HashMap
<>();
properties
.
put
(
"id"
,
entityId
);
properties
.
put
(
"id"
,
entityId
);
...
@@ -160,5 +218,8 @@ public class EntityService extends BaseService {
...
@@ -160,5 +218,8 @@ public class EntityService extends BaseService {
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
new
Results
(
ui
.
getRequestUri
().
toString
(),
200
)).
build
();
new
Results
(
ui
.
getRequestUri
().
toString
(),
200
)).
build
();
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
}
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/resources/LineageResource.java
View file @
bff013f0
...
@@ -22,6 +22,7 @@ import org.apache.atlas.AtlasClient;
...
@@ -22,6 +22,7 @@ import org.apache.atlas.AtlasClient;
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
;
import
org.apache.atlas.utils.AtlasPerfTracer
;
import
org.apache.atlas.web.util.Servlets
;
import
org.apache.atlas.web.util.Servlets
;
import
org.codehaus.jettison.json.JSONObject
;
import
org.codehaus.jettison.json.JSONObject
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -41,6 +42,7 @@ import javax.ws.rs.core.Response;
...
@@ -41,6 +42,7 @@ import javax.ws.rs.core.Response;
@Singleton
@Singleton
public
class
LineageResource
{
public
class
LineageResource
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
DataSetLineageResource
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
DataSetLineageResource
.
class
);
private
static
final
Logger
PERF_LOG
=
AtlasPerfTracer
.
getPerfLogger
(
"rest.LineageResource"
);
private
final
LineageService
lineageService
;
private
final
LineageService
lineageService
;
...
@@ -67,7 +69,12 @@ public class LineageResource {
...
@@ -67,7 +69,12 @@ 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
();
...
@@ -84,6 +91,8 @@ public class LineageResource {
...
@@ -84,6 +91,8 @@ 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
);
}
}
}
}
...
@@ -99,7 +108,12 @@ public class LineageResource {
...
@@ -99,7 +108,12 @@ 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
();
...
@@ -116,6 +130,8 @@ public class LineageResource {
...
@@ -116,6 +130,8 @@ 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
);
}
}
}
}
...
@@ -131,7 +147,12 @@ public class LineageResource {
...
@@ -131,7 +147,12 @@ 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
();
...
@@ -148,6 +169,8 @@ public class LineageResource {
...
@@ -148,6 +169,8 @@ 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
);
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
View file @
bff013f0
...
@@ -20,6 +20,7 @@ package org.apache.atlas.web.resources;
...
@@ -20,6 +20,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.utils.AtlasPerfTracer
;
import
org.apache.atlas.utils.ParamChecker
;
import
org.apache.atlas.utils.ParamChecker
;
import
org.apache.atlas.discovery.DiscoveryException
;
import
org.apache.atlas.discovery.DiscoveryException
;
import
org.apache.atlas.discovery.DiscoveryService
;
import
org.apache.atlas.discovery.DiscoveryService
;
...
@@ -51,6 +52,7 @@ import org.apache.hadoop.classification.InterfaceAudience;
...
@@ -51,6 +52,7 @@ import org.apache.hadoop.classification.InterfaceAudience;
public
class
MetadataDiscoveryResource
{
public
class
MetadataDiscoveryResource
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MetadataDiscoveryResource
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MetadataDiscoveryResource
.
class
);
private
static
final
Logger
PERF_LOG
=
AtlasPerfTracer
.
getPerfLogger
(
"rest.MetadataDiscoveryResource"
);
private
static
final
String
QUERY_TYPE_DSL
=
"dsl"
;
private
static
final
String
QUERY_TYPE_DSL
=
"dsl"
;
private
static
final
String
QUERY_TYPE_GREMLIN
=
"gremlin"
;
private
static
final
String
QUERY_TYPE_GREMLIN
=
"gremlin"
;
private
static
final
String
QUERY_TYPE_FULLTEXT
=
"full-text"
;
private
static
final
String
QUERY_TYPE_FULLTEXT
=
"full-text"
;
...
@@ -80,7 +82,12 @@ public class MetadataDiscoveryResource {
...
@@ -80,7 +82,12 @@ public class MetadataDiscoveryResource {
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
search
(
@QueryParam
(
"query"
)
String
query
)
{
public
Response
search
(
@QueryParam
(
"query"
)
String
query
)
{
JSONObject
response
;
JSONObject
response
;
AtlasPerfTracer
perf
=
null
;
try
{
// fall back to dsl
try
{
// fall back to dsl
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"MetadataDiscoveryResource.search("
+
query
+
")"
);
}
ParamChecker
.
notEmpty
(
query
,
"query cannot be null"
);
ParamChecker
.
notEmpty
(
query
,
"query cannot be null"
);
final
String
jsonResultStr
=
discoveryService
.
searchByDSL
(
query
);
final
String
jsonResultStr
=
discoveryService
.
searchByDSL
(
query
);
...
@@ -94,6 +101,8 @@ public class MetadataDiscoveryResource {
...
@@ -94,6 +101,8 @@ public class MetadataDiscoveryResource {
}
catch
(
Throwable
throwable
)
{
}
catch
(
Throwable
throwable
)
{
LOG
.
error
(
"Unable to get entity list for query {} using dsl"
,
query
,
throwable
);
LOG
.
error
(
"Unable to get entity list for query {} using dsl"
,
query
,
throwable
);
return
searchUsingFullText
(
query
);
return
searchUsingFullText
(
query
);
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
}
}
...
@@ -108,7 +117,12 @@ public class MetadataDiscoveryResource {
...
@@ -108,7 +117,12 @@ public class MetadataDiscoveryResource {
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
searchUsingQueryDSL
(
@QueryParam
(
"query"
)
String
dslQuery
)
{
public
Response
searchUsingQueryDSL
(
@QueryParam
(
"query"
)
String
dslQuery
)
{
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"MetadataDiscoveryResource.searchUsingQueryDSL("
+
dslQuery
+
")"
);
}
ParamChecker
.
notEmpty
(
dslQuery
,
"dslQuery cannot be null"
);
ParamChecker
.
notEmpty
(
dslQuery
,
"dslQuery cannot be null"
);
final
String
jsonResultStr
=
discoveryService
.
searchByDSL
(
dslQuery
);
final
String
jsonResultStr
=
discoveryService
.
searchByDSL
(
dslQuery
);
...
@@ -121,6 +135,8 @@ public class MetadataDiscoveryResource {
...
@@ -121,6 +135,8 @@ 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
);
}
}
}
}
...
@@ -136,7 +152,12 @@ public class MetadataDiscoveryResource {
...
@@ -136,7 +152,12 @@ public class MetadataDiscoveryResource {
@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
+
")"
);
}
ParamChecker
.
notEmpty
(
gremlinQuery
,
"gremlinQuery cannot be null or empty"
);
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
);
...
@@ -159,6 +180,8 @@ public class MetadataDiscoveryResource {
...
@@ -159,6 +180,8 @@ 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
);
}
}
}
}
...
@@ -173,7 +196,12 @@ public class MetadataDiscoveryResource {
...
@@ -173,7 +196,12 @@ public class MetadataDiscoveryResource {
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
searchUsingFullText
(
@QueryParam
(
"query"
)
String
query
)
{
public
Response
searchUsingFullText
(
@QueryParam
(
"query"
)
String
query
)
{
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"MetadataDiscoveryResource.searchUsingFullText("
+
query
+
")"
);
}
ParamChecker
.
notEmpty
(
query
,
"query cannot be null or empty"
);
ParamChecker
.
notEmpty
(
query
,
"query cannot be null or empty"
);
final
String
jsonResultStr
=
discoveryService
.
searchByFullText
(
query
);
final
String
jsonResultStr
=
discoveryService
.
searchByFullText
(
query
);
JSONArray
rowsJsonArr
=
new
JSONArray
(
jsonResultStr
);
JSONArray
rowsJsonArr
=
new
JSONArray
(
jsonResultStr
);
...
@@ -186,6 +214,8 @@ public class MetadataDiscoveryResource {
...
@@ -186,6 +214,8 @@ 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
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/resources/TaxonomyService.java
View file @
bff013f0
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java
View file @
bff013f0
...
@@ -24,6 +24,7 @@ import org.apache.atlas.AtlasException;
...
@@ -24,6 +24,7 @@ import org.apache.atlas.AtlasException;
import
org.apache.atlas.services.MetadataService
;
import
org.apache.atlas.services.MetadataService
;
import
org.apache.atlas.typesystem.exception.TypeExistsException
;
import
org.apache.atlas.typesystem.exception.TypeExistsException
;
import
org.apache.atlas.typesystem.types.DataTypes
;
import
org.apache.atlas.typesystem.types.DataTypes
;
import
org.apache.atlas.utils.AtlasPerfTracer
;
import
org.apache.atlas.web.util.Servlets
;
import
org.apache.atlas.web.util.Servlets
;
import
org.codehaus.jettison.json.JSONArray
;
import
org.codehaus.jettison.json.JSONArray
;
import
org.codehaus.jettison.json.JSONException
;
import
org.codehaus.jettison.json.JSONException
;
...
@@ -62,6 +63,7 @@ import java.util.List;
...
@@ -62,6 +63,7 @@ import java.util.List;
public
class
TypesResource
{
public
class
TypesResource
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
TypesResource
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
TypesResource
.
class
);
private
static
final
Logger
PERF_LOG
=
AtlasPerfTracer
.
getPerfLogger
(
"rest.TypesResource"
);
private
final
MetadataService
metadataService
;
private
final
MetadataService
metadataService
;
...
@@ -80,7 +82,12 @@ public class TypesResource {
...
@@ -80,7 +82,12 @@ public class TypesResource {
@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
)
{
AtlasPerfTracer
perf
=
null
;
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
);
...
@@ -108,6 +115,8 @@ public class TypesResource {
...
@@ -108,6 +115,8 @@ 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
);
}
}
}
}
...
@@ -124,7 +133,12 @@ public class TypesResource {
...
@@ -124,7 +133,12 @@ public class TypesResource {
@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
)
{
AtlasPerfTracer
perf
=
null
;
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
);
...
@@ -152,6 +166,8 @@ public class TypesResource {
...
@@ -152,6 +166,8 @@ 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
);
}
}
}
}
...
@@ -164,7 +180,12 @@ public class TypesResource {
...
@@ -164,7 +180,12 @@ public class TypesResource {
@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
)
{
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"TypesResource.getDefinition("
+
typeName
+
")"
);
}
final
String
typeDefinition
=
metadataService
.
getTypeDefinition
(
typeName
);
final
String
typeDefinition
=
metadataService
.
getTypeDefinition
(
typeName
);
JSONObject
response
=
new
JSONObject
();
JSONObject
response
=
new
JSONObject
();
...
@@ -182,6 +203,8 @@ public class TypesResource {
...
@@ -182,6 +203,8 @@ 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
);
}
}
}
}
...
@@ -197,7 +220,12 @@ public class TypesResource {
...
@@ -197,7 +220,12 @@ public class TypesResource {
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
getTypesByFilter
(
@Context
HttpServletRequest
request
,
public
Response
getTypesByFilter
(
@Context
HttpServletRequest
request
,
@DefaultValue
(
TYPE_ALL
)
@QueryParam
(
"type"
)
String
type
)
{
@DefaultValue
(
TYPE_ALL
)
@QueryParam
(
"type"
)
String
type
)
{
AtlasPerfTracer
perf
=
null
;
try
{
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"TypesResource.getTypesByFilter("
+
type
+
")"
);
}
List
<
String
>
result
;
List
<
String
>
result
;
if
(
TYPE_ALL
.
equals
(
type
))
{
if
(
TYPE_ALL
.
equals
(
type
))
{
result
=
metadataService
.
getTypeNamesList
();
result
=
metadataService
.
getTypeNamesList
();
...
@@ -219,6 +247,8 @@ public class TypesResource {
...
@@ -219,6 +247,8 @@ 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
);
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
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