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
10e82ff4
Commit
10e82ff4
authored
8 years ago
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1471: updated logging for better troubleshooting and reduce overhead
parent
34d235f3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
265 additions
and
99 deletions
+265
-99
FullTextMapper.java
...ava/org/apache/atlas/repository/graph/FullTextMapper.java
+0
-2
GraphToTypedInstanceMapper.java
...he/atlas/repository/graph/GraphToTypedInstanceMapper.java
+0
-4
TypedInstanceToGraphMapper.java
...he/atlas/repository/graph/TypedInstanceToGraphMapper.java
+0
-4
MonitoredAspectTest.java
...src/test/aspect/org/apache/atlas/MonitoredAspectTest.java
+0
-47
atlas-log4j.xml
typesystem/src/main/resources/atlas-log4j.xml
+16
-0
AdminResource.java
...in/java/org/apache/atlas/web/resources/AdminResource.java
+50
-16
DataSetLineageResource.java
...rg/apache/atlas/web/resources/DataSetLineageResource.java
+33
-7
EntityResource.java
...n/java/org/apache/atlas/web/resources/EntityResource.java
+0
-0
LineageResource.java
.../java/org/apache/atlas/web/resources/LineageResource.java
+45
-7
MetadataDiscoveryResource.java
...apache/atlas/web/resources/MetadataDiscoveryResource.java
+49
-5
TypesResource.java
...in/java/org/apache/atlas/web/resources/TypesResource.java
+72
-7
No files found.
repository/src/main/java/org/apache/atlas/repository/graph/FullTextMapper.java
View file @
10e82ff4
...
...
@@ -18,7 +18,6 @@
package
org
.
apache
.
atlas
.
repository
.
graph
;
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.ITypedReferenceableInstance
;
...
...
@@ -50,7 +49,6 @@ public class FullTextMapper {
instanceCache
=
new
HashMap
<>();
}
@Monitored
public
String
mapRecursive
(
AtlasVertex
instanceVertex
,
boolean
followReferences
)
throws
AtlasException
{
String
guid
=
GraphHelper
.
getGuid
(
instanceVertex
);
ITypedReferenceableInstance
typedReference
;
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/graph/GraphToTypedInstanceMapper.java
View file @
10e82ff4
...
...
@@ -19,7 +19,6 @@ package org.apache.atlas.repository.graph;
import
com.google.inject.Singleton
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.aspect.Monitored
;
import
org.apache.atlas.repository.Constants
;
import
org.apache.atlas.repository.graphdb.AtlasEdge
;
import
org.apache.atlas.repository.graphdb.AtlasEdgeDirection
;
...
...
@@ -66,7 +65,6 @@ public final class GraphToTypedInstanceMapper {
this
.
graph
=
graph
;
}
@Monitored
public
ITypedReferenceableInstance
mapGraphToTypedInstance
(
String
guid
,
AtlasVertex
instanceVertex
)
throws
AtlasException
{
...
...
@@ -104,7 +102,6 @@ public final class GraphToTypedInstanceMapper {
return
typedInstance
;
}
@Monitored
private
void
mapVertexToInstanceTraits
(
AtlasVertex
instanceVertex
,
ITypedReferenceableInstance
typedInstance
,
List
<
String
>
traits
)
throws
AtlasException
{
for
(
String
traitName
:
traits
)
{
...
...
@@ -117,7 +114,6 @@ public final class GraphToTypedInstanceMapper {
}
}
@Monitored
public
void
mapVertexToInstance
(
AtlasVertex
instanceVertex
,
ITypedInstance
typedInstance
,
Map
<
String
,
AttributeInfo
>
fields
)
throws
AtlasException
{
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java
View file @
10e82ff4
...
...
@@ -20,7 +20,6 @@ package org.apache.atlas.repository.graph;
import
com.google.inject.Inject
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.RequestContext
;
import
org.apache.atlas.aspect.Monitored
;
import
org.apache.atlas.repository.Constants
;
import
org.apache.atlas.repository.RepositoryException
;
import
org.apache.atlas.repository.graphdb.AtlasEdge
;
...
...
@@ -85,7 +84,6 @@ public final class TypedInstanceToGraphMapper {
UPDATE_FULL
}
@Monitored
void
mapTypedInstanceToGraph
(
Operation
operation
,
ITypedReferenceableInstance
...
typedInstances
)
throws
AtlasException
{
RequestContext
requestContext
=
RequestContext
.
get
();
...
...
@@ -156,7 +154,6 @@ public final class TypedInstanceToGraphMapper {
return
guids
;
}
@Monitored
private
String
addOrUpdateAttributesAndTraits
(
Operation
operation
,
ITypedReferenceableInstance
typedInstance
)
throws
AtlasException
{
if
(
LOG
.
isDebugEnabled
())
{
...
...
@@ -254,7 +251,6 @@ public final class TypedInstanceToGraphMapper {
}
}
@Monitored
private
TypeUtils
.
Pair
<
List
<
ITypedReferenceableInstance
>,
List
<
ITypedReferenceableInstance
>>
createVerticesAndDiscoverInstances
(
Collection
<
IReferenceableInstance
>
instances
)
throws
AtlasException
{
...
...
This diff is collapsed.
Click to expand it.
server-api/src/test/aspect/org/apache/atlas/MonitoredAspectTest.java
deleted
100644 → 0
View file @
34d235f3
/**
* 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
);
}
}
This diff is collapsed.
Click to expand it.
typesystem/src/main/resources/atlas-log4j.xml
View file @
10e82ff4
...
...
@@ -41,6 +41,22 @@
<appender-ref
ref=
"console"
/>
</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"
>
<param
name=
"File"
value=
"${atlas.log.dir}/failed.log"
/>
<param
name=
"Append"
value=
"true"
/>
...
...
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
View file @
10e82ff4
...
...
@@ -20,8 +20,6 @@ package org.apache.atlas.web.resources;
import
com.google.inject.Inject
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.aspect.Monitored
;
import
org.apache.atlas.utils.AtlasPerfTracer
;
import
org.apache.atlas.web.filters.AtlasCSRFPreventionFilter
;
import
org.apache.atlas.web.service.ServiceState
;
import
org.apache.atlas.web.util.Servlets
;
...
...
@@ -31,6 +29,7 @@ import org.apache.commons.lang.StringUtils;
import
org.codehaus.jettison.json.JSONException
;
import
org.codehaus.jettison.json.JSONObject
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.context.SecurityContextHolder
;
...
...
@@ -52,7 +51,7 @@ import java.util.Set;
@Path
(
"admin"
)
@Singleton
public
class
AdminResource
{
private
static
final
Logger
PERF_LOG
=
AtlasPerfTracer
.
getPerfLogger
(
"rest.AdminResource"
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
AdminResource
.
class
);
private
static
final
String
isCSRF_ENABLED
=
"atlas.rest-csrf.enabled"
;
private
static
final
String
BROWSER_USER_AGENT_PARAM
=
"atlas.rest-csrf.browser-useragents-regex"
;
...
...
@@ -73,11 +72,14 @@ public class AdminResource {
*
* @return json representing the thread stack dump.
*/
@Monitored
@GET
@Path
(
"stack"
)
@Produces
(
MediaType
.
TEXT_PLAIN
)
public
String
getThreadDump
()
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> AdminResource.getThreadDump()"
);
}
ThreadGroup
topThreadGroup
=
Thread
.
currentThread
().
getThreadGroup
();
while
(
topThreadGroup
.
getParent
()
!=
null
)
{
...
...
@@ -93,6 +95,11 @@ public class AdminResource {
String
stackTrace
=
StringUtils
.
join
(
threads
[
i
].
getStackTrace
(),
"\n"
);
builder
.
append
(
stackTrace
);
}
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== AdminResource.getThreadDump()"
);
}
return
builder
.
toString
();
}
...
...
@@ -101,11 +108,14 @@ public class AdminResource {
*
* @return json representing the version.
*/
@Monitored
@GET
@Path
(
"version"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
getVersion
()
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> AdminResource.getVersion()"
);
}
if
(
version
==
null
)
{
try
{
PropertiesConfiguration
configProperties
=
new
PropertiesConfiguration
(
"atlas-buildinfo.properties"
);
...
...
@@ -124,34 +134,51 @@ public class AdminResource {
}
}
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== AdminResource.getVersion()"
);
}
return
version
;
}
@Monitored
@GET
@Path
(
"status"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
getStatus
()
{
JSONObject
responseData
=
new
JSONObject
();
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> AdminResource.getStatus()"
);
}
Response
response
;
try
{
JSONObject
responseData
=
new
JSONObject
();
responseData
.
put
(
AtlasClient
.
STATUS
,
serviceState
.
getState
().
toString
());
Response
response
=
Response
.
ok
(
responseData
).
build
();
return
response
;
response
=
Response
.
ok
(
responseData
).
build
();
}
catch
(
JSONException
e
)
{
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== AdminResource.getStatus()"
);
}
return
response
;
}
@Monitored
@GET
@Path
(
"session"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
getUserProfile
()
{
JSONObject
responseData
=
new
JSONObject
();
Boolean
enableTaxonomy
=
null
;
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> AdminResource.getUserProfile()"
);
}
Response
response
;
try
{
PropertiesConfiguration
configProperties
=
new
PropertiesConfiguration
(
"atlas-application.properties"
);
enableTaxonomy
=
configProperties
.
getBoolean
(
isTaxonomyEnabled
,
false
);
Boolean
enableTaxonomy
=
configProperties
.
getBoolean
(
isTaxonomyEnabled
,
false
);
Authentication
auth
=
SecurityContextHolder
.
getContext
().
getAuthentication
();
String
userName
=
null
;
Set
<
String
>
groups
=
new
HashSet
<>();
...
...
@@ -163,18 +190,25 @@ public class AdminResource {
}
}
JSONObject
responseData
=
new
JSONObject
();
responseData
.
put
(
isCSRF_ENABLED
,
AtlasCSRFPreventionFilter
.
isCSRF_ENABLED
);
responseData
.
put
(
BROWSER_USER_AGENT_PARAM
,
AtlasCSRFPreventionFilter
.
BROWSER_USER_AGENTS_DEFAULT
);
responseData
.
put
(
CUSTOM_METHODS_TO_IGNORE_PARAM
,
AtlasCSRFPreventionFilter
.
METHODS_TO_IGNORE_DEFAULT
);
responseData
.
put
(
CUSTOM_HEADER_PARAM
,
AtlasCSRFPreventionFilter
.
HEADER_DEFAULT
);
responseData
.
put
(
isTaxonomyEnabled
,
enableTaxonomy
);
responseData
.
put
(
"userName"
,
userName
);
responseData
.
put
(
"groups"
,
groups
);
return
Response
.
ok
(
responseData
).
build
();
response
=
Response
.
ok
(
responseData
).
build
();
}
catch
(
JSONException
|
ConfigurationException
e
)
{
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== AdminResource.getUserProfile()"
);
}
return
response
;
}
}
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/resources/DataSetLineageResource.java
View file @
10e82ff4
...
...
@@ -19,7 +19,6 @@
package
org
.
apache
.
atlas
.
web
.
resources
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.aspect.Monitored
;
import
org.apache.atlas.discovery.DiscoveryException
;
import
org.apache.atlas.discovery.LineageService
;
import
org.apache.atlas.typesystem.exception.EntityNotFoundException
;
...
...
@@ -69,15 +68,22 @@ public class DataSetLineageResource {
*
* @param tableName table name
*/
@Monitored
@GET
@Path
(
"table/{tableName}/inputs/graph"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
inputsGraph
(
@Context
HttpServletRequest
request
,
@PathParam
(
"tableName"
)
String
tableName
)
{
LOG
.
info
(
"Fetching lineage inputs graph for tableName={}"
,
tableName
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> DataSetLineageResource.inputsGraph({})"
,
tableName
);
}
AtlasPerfTracer
perf
=
null
;
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"DataSetLineageResource.inputsGraph(tableName="
+
tableName
+
")"
);
}
final
String
jsonResult
=
lineageService
.
getInputsGraph
(
tableName
);
JSONObject
response
=
new
JSONObject
();
...
...
@@ -95,6 +101,8 @@ public class DataSetLineageResource {
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get lineage inputs graph for table {}"
,
tableName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
...
...
@@ -103,15 +111,22 @@ public class DataSetLineageResource {
*
* @param tableName table name
*/
@Monitored
@GET
@Path
(
"table/{tableName}/outputs/graph"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
outputsGraph
(
@Context
HttpServletRequest
request
,
@PathParam
(
"tableName"
)
String
tableName
)
{
LOG
.
info
(
"Fetching lineage outputs graph for tableName={}"
,
tableName
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> DataSetLineageResource.outputsGraph({})"
,
tableName
);
}
AtlasPerfTracer
perf
=
null
;
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"DataSetLineageResource.outputsGraph(tableName="
+
tableName
+
")"
);
}
final
String
jsonResult
=
lineageService
.
getOutputsGraph
(
tableName
);
JSONObject
response
=
new
JSONObject
();
...
...
@@ -129,6 +144,8 @@ public class DataSetLineageResource {
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get lineage outputs graph for table {}"
,
tableName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
...
...
@@ -137,15 +154,22 @@ public class DataSetLineageResource {
*
* @param tableName table name
*/
@Monitored
@GET
@Path
(
"table/{tableName}/schema"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
schema
(
@Context
HttpServletRequest
request
,
@PathParam
(
"tableName"
)
String
tableName
)
{
LOG
.
info
(
"Fetching schema for tableName={}"
,
tableName
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> DataSetLineageResource.schema({})"
,
tableName
);
}
AtlasPerfTracer
perf
=
null
;
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"DataSetLineageResource.schema(tableName="
+
tableName
+
")"
);
}
final
String
jsonResult
=
lineageService
.
getSchema
(
tableName
);
JSONObject
response
=
new
JSONObject
();
...
...
@@ -163,6 +187,8 @@ public class DataSetLineageResource {
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get schema for table {}"
,
tableName
,
e
);
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 @
10e82ff4
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/resources/LineageResource.java
View file @
10e82ff4
...
...
@@ -19,7 +19,6 @@
package
org
.
apache
.
atlas
.
web
.
resources
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.aspect.Monitored
;
import
org.apache.atlas.discovery.AtlasLineageService
;
import
org.apache.atlas.discovery.DiscoveryException
;
import
org.apache.atlas.discovery.LineageService
;
...
...
@@ -29,6 +28,7 @@ import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.typesystem.exception.EntityNotFoundException
;
import
org.apache.atlas.typesystem.exception.SchemaNotFoundException
;
import
org.apache.atlas.utils.AtlasPerfTracer
;
import
org.apache.atlas.web.util.LineageUtils
;
import
org.apache.atlas.web.util.Servlets
;
import
org.codehaus.jettison.json.JSONException
;
...
...
@@ -50,6 +50,7 @@ import javax.ws.rs.core.Response;
@Singleton
public
class
LineageResource
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
DataSetLineageResource
.
class
);
private
static
final
Logger
PERF_LOG
=
AtlasPerfTracer
.
getPerfLogger
(
"rest.LineageResource"
);
private
final
AtlasLineageService
atlasLineageService
;
private
final
LineageService
lineageService
;
...
...
@@ -73,15 +74,21 @@ public class LineageResource {
* @param guid dataset entity id
* @return
*/
@Monitored
@GET
@Path
(
"{guid}/inputs/graph"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
inputsGraph
(
@PathParam
(
"guid"
)
String
guid
)
{
LOG
.
info
(
"Fetching lineage inputs graph for guid={}"
,
guid
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> LineageResource.inputsGraph({})"
,
guid
);
}
AtlasPerfTracer
perf
=
null
;
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"LineageResource.inputsGraph("
+
guid
+
")"
);
}
AtlasLineageInfo
lineageInfo
=
atlasLineageService
.
getAtlasLineageInfo
(
guid
,
LineageDirection
.
INPUT
,
-
1
);
final
String
result
=
LineageUtils
.
toLineageStruct
(
lineageInfo
,
typeRegistry
);
...
...
@@ -96,6 +103,12 @@ public class LineageResource {
}
catch
(
JSONException
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
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== LineageResource.inputsGraph({})"
,
guid
);
}
}
}
...
...
@@ -104,15 +117,22 @@ public class LineageResource {
*
* @param guid dataset entity id
*/
@Monitored
@GET
@Path
(
"{guid}/outputs/graph"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
outputsGraph
(
@PathParam
(
"guid"
)
String
guid
)
{
LOG
.
info
(
"Fetching lineage outputs graph for entity guid={}"
,
guid
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> LineageResource.outputsGraph({})"
,
guid
);
}
AtlasPerfTracer
perf
=
null
;
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"LineageResource.outputsGraph("
+
guid
+
")"
);
}
AtlasLineageInfo
lineageInfo
=
atlasLineageService
.
getAtlasLineageInfo
(
guid
,
LineageDirection
.
OUTPUT
,
-
1
);
final
String
result
=
LineageUtils
.
toLineageStruct
(
lineageInfo
,
typeRegistry
);
...
...
@@ -127,6 +147,12 @@ public class LineageResource {
}
catch
(
JSONException
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
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== LineageResource.outputsGraph({})"
,
guid
);
}
}
}
...
...
@@ -135,15 +161,21 @@ public class LineageResource {
*
* @param guid dataset entity id
*/
@Monitored
@GET
@Path
(
"{guid}/schema"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
schema
(
@PathParam
(
"guid"
)
String
guid
)
{
LOG
.
info
(
"Fetching schema for entity guid={}"
,
guid
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> LineageResource.schema({})"
,
guid
);
}
AtlasPerfTracer
perf
=
null
;
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"LineageResource.schema("
+
guid
+
")"
);
}
final
String
jsonResult
=
lineageService
.
getSchemaForEntity
(
guid
);
JSONObject
response
=
new
JSONObject
();
...
...
@@ -163,6 +195,12 @@ public class LineageResource {
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get schema for entity={}"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== LineageResource.schema({})"
,
guid
);
}
}
}
}
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
View file @
10e82ff4
...
...
@@ -21,7 +21,6 @@ package org.apache.atlas.web.resources;
import
com.google.common.base.Preconditions
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasConfiguration
;
import
org.apache.atlas.aspect.Monitored
;
import
org.apache.atlas.classification.InterfaceAudience
;
import
org.apache.atlas.discovery.DiscoveryException
;
import
org.apache.atlas.discovery.DiscoveryService
;
...
...
@@ -83,7 +82,6 @@ public class MetadataDiscoveryResource {
* @param offset offset to the results returned, used for pagination. offset >= 0. -1 maps to offset 0
* @return JSON representing the type and results.
*/
@Monitored
@GET
@Path
(
"search"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
...
...
@@ -99,13 +97,17 @@ public class MetadataDiscoveryResource {
dslQueryFailed
=
true
;
}
}
catch
(
Exception
e
)
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Error while running DSL. Switching to fulltext for query {}"
,
query
,
e
);
}
dslQueryFailed
=
true
;
}
if
(
dslQueryFailed
)
{
response
=
searchUsingFullText
(
query
,
limit
,
offset
);
}
return
response
;
}
...
...
@@ -121,7 +123,6 @@ public class MetadataDiscoveryResource {
*
* @return JSON representing the type and results.
*/
@Monitored
@GET
@Path
(
"search/dsl"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
...
...
@@ -129,7 +130,16 @@ public class MetadataDiscoveryResource {
public
Response
searchUsingQueryDSL
(
@QueryParam
(
"query"
)
String
dslQuery
,
@DefaultValue
(
LIMIT_OFFSET_DEFAULT
)
@QueryParam
(
"limit"
)
int
limit
,
@DefaultValue
(
LIMIT_OFFSET_DEFAULT
)
@QueryParam
(
"offset"
)
int
offset
)
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> MetadataDiscoveryResource.searchUsingQueryDSL({}, {}, {})"
,
dslQuery
,
limit
,
offset
);
}
AtlasPerfTracer
perf
=
null
;
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"MetadataDiscoveryResource.searchUsingQueryDSL("
+
dslQuery
+
", "
+
limit
+
", "
+
offset
+
")"
);
}
dslQuery
=
ParamChecker
.
notEmpty
(
dslQuery
,
"dslQuery cannot be null"
);
QueryParams
queryParams
=
validateQueryParams
(
limit
,
offset
);
final
String
jsonResultStr
=
discoveryService
.
searchByDSL
(
dslQuery
,
queryParams
);
...
...
@@ -143,6 +153,12 @@ public class MetadataDiscoveryResource {
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get entity list for dslQuery {}"
,
dslQuery
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== MetadataDiscoveryResource.searchUsingQueryDSL({}, {}, {})"
,
dslQuery
,
limit
,
offset
);
}
}
}
...
...
@@ -174,14 +190,22 @@ public class MetadataDiscoveryResource {
* @param gremlinQuery search query in raw gremlin format.
* @return JSON representing the type and results.
*/
@Monitored
@GET
@Path
(
"search/gremlin"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@InterfaceAudience
.
Private
public
Response
searchUsingGremlinQuery
(
@QueryParam
(
"query"
)
String
gremlinQuery
)
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> MetadataDiscoveryResource.searchUsingGremlinQuery({})"
,
gremlinQuery
);
}
AtlasPerfTracer
perf
=
null
;
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"MetadataDiscoveryResource.searchUsingGremlinQuery("
+
gremlinQuery
+
")"
);
}
gremlinQuery
=
ParamChecker
.
notEmpty
(
gremlinQuery
,
"gremlinQuery cannot be null or empty"
);
final
List
<
Map
<
String
,
String
>>
results
=
discoveryService
.
searchByGremlin
(
gremlinQuery
);
...
...
@@ -204,6 +228,12 @@ public class MetadataDiscoveryResource {
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get entity list for gremlinQuery {}"
,
gremlinQuery
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== MetadataDiscoveryResource.searchUsingGremlinQuery({})"
,
gremlinQuery
);
}
}
}
...
...
@@ -215,7 +245,6 @@ public class MetadataDiscoveryResource {
* @param offset offset to the results returned, used for pagination. offset >= 0. -1 maps to offset 0
* @return JSON representing the type and results.
*/
@Monitored
@GET
@Path
(
"search/fulltext"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
...
...
@@ -223,7 +252,16 @@ public class MetadataDiscoveryResource {
public
Response
searchUsingFullText
(
@QueryParam
(
"query"
)
String
query
,
@DefaultValue
(
LIMIT_OFFSET_DEFAULT
)
@QueryParam
(
"limit"
)
int
limit
,
@DefaultValue
(
LIMIT_OFFSET_DEFAULT
)
@QueryParam
(
"offset"
)
int
offset
)
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> MetadataDiscoveryResource.searchUsingFullText({}, {}, {})"
,
query
,
limit
,
offset
);
}
AtlasPerfTracer
perf
=
null
;
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"
);
QueryParams
queryParams
=
validateQueryParams
(
limit
,
offset
);
final
String
jsonResultStr
=
discoveryService
.
searchByFullText
(
query
,
queryParams
);
...
...
@@ -237,6 +275,12 @@ public class MetadataDiscoveryResource {
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get entity list for query {}"
,
query
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== MetadataDiscoveryResource.searchUsingFullText({}, {}, {})"
,
query
,
limit
,
offset
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java
View file @
10e82ff4
...
...
@@ -22,7 +22,6 @@ import com.sun.jersey.api.client.ClientResponse;
import
com.sun.jersey.api.core.ResourceContext
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.aspect.Monitored
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.TypeCategory
;
import
org.apache.atlas.model.typedef.AtlasClassificationDef
;
...
...
@@ -88,17 +87,29 @@ public class TypesResource {
* 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.
*/
@Monitored
@POST
@Consumes
({
Servlets
.
JSON_MEDIA_TYPE
,
MediaType
.
APPLICATION_JSON
})
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
submit
(
@Context
HttpServletRequest
request
)
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> TypesResource.submit()"
);
}
AtlasPerfTracer
perf
=
null
;
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"TypesResource.submit()"
);
}
TypesREST
typesRest
=
resourceContext
.
getResource
(
TypesREST
.
class
);
JSONArray
typesResponse
=
new
JSONArray
();
try
{
final
String
typeDefinition
=
Servlets
.
getRequestPayload
(
request
);
LOG
.
info
(
"Creating type with definition {} "
,
typeDefinition
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Creating type with definition {} "
,
typeDefinition
);
}
AtlasTypesDef
createTypesDef
=
RestUtils
.
toAtlasTypesDef
(
typeDefinition
,
typeRegistry
);
AtlasTypesDef
createdTypesDef
=
typesRest
.
createAtlasTypeDefs
(
createTypesDef
);
...
...
@@ -127,6 +138,12 @@ public class TypesResource {
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to persist types"
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== TypesResource.submit()"
);
}
}
}
...
...
@@ -139,16 +156,28 @@ public class TypesResource {
* @param request
* @return
*/
@Monitored
@PUT
@Consumes
({
Servlets
.
JSON_MEDIA_TYPE
,
MediaType
.
APPLICATION_JSON
})
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
update
(
@Context
HttpServletRequest
request
)
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> TypesResource.update()"
);
}
AtlasPerfTracer
perf
=
null
;
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"TypesResource.update()"
);
}
TypesREST
typesRest
=
resourceContext
.
getResource
(
TypesREST
.
class
);
JSONArray
typesResponse
=
new
JSONArray
();
try
{
final
String
typeDefinition
=
Servlets
.
getRequestPayload
(
request
);
LOG
.
info
(
"Updating type with definition {} "
,
typeDefinition
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Updating type with definition {} "
,
typeDefinition
);
}
AtlasTypesDef
updateTypesDef
=
RestUtils
.
toAtlasTypesDef
(
typeDefinition
,
typeRegistry
);
AtlasTypesDef
updatedTypesDef
=
typesRest
.
updateAtlasTypeDefs
(
updateTypesDef
);
...
...
@@ -174,6 +203,12 @@ public class TypesResource {
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to persist types"
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== TypesResource.update()"
);
}
}
}
...
...
@@ -182,11 +217,20 @@ public class TypesResource {
*
* @param typeName name of a type which is unique.
*/
@Monitored
@GET
@Path
(
"{typeName}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
getDefinition
(
@Context
HttpServletRequest
request
,
@PathParam
(
"typeName"
)
String
typeName
)
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> TypesResource.getDefinition({})"
,
typeName
);
}
AtlasPerfTracer
perf
=
null
;
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"TypesResource.getDefinition("
+
typeName
+
")"
);
}
TypesREST
typesRest
=
resourceContext
.
getResource
(
TypesREST
.
class
);
JSONObject
response
=
new
JSONObject
();
...
...
@@ -233,6 +277,12 @@ public class TypesResource {
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get type definition for type {}"
,
typeName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== TypesResource.getDefinition({})"
,
typeName
);
}
}
}
...
...
@@ -248,12 +298,21 @@ public class TypesResource {
* For example, typeCategory = TRAIT && supertype contains 'X' && supertype !contains 'Y'
* If there is no filter, all the types are returned
*/
@Monitored
@GET
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
getTypesByFilter
(
@Context
HttpServletRequest
request
,
@QueryParam
(
"type"
)
String
typeCategory
,
@QueryParam
(
"supertype"
)
String
supertype
,
@QueryParam
(
"notsupertype"
)
String
notsupertype
)
throws
AtlasBaseException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> TypesResource.getTypesByFilter({}, {}, {})"
,
typeCategory
,
supertype
,
notsupertype
);
}
AtlasPerfTracer
perf
=
null
;
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"TypesResource.getTypesByFilter("
+
typeCategory
+
", "
+
supertype
+
", "
+
notsupertype
+
")"
);
}
TypesREST
typesRest
=
resourceContext
.
getResource
(
TypesREST
.
class
);
JSONObject
response
=
new
JSONObject
();
try
{
...
...
@@ -270,6 +329,12 @@ public class TypesResource {
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get types list"
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== TypesResource.getTypesByFilter({}, {}, {})"
,
typeCategory
,
supertype
,
notsupertype
);
}
}
}
}
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