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
59648d28
Commit
59648d28
authored
5 years ago
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3279: avoid unncessary retrieval of entity-extended info while sending notifications
Change-Id: I82e0bba27010709c74cd98a93f8a9c617577535e
parent
9062e2c8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
19 deletions
+32
-19
FullTextMapperV2.java
...a/org/apache/atlas/repository/graph/FullTextMapperV2.java
+3
-3
AtlasEntityChangeNotifier.java
.../repository/store/graph/v2/AtlasEntityChangeNotifier.java
+29
-16
No files found.
repository/src/main/java/org/apache/atlas/repository/graph/FullTextMapperV2.java
View file @
59648d28
...
...
@@ -271,11 +271,11 @@ public class FullTextMapperV2 {
}
}
p
rivate
AtlasEntity
getAndCacheEntity
(
String
guid
)
throws
AtlasBaseException
{
p
ublic
AtlasEntity
getAndCacheEntity
(
String
guid
)
throws
AtlasBaseException
{
return
getAndCacheEntity
(
guid
,
true
);
}
p
rivate
AtlasEntity
getAndCacheEntity
(
String
guid
,
boolean
includeReferences
)
throws
AtlasBaseException
{
p
ublic
AtlasEntity
getAndCacheEntity
(
String
guid
,
boolean
includeReferences
)
throws
AtlasBaseException
{
RequestContext
context
=
RequestContext
.
get
();
AtlasEntity
entity
=
context
.
getEntity
(
guid
);
...
...
@@ -294,7 +294,7 @@ public class FullTextMapperV2 {
return
entity
;
}
p
rivate
AtlasEntityWithExtInfo
getAndCacheEntityWithExtInfo
(
String
guid
)
throws
AtlasBaseException
{
p
ublic
AtlasEntityWithExtInfo
getAndCacheEntityWithExtInfo
(
String
guid
)
throws
AtlasBaseException
{
RequestContext
context
=
RequestContext
.
get
();
AtlasEntityWithExtInfo
entityWithExtInfo
=
context
.
getEntityWithExtInfo
(
guid
);
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityChangeNotifier.java
View file @
59648d28
...
...
@@ -92,7 +92,7 @@ public class AtlasEntityChangeNotifier {
}
public
void
onEntitiesMutated
(
EntityMutationResponse
entityMutationResponse
,
boolean
isImport
)
throws
AtlasBaseException
{
if
(
CollectionUtils
.
isEmpty
(
entityChangeListeners
)
||
instanceConverter
==
null
)
{
if
(
CollectionUtils
.
isEmpty
(
entityChangeListeners
))
{
return
;
}
...
...
@@ -118,7 +118,7 @@ public class AtlasEntityChangeNotifier {
}
public
void
notifyRelationshipMutation
(
AtlasRelationship
relationship
,
EntityNotification
.
EntityNotificationV2
.
OperationType
operationType
)
throws
AtlasBaseException
{
if
(
CollectionUtils
.
isEmpty
(
entityChangeListeners
)
||
instanceConverter
==
null
)
{
if
(
CollectionUtils
.
isEmpty
(
entityChangeListeners
))
{
return
;
}
...
...
@@ -145,6 +145,7 @@ public class AtlasEntityChangeNotifier {
}
else
{
updateFullTextMapping
(
entity
.
getGuid
(),
addedClassifications
);
if
(
instanceConverter
!=
null
)
{
Referenceable
entityRef
=
toReferenceable
(
entity
.
getGuid
());
List
<
Struct
>
traits
=
toStruct
(
addedClassifications
);
...
...
@@ -161,17 +162,17 @@ public class AtlasEntityChangeNotifier {
}
}
}
}
public
void
onClassificationUpdatedToEntity
(
AtlasEntity
entity
,
List
<
AtlasClassification
>
updatedClassifications
)
throws
AtlasBaseException
{
if
(
isV2EntityNotificationEnabled
)
{
doFullTextMapping
(
entity
.
getGuid
());
if
(
isV2EntityNotificationEnabled
)
{
for
(
EntityChangeListenerV2
listener
:
entityChangeListenersV2
)
{
listener
.
onClassificationsUpdated
(
entity
,
updatedClassifications
);
}
}
else
{
doFullTextMapping
(
entity
.
getGuid
());
if
(
instanceConverter
!=
null
)
{
Referenceable
entityRef
=
toReferenceable
(
entity
.
getGuid
());
List
<
Struct
>
traits
=
toStruct
(
updatedClassifications
);
...
...
@@ -188,17 +189,17 @@ public class AtlasEntityChangeNotifier {
}
}
}
}
public
void
onClassificationDeletedFromEntity
(
AtlasEntity
entity
,
List
<
AtlasClassification
>
deletedClassifications
)
throws
AtlasBaseException
{
if
(
isV2EntityNotificationEnabled
)
{
doFullTextMapping
(
entity
.
getGuid
());
if
(
isV2EntityNotificationEnabled
)
{
for
(
EntityChangeListenerV2
listener
:
entityChangeListenersV2
)
{
listener
.
onClassificationsDeleted
(
entity
,
deletedClassifications
);
}
}
else
{
doFullTextMapping
(
entity
.
getGuid
());
if
(
instanceConverter
!=
null
)
{
Referenceable
entityRef
=
toReferenceable
(
entity
.
getGuid
());
List
<
Struct
>
traits
=
toStruct
(
deletedClassifications
);
...
...
@@ -213,7 +214,7 @@ public class AtlasEntityChangeNotifier {
throw
new
AtlasBaseException
(
AtlasErrorCode
.
NOTIFICATION_FAILED
,
e
,
getListenerName
(
listener
),
"TraitDelete"
);
}
}
}
}
}
...
...
@@ -223,7 +224,7 @@ public class AtlasEntityChangeNotifier {
for
(
EntityChangeListenerV2
listener
:
entityChangeListenersV2
)
{
listener
.
onTermAdded
(
term
,
entityIds
);
}
}
else
{
}
else
if
(
instanceConverter
!=
null
)
{
List
<
Referenceable
>
entityRefs
=
toReferenceables
(
entityIds
);
for
(
EntityChangeListener
listener
:
entityChangeListeners
)
{
...
...
@@ -242,7 +243,7 @@ public class AtlasEntityChangeNotifier {
for
(
EntityChangeListenerV2
listener
:
entityChangeListenersV2
)
{
listener
.
onTermDeleted
(
term
,
entityIds
);
}
}
else
{
}
else
if
(
instanceConverter
!=
null
)
{
List
<
Referenceable
>
entityRefs
=
toReferenceables
(
entityIds
);
for
(
EntityChangeListener
listener
:
entityChangeListeners
)
{
...
...
@@ -277,7 +278,7 @@ public class AtlasEntityChangeNotifier {
continue
;
}
AtlasEntity
entity
=
instanceConverter
.
getAndCacheEntity
(
guid
);
AtlasEntity
entity
=
fullTextMapperV2
.
getAndCacheEntity
(
guid
);
if
(
entity
==
null
)
{
continue
;
...
...
@@ -300,11 +301,15 @@ public class AtlasEntityChangeNotifier {
return
;
}
MetricRecorder
metric
=
RequestContext
.
get
().
startMetricRecord
(
"notifyListeners"
);
if
(
isV2EntityNotificationEnabled
)
{
notifyV2Listeners
(
entityHeaders
,
operation
,
isImport
);
}
else
{
notifyV1Listeners
(
entityHeaders
,
operation
,
isImport
);
}
RequestContext
.
get
().
endMetricRecord
(
metric
);
}
private
void
notifyRelationshipListeners
(
List
<
AtlasRelationship
>
relationships
,
EntityOperation
operation
,
boolean
isImport
)
throws
AtlasBaseException
{
...
...
@@ -322,6 +327,7 @@ public class AtlasEntityChangeNotifier {
private
void
notifyV1Listeners
(
List
<
AtlasEntityHeader
>
entityHeaders
,
EntityOperation
operation
,
boolean
isImport
)
throws
AtlasBaseException
{
if
(
instanceConverter
!=
null
)
{
List
<
Referenceable
>
typedRefInsts
=
toReferenceables
(
entityHeaders
,
operation
);
for
(
EntityChangeListener
listener
:
entityChangeListeners
)
{
...
...
@@ -343,6 +349,7 @@ public class AtlasEntityChangeNotifier {
}
}
}
}
private
void
notifyV2Listeners
(
List
<
AtlasEntityHeader
>
entityHeaders
,
EntityOperation
operation
,
boolean
isImport
)
throws
AtlasBaseException
{
List
<
AtlasEntity
>
entities
=
toAtlasEntities
(
entityHeaders
,
operation
);
...
...
@@ -386,6 +393,7 @@ public class AtlasEntityChangeNotifier {
private
List
<
Referenceable
>
toReferenceables
(
List
<
AtlasEntityHeader
>
entityHeaders
,
EntityOperation
operation
)
throws
AtlasBaseException
{
List
<
Referenceable
>
ret
=
new
ArrayList
<>(
entityHeaders
.
size
());
if
(
instanceConverter
!=
null
)
{
// delete notifications don't need all attributes. Hence the special handling for delete operation
if
(
operation
==
EntityOperation
.
DELETE
)
{
for
(
AtlasEntityHeader
entityHeader
:
entityHeaders
)
{
...
...
@@ -396,6 +404,7 @@ public class AtlasEntityChangeNotifier {
ret
.
add
(
toReferenceable
(
entityHeader
.
getGuid
()));
}
}
}
return
ret
;
}
...
...
@@ -403,7 +412,7 @@ public class AtlasEntityChangeNotifier {
private
List
<
Referenceable
>
toReferenceables
(
List
<
AtlasRelatedObjectId
>
entityIds
)
throws
AtlasBaseException
{
List
<
Referenceable
>
ret
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isNotEmpty
(
entityIds
))
{
if
(
instanceConverter
!=
null
&&
CollectionUtils
.
isNotEmpty
(
entityIds
))
{
for
(
AtlasRelatedObjectId
relatedObjectId
:
entityIds
)
{
String
entityGuid
=
relatedObjectId
.
getGuid
();
...
...
@@ -417,7 +426,7 @@ public class AtlasEntityChangeNotifier {
private
Referenceable
toReferenceable
(
String
entityId
)
throws
AtlasBaseException
{
Referenceable
ret
=
null
;
if
(
StringUtils
.
isNotEmpty
(
entityId
))
{
if
(
instanceConverter
!=
null
&&
StringUtils
.
isNotEmpty
(
entityId
))
{
ret
=
instanceConverter
.
getReferenceable
(
entityId
);
}
...
...
@@ -427,7 +436,7 @@ public class AtlasEntityChangeNotifier {
private
List
<
Struct
>
toStruct
(
List
<
AtlasClassification
>
classifications
)
throws
AtlasBaseException
{
List
<
Struct
>
ret
=
null
;
if
(
classifications
!=
null
)
{
if
(
instanceConverter
!=
null
&&
classifications
!=
null
)
{
ret
=
new
ArrayList
<>(
classifications
.
size
());
for
(
AtlasClassification
classification
:
classifications
)
{
...
...
@@ -468,7 +477,7 @@ public class AtlasEntityChangeNotifier {
}
else
{
String
entityGuid
=
entityHeader
.
getGuid
();
entity
=
instanceConverter
.
getAndCacheEntity
(
entityGuid
);
entity
=
fullTextMapperV2
.
getAndCacheEntity
(
entityGuid
);
}
if
(
entity
!=
null
)
{
...
...
@@ -545,6 +554,10 @@ public class AtlasEntityChangeNotifier {
}
private
void
doFullTextMapping
(
String
guid
)
{
if
(
AtlasRepositoryConfiguration
.
isFreeTextSearchEnabled
()
||
!
AtlasRepositoryConfiguration
.
isFullTextSearchEnabled
())
{
return
;
}
AtlasEntityHeader
entityHeader
=
new
AtlasEntityHeader
();
entityHeader
.
setGuid
(
guid
);
...
...
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