This is an automated email from the ASF dual-hosted git repository.
sarath pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 28caa64 ATLAS-3602: Provide option to Ignore relationship attribute
mapping in getAndCacheEntity()
28caa64 is described below
commit 28caa643dab596a195bb47d4e868cec2fedde411
Author: Sarath Subramanian <[email protected]>
AuthorDate: Mon Feb 3 14:30:58 2020 -0800
ATLAS-3602: Provide option to Ignore relationship attribute mapping in
getAndCacheEntity()
(cherry picked from commit a6cdb608b21d8c4d1c843ca7d2d974fc2b65b93c)
---
.../main/java/org/apache/atlas/AtlasConfiguration.java | 1 +
.../repository/converters/AtlasInstanceConverter.java | 18 ++++++++++++++----
.../repository/store/graph/v2/EntityGraphMapper.java | 10 ++++++----
3 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java
b/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java
index 6e726f2..1a0d0cc 100644
--- a/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java
+++ b/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java
@@ -54,6 +54,7 @@ public enum AtlasConfiguration {
GRAPHSTORE_INDEXED_STRING_SAFE_LENGTH("atlas.graphstore.indexed.string.safe.length",
Short.MAX_VALUE), // based on
org.apache.hadoop.hbase.client.Mutation.checkRow()
RELATIONSHIP_WARN_NO_RELATIONSHIPS("atlas.relationships.warnOnNoRelationships",
false),
+
ENTITY_CHANGE_NOTIFY_IGNORE_RELATIONSHIP_ATTRIBUTES("atlas.entity.change.notify.ignore.relationship.attributes",
true),
//search configuration
SEARCH_MAX_LIMIT("atlas.search.maxlimit", 10000),
diff --git
a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
index 01e339d..172e187 100644
---
a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
+++
b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
@@ -65,12 +65,14 @@ public class AtlasInstanceConverter {
private final AtlasTypeRegistry typeRegistry;
private final AtlasFormatConverters instanceFormatters;
private final EntityGraphRetriever entityGraphRetriever;
+ private final EntityGraphRetriever
entityGraphRetrieverIgnoreRelationshipAttrs;
@Inject
public AtlasInstanceConverter(AtlasTypeRegistry typeRegistry,
AtlasFormatConverters instanceFormatters) {
- this.typeRegistry = typeRegistry;
- this.instanceFormatters = instanceFormatters;
- this.entityGraphRetriever = new EntityGraphRetriever(typeRegistry);
+ this.typeRegistry = typeRegistry;
+ this.instanceFormatters = instanceFormatters;
+ this.entityGraphRetriever = new
EntityGraphRetriever(typeRegistry);
+ this.entityGraphRetrieverIgnoreRelationshipAttrs = new
EntityGraphRetriever(typeRegistry, true);
}
public Referenceable[] getReferenceables(Collection<AtlasEntity> entities)
throws AtlasBaseException {
@@ -293,11 +295,19 @@ public class AtlasInstanceConverter {
}
public AtlasEntity getAndCacheEntity(String guid) throws
AtlasBaseException {
+ return getAndCacheEntity(guid, false);
+ }
+
+ public AtlasEntity getAndCacheEntity(String guid, boolean
ignoreRelationshipAttributes) throws AtlasBaseException {
RequestContext context = RequestContext.get();
AtlasEntity entity = context.getEntity(guid);
if (entity == null) {
- entity = entityGraphRetriever.toAtlasEntity(guid);
+ if (ignoreRelationshipAttributes) {
+ entity =
entityGraphRetrieverIgnoreRelationshipAttrs.toAtlasEntity(guid);
+ } else {
+ entity = entityGraphRetriever.toAtlasEntity(guid);
+ }
if (entity != null) {
context.cache(entity);
diff --git
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java
index e427a59..3d42d1f 100644
---
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java
+++
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java
@@ -124,6 +124,8 @@ public class EntityGraphMapper {
private static final int CUSTOM_ATTRIBUTE_KEY_MAX_LENGTH =
AtlasConfiguration.CUSTOM_ATTRIBUTE_KEY_MAX_LENGTH.getInt();
private static final int CUSTOM_ATTRIBUTE_VALUE_MAX_LENGTH =
AtlasConfiguration.CUSTOM_ATTRIBUTE_VALUE_MAX_LENGTH.getInt();
+ private static final boolean
ENTITY_CHANGE_NOTIFY_IGNORE_RELATIONSHIP_ATTRIBUTES =
AtlasConfiguration.ENTITY_CHANGE_NOTIFY_IGNORE_RELATIONSHIP_ATTRIBUTES.getBoolean();
+
private final GraphHelper graphHelper =
GraphHelper.getInstance();
private final AtlasGraph graph;
private final DeleteHandlerDelegate deleteDelegate;
@@ -1916,7 +1918,7 @@ public class EntityGraphMapper {
private AtlasEntity updateClassificationText(AtlasVertex vertex) throws
AtlasBaseException {
String guid = GraphHelper.getGuid(vertex);
- AtlasEntity entity = instanceConverter.getAndCacheEntity(guid);
+ AtlasEntity entity = instanceConverter.getAndCacheEntity(guid,
ENTITY_CHANGE_NOTIFY_IGNORE_RELATIONSHIP_ATTRIBUTES);
vertex.setProperty(CLASSIFICATION_TEXT_KEY,
fullTextMapperV2.getClassificationTextForEntity(entity));
return entity;
@@ -1929,7 +1931,7 @@ public class EntityGraphMapper {
}
String guid = GraphHelper.getGuid(vertex);
- AtlasEntity entity = instanceConverter.getAndCacheEntity(guid);
+ AtlasEntity entity = instanceConverter.getAndCacheEntity(guid,
ENTITY_CHANGE_NOTIFY_IGNORE_RELATIONSHIP_ATTRIBUTES);
List<String> classificationNames = new ArrayList<>();
List<String> propagatedClassificationNames = new ArrayList<>();
@@ -2139,7 +2141,7 @@ public class EntityGraphMapper {
for (AtlasVertex vertex : notificationVertices) {
String entityGuid = GraphHelper.getGuid(vertex);
- AtlasEntity entity =
instanceConverter.getAndCacheEntity(entityGuid);
+ AtlasEntity entity =
instanceConverter.getAndCacheEntity(entityGuid,
ENTITY_CHANGE_NOTIFY_IGNORE_RELATIONSHIP_ATTRIBUTES);
if (isActive(entity)) {
vertex.setProperty(CLASSIFICATION_TEXT_KEY,
fullTextMapperV2.getClassificationTextForEntity(entity));
@@ -2382,7 +2384,7 @@ public class EntityGraphMapper {
if(CollectionUtils.isNotEmpty(propagatedVertices)) {
for(AtlasVertex vertex : propagatedVertices) {
- AtlasEntity entity =
instanceConverter.getAndCacheEntity(GraphHelper.getGuid(vertex));
+ AtlasEntity entity =
instanceConverter.getAndCacheEntity(GraphHelper.getGuid(vertex),
ENTITY_CHANGE_NOTIFY_IGNORE_RELATIONSHIP_ATTRIBUTES);
if (isActive(entity)) {
vertex.setProperty(CLASSIFICATION_TEXT_KEY,
fullTextMapperV2.getClassificationTextForEntity(entity));