You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ap...@apache.org on 2018/05/22 21:56:50 UTC
atlas git commit: ATLAS-2705 #2
Repository: atlas
Updated Branches:
refs/heads/master 96e5f1cbd -> a0269b9ce
ATLAS-2705 #2
Change-Id: I37796a6596cb284ba885dc05ffacd1dd7bcb6fba
Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/a0269b9c
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/a0269b9c
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/a0269b9c
Branch: refs/heads/master
Commit: a0269b9ce8c1ebbe056b786f4bc1e3a522ca0e50
Parents: 96e5f1c
Author: apoorvnaik <ap...@apache.org>
Authored: Tue May 22 14:11:26 2018 -0700
Committer: apoorvnaik <ap...@apache.org>
Committed: Tue May 22 14:11:26 2018 -0700
----------------------------------------------------------------------
.../atlas/glossary/GlossaryCategoryUtils.java | 16 +++++-----
.../atlas/glossary/GlossaryTermUtils.java | 10 +++---
.../store/graph/AtlasRelationshipStore.java | 7 +++++
.../graph/v1/AtlasRelationshipStoreV1.java | 10 ++++--
.../store/graph/v1/DeleteHandlerV1.java | 33 ++++----------------
5 files changed, 35 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/atlas/blob/a0269b9c/repository/src/main/java/org/apache/atlas/glossary/GlossaryCategoryUtils.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/glossary/GlossaryCategoryUtils.java b/repository/src/main/java/org/apache/atlas/glossary/GlossaryCategoryUtils.java
index 42cdef8..38ce147 100644
--- a/repository/src/main/java/org/apache/atlas/glossary/GlossaryCategoryUtils.java
+++ b/repository/src/main/java/org/apache/atlas/glossary/GlossaryCategoryUtils.java
@@ -113,7 +113,7 @@ public class GlossaryCategoryUtils extends GlossaryUtils {
updatedCategory.getAnchor().getGlossaryGuid(),
storeObject.getGuid());
}
- relationshipStore.deleteById(storeObject.getAnchor().getRelationGuid());
+ relationshipStore.deleteById(storeObject.getAnchor().getRelationGuid(), true);
// Derive the qualifiedName when anchor changes
String anchorGlossaryGuid = updatedCategory.getAnchor().getGlossaryGuid();
@@ -135,7 +135,7 @@ public class GlossaryCategoryUtils extends GlossaryUtils {
if (DEBUG_ENABLED) {
LOG.debug("Deleting category anchor");
}
- relationshipStore.deleteById(storeObject.getAnchor().getRelationGuid());
+ relationshipStore.deleteById(storeObject.getAnchor().getRelationGuid(), true);
}
break;
}
@@ -174,7 +174,7 @@ public class GlossaryCategoryUtils extends GlossaryUtils {
relationshipStore.update(parentRelationship);
} else {
// Delete link to existing parent and link to new parent
- relationshipStore.deleteById(parentRelationship.getGuid());
+ relationshipStore.deleteById(parentRelationship.getGuid(), true);
createRelationship(defineCategoryHierarchyLink(newParent, storeObject.getGuid()));
}
}
@@ -209,7 +209,7 @@ public class GlossaryCategoryUtils extends GlossaryUtils {
if (DEBUG_ENABLED) {
LOG.debug("Removing category parent, category = {}, parent = {}", storeObject.getGuid(), existingParent.getDisplayText());
}
- relationshipStore.deleteById(existingParent.getRelationGuid());
+ relationshipStore.deleteById(existingParent.getRelationGuid(), true);
// Parent deleted, qualifiedName needs recomputation
@@ -343,7 +343,7 @@ public class GlossaryCategoryUtils extends GlossaryUtils {
if (DEBUG_ENABLED) {
LOG.debug("Creating term relation with category = {}, terms = {}", storeObject.getDisplayName(), term.getDisplayText());
}
- relationshipStore.deleteById(term.getRelationGuid());
+ relationshipStore.deleteById(term.getRelationGuid(), true);
}
}
}
@@ -485,7 +485,7 @@ public class GlossaryCategoryUtils extends GlossaryUtils {
if (DEBUG_ENABLED) {
LOG.debug("Deleting child, category = {}, child = {}", storeObject.getDisplayName(), child.getDisplayText());
}
- relationshipStore.deleteById(child.getRelationGuid());
+ relationshipStore.deleteById(child.getRelationGuid(), true);
}
}
}
@@ -565,9 +565,11 @@ public class GlossaryCategoryUtils extends GlossaryUtils {
LOG.debug("Child anchor guid({}) doesn't match parent anchor guid({}). Updating child anchor", childAnchorGuid, parentAnchorGuid);
}
// Remove old glossary relation
- relationshipStore.deleteById(child.getAnchor().getRelationGuid());
+ relationshipStore.deleteById(child.getAnchor().getRelationGuid(), true);
+
// Link to new glossary
createRelationship(defineCategoryAnchorRelation(parentAnchorGuid, child.getGuid()));
+
// Update the child's anchor GUID
child.getAnchor().setGlossaryGuid(parentAnchorGuid);
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/a0269b9c/repository/src/main/java/org/apache/atlas/glossary/GlossaryTermUtils.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/glossary/GlossaryTermUtils.java b/repository/src/main/java/org/apache/atlas/glossary/GlossaryTermUtils.java
index 2af4e79..8094019 100644
--- a/repository/src/main/java/org/apache/atlas/glossary/GlossaryTermUtils.java
+++ b/repository/src/main/java/org/apache/atlas/glossary/GlossaryTermUtils.java
@@ -119,7 +119,7 @@ public class GlossaryTermUtils extends GlossaryUtils {
}
AtlasRelatedObjectId existingTermRelation = assignedEntityMap.get(relatedObjectId.getGuid());
if (CollectionUtils.isNotEmpty(assignedEntities) && isRelationshipGuidSame(existingTermRelation, relatedObjectId)) {
- relationshipStore.deleteById(relatedObjectId.getRelationshipGuid());
+ relationshipStore.deleteById(relatedObjectId.getRelationshipGuid(), true);
} else {
throw new AtlasBaseException(AtlasErrorCode.INVALID_TERM_DISSOCIATION, relatedObjectId.getRelationshipGuid(), glossaryTerm.getGuid(), relatedObjectId.getGuid());
}
@@ -176,7 +176,7 @@ public class GlossaryTermUtils extends GlossaryUtils {
updatedTermAnchor.getGlossaryGuid(),
storeObject.getDisplayName());
}
- relationshipStore.deleteById(existingAnchor.getRelationGuid());
+ relationshipStore.deleteById(existingAnchor.getRelationGuid(), true);
// Derive the qualifiedName when anchor changes
String anchorGlossaryGuid = updatedTermAnchor.getGlossaryGuid();
@@ -195,7 +195,7 @@ public class GlossaryTermUtils extends GlossaryUtils {
if (DEBUG_ENABLED) {
LOG.debug("Deleting term anchor");
}
- relationshipStore.deleteById(existingAnchor.getRelationGuid());
+ relationshipStore.deleteById(existingAnchor.getRelationGuid(), true);
}
break;
}
@@ -406,7 +406,7 @@ public class GlossaryTermUtils extends GlossaryUtils {
if (DEBUG_ENABLED) {
LOG.debug("Deleting relation guid = {}, text = {}", categorizationHeader.getRelationGuid(), categorizationHeader.getDisplayText());
}
- relationshipStore.deleteById(categorizationHeader.getRelationGuid());
+ relationshipStore.deleteById(categorizationHeader.getRelationGuid(), true);
}
}
}
@@ -466,7 +466,7 @@ public class GlossaryTermUtils extends GlossaryUtils {
if (DEBUG_ENABLED) {
LOG.debug("Deleting term relation = {}, terms = {}", relation, termHeader.getDisplayText());
}
- relationshipStore.deleteById(termHeader.getRelationGuid());
+ relationshipStore.deleteById(termHeader.getRelationGuid(), true);
}
}
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/a0269b9c/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasRelationshipStore.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasRelationshipStore.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasRelationshipStore.java
index 072ea94..4468951 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasRelationshipStore.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasRelationshipStore.java
@@ -71,4 +71,11 @@ public interface AtlasRelationshipStore {
* @param guid relationship instance guid
*/
void deleteById(String guid) throws AtlasBaseException;
+
+ /**
+ * Delete a relationship instance using guid.
+ * @param guid relationship instance guid
+ * @param forceDelete force delete the relationship edge
+ */
+ void deleteById(String guid, boolean forceDelete) throws AtlasBaseException;
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/a0269b9c/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipStoreV1.java
index a600b20..b683c6b 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipStoreV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipStoreV1.java
@@ -234,8 +234,14 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore {
@Override
@GraphTransaction
public void deleteById(String guid) throws AtlasBaseException {
+ deleteById(guid, false);
+ }
+
+ @Override
+ @GraphTransaction
+ public void deleteById(String guid, boolean forceDelete) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
- LOG.debug("==> deleteById({})", guid);
+ LOG.debug("==> deleteById({}, {})", guid, forceDelete);
}
if (StringUtils.isEmpty(guid)) {
@@ -252,7 +258,7 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore {
throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_ALREADY_DELETED, guid);
}
- deleteHandler.deleteRelationships(Collections.singleton(edge));
+ deleteHandler.deleteRelationships(Collections.singleton(edge), forceDelete);
// notify entities for added/removed classification propagation
entityChangeNotifier.notifyPropagatedEntities();
http://git-wip-us.apache.org/repos/asf/atlas/blob/a0269b9c/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 b4d26d0..69a4758 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
@@ -52,11 +52,7 @@ import org.slf4j.LoggerFactory;
import java.util.*;
-import static org.apache.atlas.model.TypeCategory.ARRAY;
-import static org.apache.atlas.model.TypeCategory.CLASSIFICATION;
-import static org.apache.atlas.model.TypeCategory.MAP;
-import static org.apache.atlas.model.TypeCategory.OBJECT_ID_TYPE;
-import static org.apache.atlas.model.TypeCategory.STRUCT;
+import static org.apache.atlas.model.TypeCategory.*;
import static org.apache.atlas.model.instance.AtlasEntity.Status.ACTIVE;
import static org.apache.atlas.model.instance.AtlasEntity.Status.DELETED;
import static org.apache.atlas.model.typedef.AtlasRelationshipDef.PropagateTags.ONE_TO_TWO;
@@ -64,25 +60,7 @@ import static org.apache.atlas.repository.Constants.CLASSIFICATION_EDGE_NAME_PRO
import static org.apache.atlas.repository.Constants.CLASSIFICATION_LABEL;
import static org.apache.atlas.repository.Constants.PROPAGATED_TRAIT_NAMES_PROPERTY_KEY;
import static org.apache.atlas.repository.Constants.RELATIONSHIP_GUID_PROPERTY_KEY;
-import static org.apache.atlas.repository.Constants.TRAIT_NAMES_PROPERTY_KEY;
-import static org.apache.atlas.repository.graph.GraphHelper.addToPropagatedTraitNames;
-import static org.apache.atlas.repository.graph.GraphHelper.getAssociatedEntityVertex;
-import static org.apache.atlas.repository.graph.GraphHelper.getClassificationEdge;
-import static org.apache.atlas.repository.graph.GraphHelper.getClassificationEdges;
-import static org.apache.atlas.repository.graph.GraphHelper.getClassificationEntityGuid;
-import static org.apache.atlas.repository.graph.GraphHelper.getClassificationName;
-import static org.apache.atlas.repository.graph.GraphHelper.getClassificationVertices;
-import static org.apache.atlas.repository.graph.GraphHelper.getCollectionElementsUsingRelationship;
-import static org.apache.atlas.repository.graph.GraphHelper.getGuid;
-import static org.apache.atlas.repository.graph.GraphHelper.getMapValuesUsingRelationship;
-import static org.apache.atlas.repository.graph.GraphHelper.getPropagatedClassificationEdge;
-import static org.apache.atlas.repository.graph.GraphHelper.getPropagatedEdges;
-import static org.apache.atlas.repository.graph.GraphHelper.getPropagationEnabledClassificationVertices;
-import static org.apache.atlas.repository.graph.GraphHelper.getRelationshipGuid;
-import static org.apache.atlas.repository.graph.GraphHelper.getTraitNames;
-import static org.apache.atlas.repository.graph.GraphHelper.getTypeName;
-import static org.apache.atlas.repository.graph.GraphHelper.string;
-import static org.apache.atlas.repository.graph.GraphHelper.updateModificationMetadata;
+import static org.apache.atlas.repository.graph.GraphHelper.*;
import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.getIdFromEdge;
import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.getQualifiedAttributePropertyKey;
import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.getState;
@@ -150,16 +128,17 @@ public abstract class DeleteHandlerV1 {
* @throws AtlasBaseException
*/
public void deleteRelationship(AtlasEdge edge) throws AtlasBaseException {
- deleteRelationships(Collections.singleton(edge));
+ deleteRelationships(Collections.singleton(edge), false);
}
/**
* Deletes the specified relationship edges.
*
* @param edges
+ * @param forceDelete
* @throws AtlasBaseException
*/
- public void deleteRelationships(Collection<AtlasEdge> edges) throws AtlasBaseException {
+ public void deleteRelationships(Collection<AtlasEdge> edges, final boolean forceDelete) throws AtlasBaseException {
for (AtlasEdge edge : edges) {
boolean isInternal = isInternalType(edge.getInVertex()) && isInternalType(edge.getOutVertex());
@@ -171,7 +150,7 @@ public abstract class DeleteHandlerV1 {
continue;
}
- deleteEdge(edge, isInternal);
+ deleteEdge(edge, isInternal || forceDelete);
}
}