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
a064e092
Commit
a064e092
authored
6 years ago
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2878: avoid retrieval of entiyWithExtInfo when extInfo is not needed
(cherry picked from commit 8e7ecf72f32ef6ca282a314d85761742e229a48b)
parent
48e52249
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
84 additions
and
32 deletions
+84
-32
EntityAuditListenerV2.java
.../apache/atlas/repository/audit/EntityAuditListenerV2.java
+2
-4
AtlasInstanceConverter.java
...e/atlas/repository/converters/AtlasInstanceConverter.java
+24
-4
FullTextMapperV2.java
...a/org/apache/atlas/repository/graph/FullTextMapperV2.java
+33
-6
AtlasEntityChangeNotifier.java
.../repository/store/graph/v2/AtlasEntityChangeNotifier.java
+2
-5
EntityGraphMapper.java
...he/atlas/repository/store/graph/v2/EntityGraphMapper.java
+4
-8
RequestContext.java
...er-api/src/main/java/org/apache/atlas/RequestContext.java
+19
-5
No files found.
repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListenerV2.java
View file @
a064e092
...
...
@@ -180,8 +180,7 @@ public class EntityAuditListenerV2 implements EntityChangeListenerV2 {
List
<
EntityAuditEventV2
>
events
=
new
ArrayList
<>();
for
(
AtlasRelatedObjectId
relatedObjectId
:
entities
)
{
AtlasEntityWithExtInfo
entityWithExtInfo
=
instanceConverter
.
getAndCacheEntity
(
relatedObjectId
.
getGuid
());
AtlasEntity
entity
=
(
entityWithExtInfo
!=
null
)
?
entityWithExtInfo
.
getEntity
()
:
null
;
AtlasEntity
entity
=
instanceConverter
.
getAndCacheEntity
(
relatedObjectId
.
getGuid
());
if
(
entity
!=
null
)
{
events
.
add
(
createEvent
(
entity
,
TERM_ADD
,
"Added term: "
+
term
.
toAuditString
()));
...
...
@@ -198,8 +197,7 @@ public class EntityAuditListenerV2 implements EntityChangeListenerV2 {
List
<
EntityAuditEventV2
>
events
=
new
ArrayList
<>();
for
(
AtlasRelatedObjectId
relatedObjectId
:
entities
)
{
AtlasEntityWithExtInfo
entityWithExtInfo
=
instanceConverter
.
getAndCacheEntity
(
relatedObjectId
.
getGuid
());
AtlasEntity
entity
=
(
entityWithExtInfo
!=
null
)
?
entityWithExtInfo
.
getEntity
()
:
null
;
AtlasEntity
entity
=
instanceConverter
.
getAndCacheEntity
(
relatedObjectId
.
getGuid
());
if
(
entity
!=
null
)
{
events
.
add
(
createEvent
(
entity
,
TERM_DELETE
,
"Deleted term: "
+
term
.
toAuditString
()));
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
View file @
a064e092
...
...
@@ -28,6 +28,7 @@ import org.apache.atlas.model.TypeCategory;
import
org.apache.atlas.model.instance.AtlasClassification
;
import
org.apache.atlas.model.instance.AtlasEntity
;
import
org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo
;
import
org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo
;
import
org.apache.atlas.model.instance.AtlasEntityHeader
;
import
org.apache.atlas.model.instance.EntityMutationResponse
;
import
org.apache.atlas.model.instance.EntityMutations.EntityOperation
;
...
...
@@ -94,12 +95,12 @@ public class AtlasInstanceConverter {
}
public
Referenceable
getReferenceable
(
String
guid
)
throws
AtlasBaseException
{
AtlasEntity
.
AtlasEntityWithExtInfo
entity
=
getAndCacheEntity
(
guid
);
AtlasEntity
WithExtInfo
entity
=
getAndCacheEntityExtInfo
(
guid
);
return
getReferenceable
(
entity
);
}
public
Referenceable
getReferenceable
(
AtlasEntity
.
AtlasEntity
WithExtInfo
entity
)
throws
AtlasBaseException
{
public
Referenceable
getReferenceable
(
AtlasEntityWithExtInfo
entity
)
throws
AtlasBaseException
{
AtlasFormatConverter
.
ConverterContext
ctx
=
new
AtlasFormatConverter
.
ConverterContext
();
ctx
.
addEntity
(
entity
.
getEntity
());
...
...
@@ -291,10 +292,29 @@ public class AtlasInstanceConverter {
return
ret
;
}
public
AtlasEntity
getAndCacheEntity
(
String
guid
)
throws
AtlasBaseException
{
RequestContext
context
=
RequestContext
.
get
();
AtlasEntity
entity
=
context
.
getEntity
(
guid
);
if
(
entity
==
null
)
{
entity
=
entityGraphRetriever
.
toAtlasEntity
(
guid
);
if
(
entity
!=
null
)
{
context
.
cache
(
entity
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Cache miss -> GUID = {}"
,
guid
);
}
}
}
return
entity
;
}
public
AtlasEntity
.
AtlasEntityWithExtInfo
getAndCacheEntity
(
String
guid
)
throws
AtlasBaseException
{
public
AtlasEntity
WithExtInfo
getAndCacheEntityExtInfo
(
String
guid
)
throws
AtlasBaseException
{
RequestContext
context
=
RequestContext
.
get
();
AtlasEntity
.
AtlasEntityWithExtInfo
entityWithExtInfo
=
context
.
getInstanceV2
(
guid
);
AtlasEntity
WithExtInfo
entityWithExtInfo
=
context
.
getEntityWithExtInfo
(
guid
);
if
(
entityWithExtInfo
==
null
)
{
entityWithExtInfo
=
entityGraphRetriever
.
toAtlasEntityWithExtInfo
(
guid
);
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/graph/FullTextMapperV2.java
View file @
a064e092
...
...
@@ -75,7 +75,15 @@ public class FullTextMapperV2 {
*/
public
String
getIndexTextForClassifications
(
String
guid
,
List
<
AtlasClassification
>
classifications
)
throws
AtlasBaseException
{
String
ret
=
null
;
AtlasEntityWithExtInfo
entityWithExtInfo
=
getAndCacheEntity
(
guid
);
final
AtlasEntityWithExtInfo
entityWithExtInfo
;
if
(
followReferences
)
{
entityWithExtInfo
=
getAndCacheEntityWithExtInfo
(
guid
);
}
else
{
AtlasEntity
entity
=
getAndCacheEntity
(
guid
);
entityWithExtInfo
=
entity
!=
null
?
new
AtlasEntityWithExtInfo
(
entity
)
:
null
;
}
if
(
entityWithExtInfo
!=
null
)
{
StringBuilder
sb
=
new
StringBuilder
();
...
...
@@ -102,12 +110,12 @@ public class FullTextMapperV2 {
public
String
getIndexTextForEntity
(
String
guid
)
throws
AtlasBaseException
{
String
ret
=
null
;
AtlasEntity
WithExtInfo
entity
=
getAndCacheEntity
(
guid
);
AtlasEntity
entity
=
getAndCacheEntity
(
guid
);
if
(
entity
!=
null
)
{
StringBuilder
sb
=
new
StringBuilder
();
map
(
entity
.
getEntity
(),
entity
,
sb
,
new
HashSet
<
String
>());
map
(
entity
,
null
,
sb
,
new
HashSet
<
String
>());
ret
=
sb
.
toString
();
}
...
...
@@ -166,7 +174,7 @@ public class FullTextMapperV2 {
private
void
mapAttribute
(
Object
value
,
AtlasEntityExtInfo
entityExtInfo
,
StringBuilder
sb
,
Set
<
String
>
processedGuids
)
throws
AtlasBaseException
{
if
(
value
instanceof
AtlasObjectId
)
{
if
(
followReferences
)
{
if
(
followReferences
&&
entityExtInfo
!=
null
)
{
AtlasObjectId
objectId
=
(
AtlasObjectId
)
value
;
AtlasEntity
entity
=
entityExtInfo
.
getEntity
(
objectId
.
getGuid
());
...
...
@@ -203,9 +211,28 @@ public class FullTextMapperV2 {
}
}
private
AtlasEntityWithExtInfo
getAndCacheEntity
(
String
guid
)
throws
AtlasBaseException
{
private
AtlasEntity
getAndCacheEntity
(
String
guid
)
throws
AtlasBaseException
{
RequestContext
context
=
RequestContext
.
get
();
AtlasEntity
entity
=
context
.
getEntity
(
guid
);
if
(
entity
==
null
)
{
entity
=
entityGraphRetriever
.
toAtlasEntity
(
guid
);
if
(
entity
!=
null
)
{
context
.
cache
(
entity
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Cache miss -> GUID = {}"
,
guid
);
}
}
}
return
entity
;
}
private
AtlasEntityWithExtInfo
getAndCacheEntityWithExtInfo
(
String
guid
)
throws
AtlasBaseException
{
RequestContext
context
=
RequestContext
.
get
();
AtlasEntityWithExtInfo
entityWithExtInfo
=
context
.
get
InstanceV2
(
guid
);
AtlasEntityWithExtInfo
entityWithExtInfo
=
context
.
get
EntityWithExtInfo
(
guid
);
if
(
entityWithExtInfo
==
null
)
{
// Only map ownedRef and relationship attr when follow references is set to true
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityChangeNotifier.java
View file @
a064e092
...
...
@@ -254,8 +254,7 @@ public class AtlasEntityChangeNotifier {
continue
;
}
AtlasEntityWithExtInfo
entityWithExtInfo
=
instanceConverter
.
getAndCacheEntity
(
guid
);
AtlasEntity
entity
=
entityWithExtInfo
!=
null
?
entityWithExtInfo
.
getEntity
()
:
null
;
AtlasEntity
entity
=
instanceConverter
.
getAndCacheEntity
(
guid
);
if
(
entity
==
null
)
{
continue
;
...
...
@@ -413,9 +412,7 @@ public class AtlasEntityChangeNotifier {
entity
.
setGuid
(
entityGuid
);
}
else
{
AtlasEntityWithExtInfo
entityWithExtInfo
=
instanceConverter
.
getAndCacheEntity
(
entityGuid
);
entity
=
(
entityWithExtInfo
!=
null
)
?
entityWithExtInfo
.
getEntity
()
:
null
;
entity
=
instanceConverter
.
getAndCacheEntity
(
entityGuid
);
}
if
(
entity
!=
null
)
{
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java
View file @
a064e092
...
...
@@ -1422,8 +1422,7 @@ public class EntityGraphMapper {
for
(
AtlasVertex
vertex
:
notificationVertices
)
{
String
entityGuid
=
GraphHelper
.
getGuid
(
vertex
);
AtlasEntityWithExtInfo
entityWithExtInfo
=
instanceConverter
.
getAndCacheEntity
(
entityGuid
);
AtlasEntity
entity
=
(
entityWithExtInfo
!=
null
)
?
entityWithExtInfo
.
getEntity
()
:
null
;
AtlasEntity
entity
=
instanceConverter
.
getAndCacheEntity
(
entityGuid
);
List
<
AtlasClassification
>
addedClassifications
=
StringUtils
.
equals
(
entityGuid
,
guid
)
?
addClassifications
:
propagations
.
get
(
vertex
);
if
(
CollectionUtils
.
isNotEmpty
(
addedClassifications
))
{
...
...
@@ -1529,8 +1528,7 @@ public class EntityGraphMapper {
for
(
Map
.
Entry
<
AtlasVertex
,
List
<
AtlasClassification
>>
entry
:
removedClassifications
.
entrySet
())
{
String
guid
=
GraphHelper
.
getGuid
(
entry
.
getKey
());
List
<
AtlasClassification
>
deletedClassificationNames
=
entry
.
getValue
();
AtlasEntityWithExtInfo
entityWithExtInfo
=
instanceConverter
.
getAndCacheEntity
(
guid
);
AtlasEntity
entity
=
(
entityWithExtInfo
!=
null
)
?
entityWithExtInfo
.
getEntity
()
:
null
;
AtlasEntity
entity
=
instanceConverter
.
getAndCacheEntity
(
guid
);
entityChangeNotifier
.
onClassificationDeletedFromEntity
(
entity
,
deletedClassificationNames
);
}
...
...
@@ -1687,8 +1685,7 @@ public class EntityGraphMapper {
for
(
AtlasVertex
vertex
:
notificationVertices
)
{
String
entityGuid
=
GraphHelper
.
getGuid
(
vertex
);
AtlasEntityWithExtInfo
entityWithExtInfo
=
instanceConverter
.
getAndCacheEntity
(
entityGuid
);
AtlasEntity
entity
=
(
entityWithExtInfo
!=
null
)
?
entityWithExtInfo
.
getEntity
()
:
null
;
AtlasEntity
entity
=
instanceConverter
.
getAndCacheEntity
(
entityGuid
);
if
(
isActive
(
entity
))
{
entityChangeNotifier
.
onClassificationUpdatedToEntity
(
entity
,
updatedClassifications
);
...
...
@@ -1700,8 +1697,7 @@ public class EntityGraphMapper {
AtlasVertex
vertex
=
entry
.
getKey
();
List
<
AtlasClassification
>
removedClassifications
=
entry
.
getValue
();
String
entityGuid
=
GraphHelper
.
getGuid
(
vertex
);
AtlasEntityWithExtInfo
entityWithExtInfo
=
instanceConverter
.
getAndCacheEntity
(
entityGuid
);
AtlasEntity
entity
=
(
entityWithExtInfo
!=
null
)
?
entityWithExtInfo
.
getEntity
()
:
null
;
AtlasEntity
entity
=
instanceConverter
.
getAndCacheEntity
(
entityGuid
);
if
(
isActive
(
entity
))
{
entityChangeNotifier
.
onClassificationDeletedFromEntity
(
entity
,
removedClassifications
);
...
...
This diff is collapsed.
Click to expand it.
server-api/src/main/java/org/apache/atlas/RequestContext.java
View file @
a064e092
...
...
@@ -35,7 +35,8 @@ public class RequestContext {
private
final
Map
<
String
,
AtlasObjectId
>
updatedEntities
=
new
HashMap
<>();
private
final
Map
<
String
,
AtlasObjectId
>
deletedEntities
=
new
HashMap
<>();
private
final
Map
<
String
,
AtlasEntityWithExtInfo
>
entityCacheV2
=
new
HashMap
<>();
private
final
Map
<
String
,
AtlasEntity
>
entityCache
=
new
HashMap
<>();
private
final
Map
<
String
,
AtlasEntityWithExtInfo
>
entityExtInfoCache
=
new
HashMap
<>();
private
final
Map
<
String
,
List
<
AtlasClassification
>>
addedPropagations
=
new
HashMap
<>();
private
final
Map
<
String
,
List
<
AtlasClassification
>>
removedPropagations
=
new
HashMap
<>();
private
final
long
requestTime
=
System
.
currentTimeMillis
();
...
...
@@ -70,7 +71,8 @@ public class RequestContext {
if
(
instance
!=
null
)
{
instance
.
updatedEntities
.
clear
();
instance
.
deletedEntities
.
clear
();
instance
.
entityCacheV2
.
clear
();
instance
.
entityCache
.
clear
();
instance
.
entityExtInfoCache
.
clear
();
instance
.
addedPropagations
.
clear
();
instance
.
removedPropagations
.
clear
();
...
...
@@ -174,10 +176,18 @@ public class RequestContext {
*/
public
void
cache
(
AtlasEntityWithExtInfo
entity
)
{
if
(
entity
!=
null
&&
entity
.
getEntity
()
!=
null
&&
entity
.
getEntity
().
getGuid
()
!=
null
)
{
entityCacheV2
.
put
(
entity
.
getEntity
().
getGuid
(),
entity
);
entityExtInfoCache
.
put
(
entity
.
getEntity
().
getGuid
(),
entity
);
entityCache
.
put
(
entity
.
getEntity
().
getGuid
(),
entity
.
getEntity
());
}
}
public
void
cache
(
AtlasEntity
entity
)
{
if
(
entity
!=
null
&&
entity
.
getGuid
()
!=
null
)
{
entityCache
.
put
(
entity
.
getGuid
(),
entity
);
}
}
public
Collection
<
AtlasObjectId
>
getUpdatedEntities
()
{
return
updatedEntities
.
values
();
}
...
...
@@ -193,8 +203,12 @@ public class RequestContext {
* @param guid the guid to find
* @return Either the instance or null if it is not in the cache.
*/
public
AtlasEntityWithExtInfo
getInstanceV2
(
String
guid
)
{
return
entityCacheV2
.
get
(
guid
);
public
AtlasEntityWithExtInfo
getEntityWithExtInfo
(
String
guid
)
{
return
entityExtInfoCache
.
get
(
guid
);
}
public
AtlasEntity
getEntity
(
String
guid
)
{
return
entityCache
.
get
(
guid
);
}
public
long
getRequestTime
()
{
...
...
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