You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by sa...@apache.org on 2018/03/08 05:30:09 UTC
atlas git commit: ATLAS-2480: Regression,
Tag Propagation : Deleting the table with lineage and tag
Repository: atlas
Updated Branches:
refs/heads/master 6770091aa -> ef36a262a
ATLAS-2480: Regression,Tag Propagation : Deleting the table with lineage and tag
Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/ef36a262
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/ef36a262
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/ef36a262
Branch: refs/heads/master
Commit: ef36a262a17d7cdc3b255ebb257e61d7726f014c
Parents: 6770091
Author: Sarath Subramanian <ss...@hortonworks.com>
Authored: Wed Mar 7 21:29:21 2018 -0800
Committer: Sarath Subramanian <ss...@hortonworks.com>
Committed: Wed Mar 7 21:29:21 2018 -0800
----------------------------------------------------------------------
.../atlas/repository/graph/GraphHelper.java | 5 ++
.../store/graph/v1/DeleteHandlerV1.java | 54 ++++++++++++++++++++
.../store/graph/v1/EntityGraphMapper.java | 47 +----------------
3 files changed, 61 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/atlas/blob/ef36a262/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
index 9d56fa9..97e4941 100755
--- a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
+++ b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
@@ -766,6 +766,11 @@ public final class GraphHelper {
return getVerticesForPropertyValues(Constants.GUID_PROPERTY_KEY, guids);
}
+ public static void updateModificationMetadata(AtlasVertex vertex) {
+ AtlasGraphUtilsV1.setProperty(vertex, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContextV1.get().getRequestTime());
+ AtlasGraphUtilsV1.setProperty(vertex, Constants.MODIFIED_BY_KEY, RequestContextV1.get().getUser());
+ }
+
public static String getQualifiedNameForMapKey(String prefix, String key) {
return prefix + "." + key;
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/ef36a262/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java
index 2b62a68..4056eb1 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java
@@ -40,15 +40,23 @@ import org.apache.atlas.type.AtlasStructType.AtlasAttribute;
import org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection;
import org.apache.atlas.type.AtlasType;
import org.apache.atlas.type.AtlasTypeRegistry;
+import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import static org.apache.atlas.model.instance.AtlasEntity.Status.DELETED;
+import static org.apache.atlas.repository.Constants.PROPAGATED_TRAIT_NAMES_PROPERTY_KEY;
import static org.apache.atlas.repository.graph.GraphHelper.EDGE_LABEL_PREFIX;
+import static org.apache.atlas.repository.graph.GraphHelper.addListProperty;
+import static org.apache.atlas.repository.graph.GraphHelper.getIncomingEdgesByLabel;
+import static org.apache.atlas.repository.graph.GraphHelper.getPropagatedEdgeLabel;
+import static org.apache.atlas.repository.graph.GraphHelper.getPropagatedTraitNames;
+import static org.apache.atlas.repository.graph.GraphHelper.getTypeName;
import static org.apache.atlas.repository.graph.GraphHelper.isRelationshipEdge;
import static org.apache.atlas.repository.graph.GraphHelper.string;
+import static org.apache.atlas.repository.graph.GraphHelper.updateModificationMetadata;
import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.getIdFromEdge;
import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.getState;
@@ -323,7 +331,12 @@ public abstract class DeleteHandlerV1 {
protected void deleteTypeVertex(AtlasVertex instanceVertex, TypeCategory typeCategory, boolean force) throws AtlasBaseException {
switch (typeCategory) {
case STRUCT:
+ deleteTypeVertex(instanceVertex, force);
+ break;
+
case CLASSIFICATION:
+ removeTagPropagation(instanceVertex);
+
deleteTypeVertex(instanceVertex, force);
break;
@@ -337,6 +350,47 @@ public abstract class DeleteHandlerV1 {
}
}
+ public void removeTagPropagation(AtlasVertex classificationVertex) throws AtlasBaseException {
+ if (classificationVertex != null) {
+ String classificationName = getTypeName(classificationVertex);
+ Iterator<AtlasEdge> iterator = getIncomingEdgesByLabel(classificationVertex, getPropagatedEdgeLabel(classificationName));
+
+ // remove classification from propagated entity vertices
+ while (iterator != null && iterator.hasNext()) {
+ AtlasEdge propagatedEdge = iterator.next();
+
+ if (propagatedEdge != null) {
+ AtlasVertex propagatedEntityVertex = propagatedEdge.getOutVertex();
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Removing propagated classification: [{}] from: [{}][{}] with edge label: [{}]", classificationName,
+ getTypeName(propagatedEntityVertex), GraphHelper.getGuid(propagatedEntityVertex), getPropagatedEdgeLabel(classificationName));
+ }
+
+ removePropagatedTraitName(propagatedEntityVertex, classificationName);
+
+ deleteEdge(propagatedEdge, true);
+
+ updateModificationMetadata(propagatedEntityVertex);
+ }
+ }
+ }
+ }
+
+ private void removePropagatedTraitName(AtlasVertex entityVertex, String classificationName) {
+ if (entityVertex != null && StringUtils.isNotEmpty(classificationName)) {
+ List<String> propagatedTraitNames = getPropagatedTraitNames(entityVertex);
+
+ propagatedTraitNames.remove(classificationName);
+
+ entityVertex.removeProperty(PROPAGATED_TRAIT_NAMES_PROPERTY_KEY);
+
+ for (String propagatedTraitName : propagatedTraitNames) {
+ addListProperty(entityVertex, PROPAGATED_TRAIT_NAMES_PROPERTY_KEY, propagatedTraitName);
+ }
+ }
+ }
+
/**
* Deleting any type vertex. Goes over the complex attributes and removes the references
* @param instanceVertex
http://git-wip-us.apache.org/repos/asf/atlas/blob/ef36a262/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
index 0ba06b9..73e5aa2 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
@@ -78,8 +78,6 @@ import static org.apache.atlas.repository.Constants.PROPAGATED_TRAIT_NAMES_PROPE
import static org.apache.atlas.repository.Constants.STATE_PROPERTY_KEY;
import static org.apache.atlas.repository.Constants.TRAIT_NAMES_PROPERTY_KEY;
import static org.apache.atlas.repository.graph.GraphHelper.addListProperty;
-import static org.apache.atlas.repository.graph.GraphHelper.getIncomingEdgesByLabel;
-import static org.apache.atlas.repository.graph.GraphHelper.getPropagatedTraitNames;
import static org.apache.atlas.repository.graph.GraphHelper.getPropagatedEdgeLabel;
import static org.apache.atlas.repository.graph.GraphHelper.getTraitLabel;
import static org.apache.atlas.repository.graph.GraphHelper.getTraitNames;
@@ -87,6 +85,7 @@ import static org.apache.atlas.repository.graph.GraphHelper.getTypeName;
import static org.apache.atlas.repository.graph.GraphHelper.getTypeNames;
import static org.apache.atlas.repository.graph.GraphHelper.isRelationshipEdge;
import static org.apache.atlas.repository.graph.GraphHelper.string;
+import static org.apache.atlas.repository.graph.GraphHelper.updateModificationMetadata;
import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.getIdFromVertex;
import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.IN;
import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.OUT;
@@ -922,11 +921,6 @@ public class EntityGraphMapper {
mapAttributes(struct, vertex, UPDATE, context);
}
- private void updateModificationMetadata(AtlasVertex vertex) {
- AtlasGraphUtilsV1.setProperty(vertex, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContextV1.get().getRequestTime());
- AtlasGraphUtilsV1.setProperty(vertex, Constants.MODIFIED_BY_KEY, RequestContextV1.get().getUser());
- }
-
private Long getEntityVersion(AtlasEntity entity) {
Long ret = entity != null ? entity.getVersion() : null;
return (ret != null) ? ret : 0;
@@ -1563,30 +1557,7 @@ public class EntityGraphMapper {
}
private void removeTagPropagation(AtlasVertex classificationVertex) throws AtlasBaseException {
- if (classificationVertex != null) {
- String classificationName = getTypeName(classificationVertex);
- Iterator<AtlasEdge> iterator = getIncomingEdgesByLabel(classificationVertex, getPropagatedEdgeLabel(classificationName));
-
- // remove classification from propagated entity vertices
- while (iterator != null && iterator.hasNext()) {
- AtlasEdge propagatedEdge = iterator.next();
-
- if (propagatedEdge != null) {
- AtlasVertex propagatedEntityVertex = propagatedEdge.getOutVertex();
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("Removing propagated classification: [{}] from: [{}][{}] with edge label: [{}]", classificationName,
- getTypeName(propagatedEntityVertex), GraphHelper.getGuid(propagatedEntityVertex), getPropagatedEdgeLabel(classificationName));
- }
-
- removePropagatedTraitName(propagatedEntityVertex, classificationName);
-
- deleteHandler.deleteEdge(propagatedEdge, true);
-
- updateModificationMetadata(propagatedEntityVertex);
- }
- }
- }
+ deleteHandler.removeTagPropagation(classificationVertex);
}
private AtlasEdge mapClassification(EntityOperation operation, final EntityMutationContext context, AtlasClassification classification,
@@ -1625,20 +1596,6 @@ public class EntityGraphMapper {
deleteClassifications(guid, traitNames);
}
- private void removePropagatedTraitName(AtlasVertex entityVertex, String classificationName) {
- if (entityVertex != null && StringUtils.isNotEmpty(classificationName)) {
- List<String> propagatedTraitNames = getPropagatedTraitNames(entityVertex);
-
- propagatedTraitNames.remove(classificationName);
-
- entityVertex.removeProperty(PROPAGATED_TRAIT_NAMES_PROPERTY_KEY);
-
- for (String propagatedTraitName : propagatedTraitNames) {
- addListProperty(entityVertex, PROPAGATED_TRAIT_NAMES_PROPERTY_KEY, propagatedTraitName);
- }
- }
- }
-
private void updateTraitNamesProperty(AtlasVertex entityVertex, List<String> traitNames) {
if (entityVertex != null) {
entityVertex.removeProperty(TRAIT_NAMES_PROPERTY_KEY);