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
ef36a262
Commit
ef36a262
authored
Mar 07, 2018
by
Sarath Subramanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2480: Regression,Tag Propagation : Deleting the table with lineage and tag
parent
6770091a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
45 deletions
+61
-45
GraphHelper.java
...n/java/org/apache/atlas/repository/graph/GraphHelper.java
+5
-0
DeleteHandlerV1.java
...ache/atlas/repository/store/graph/v1/DeleteHandlerV1.java
+54
-0
EntityGraphMapper.java
...he/atlas/repository/store/graph/v1/EntityGraphMapper.java
+2
-45
No files found.
repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
View file @
ef36a262
...
...
@@ -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
;
}
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java
View file @
ef36a262
...
...
@@ -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
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
View file @
ef36a262
...
...
@@ -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
);
...
...
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