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
d9ebc242
Commit
d9ebc242
authored
Nov 30, 2019
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3544: fix NPE during entity-delete
parent
9f5b7861
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
30 deletions
+37
-30
DeleteHandlerV1.java
...ache/atlas/repository/store/graph/v1/DeleteHandlerV1.java
+37
-30
No files found.
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java
View file @
d9ebc242
...
@@ -99,22 +99,27 @@ public abstract class DeleteHandlerV1 {
...
@@ -99,22 +99,27 @@ public abstract class DeleteHandlerV1 {
* @throws AtlasException
* @throws AtlasException
*/
*/
public
void
deleteEntities
(
Collection
<
AtlasVertex
>
instanceVertices
)
throws
AtlasBaseException
{
public
void
deleteEntities
(
Collection
<
AtlasVertex
>
instanceVertices
)
throws
AtlasBaseException
{
RequestContext
requestContext
=
RequestContext
.
get
();
final
RequestContext
requestContext
=
RequestContext
.
get
();
Set
<
AtlasVertex
>
deletionCandidateVertices
=
new
HashSet
<>();
final
Set
<
AtlasVertex
>
deletionCandidateVertices
=
new
HashSet
<>();
final
boolean
isPurgeRequested
=
requestContext
.
isPurgeRequested
();
for
(
AtlasVertex
instanceVertex
:
instanceVertices
)
{
for
(
AtlasVertex
instanceVertex
:
instanceVertices
)
{
String
guid
=
AtlasGraphUtilsV2
.
getIdFromVertex
(
instanceVertex
);
final
String
guid
=
AtlasGraphUtilsV2
.
getIdFromVertex
(
instanceVertex
);
AtlasEntity
.
Status
state
=
getState
(
instanceVertex
);
final
AtlasEntity
.
Status
state
=
getState
(
instanceVertex
);
final
boolean
needToSkip
;
boolean
needToSkip
=
requestContext
.
isPurgeRequested
()
?
(
state
==
ACTIVE
||
requestContext
.
isPurgedEntity
(
guid
))
:
if
(
isPurgeRequested
)
{
(
state
==
DELETED
||
requestContext
.
isDeletedEntity
(
guid
));
needToSkip
=
state
==
ACTIVE
||
requestContext
.
isPurgedEntity
(
guid
);
}
else
{
needToSkip
=
state
==
DELETED
||
requestContext
.
isDeletedEntity
(
guid
);
}
if
(
needToSkip
)
{
if
(
needToSkip
)
{
if
(
LOG
.
isDebugEnabled
())
{
if
(
LOG
.
isDebugEnabled
())
{
if
(
RequestContext
.
get
().
isPurgeRequested
()
)
{
if
(
isPurgeRequested
)
{
LOG
.
debug
(
"Skipping purging of {} as it is active or already purged"
,
guid
);
LOG
.
debug
(
"Skipping purging of
entity=
{} as it is active or already purged"
,
guid
);
}
else
{
}
else
{
LOG
.
debug
(
"Skipping deletion of {} as it is already deleted"
,
guid
);
LOG
.
debug
(
"Skipping deletion of
entity=
{} as it is already deleted"
,
guid
);
}
}
}
}
...
@@ -154,16 +159,18 @@ public abstract class DeleteHandlerV1 {
...
@@ -154,16 +159,18 @@ public abstract class DeleteHandlerV1 {
* @throws AtlasBaseException
* @throws AtlasBaseException
*/
*/
public
void
deleteRelationships
(
Collection
<
AtlasEdge
>
edges
,
final
boolean
forceDelete
)
throws
AtlasBaseException
{
public
void
deleteRelationships
(
Collection
<
AtlasEdge
>
edges
,
final
boolean
forceDelete
)
throws
AtlasBaseException
{
final
boolean
isPurgeRequested
=
RequestContext
.
get
().
isPurgeRequested
();
for
(
AtlasEdge
edge
:
edges
)
{
for
(
AtlasEdge
edge
:
edges
)
{
boolean
isInternal
=
isInternalType
(
edge
.
getInVertex
())
&&
isInternalType
(
edge
.
getOutVertex
());
boolean
isInternal
=
isInternalType
(
edge
.
getInVertex
())
&&
isInternalType
(
edge
.
getOutVertex
());
boolean
needToSkip
=
!
isInternal
&&
(
RequestContext
.
get
().
isPurgeRequested
()
?
getState
(
edge
)
==
ACTIVE
:
getState
(
edge
)
==
DELETED
);
boolean
needToSkip
=
!
isInternal
&&
(
getState
(
edge
)
==
(
isPurgeRequested
?
ACTIVE
:
DELETED
)
);
if
(
needToSkip
)
{
if
(
needToSkip
)
{
if
(
LOG
.
isDebugEnabled
())
{
if
(
LOG
.
isDebugEnabled
())
{
if
(
RequestContext
.
get
().
isPurgeRequested
()
)
{
if
(
isPurgeRequested
)
{
LOG
.
debug
(
"Skipping purging of {} as it is active or already purged"
,
getIdFromEdge
(
edge
));
LOG
.
debug
(
"Skipping purging of
edge=
{} as it is active or already purged"
,
getIdFromEdge
(
edge
));
}
else
{
}
else
{
LOG
.
debug
(
"Skipping deletion of {} as it is already deleted"
,
getIdFromEdge
(
edge
));
LOG
.
debug
(
"Skipping deletion of
edge=
{} as it is already deleted"
,
getIdFromEdge
(
edge
));
}
}
}
}
...
@@ -186,8 +193,9 @@ public abstract class DeleteHandlerV1 {
...
@@ -186,8 +193,9 @@ public abstract class DeleteHandlerV1 {
* @throws AtlasException
* @throws AtlasException
*/
*/
public
Collection
<
GraphHelper
.
VertexInfo
>
getOwnedVertices
(
AtlasVertex
entityVertex
)
throws
AtlasBaseException
{
public
Collection
<
GraphHelper
.
VertexInfo
>
getOwnedVertices
(
AtlasVertex
entityVertex
)
throws
AtlasBaseException
{
Map
<
String
,
GraphHelper
.
VertexInfo
>
vertexInfoMap
=
new
HashMap
<>();
final
Map
<
String
,
GraphHelper
.
VertexInfo
>
vertexInfoMap
=
new
HashMap
<>();
Stack
<
AtlasVertex
>
vertices
=
new
Stack
<>();
final
Stack
<
AtlasVertex
>
vertices
=
new
Stack
<>();
final
boolean
isPurgeRequested
=
RequestContext
.
get
().
isPurgeRequested
();
vertices
.
push
(
entityVertex
);
vertices
.
push
(
entityVertex
);
...
@@ -197,8 +205,7 @@ public abstract class DeleteHandlerV1 {
...
@@ -197,8 +205,7 @@ public abstract class DeleteHandlerV1 {
//In case of purge If the reference vertex is active then skip it or else
//In case of purge If the reference vertex is active then skip it or else
//If the vertex marked for deletion, skip it
//If the vertex marked for deletion, skip it
boolean
needToSkip
=
RequestContext
.
get
().
isPurgeRequested
()
?
(
state
==
ACTIVE
)
:
(
state
==
DELETED
);
if
(
state
==
(
isPurgeRequested
?
ACTIVE
:
DELETED
))
{
if
(
needToSkip
)
{
continue
;
continue
;
}
}
...
@@ -235,9 +242,7 @@ public abstract class DeleteHandlerV1 {
...
@@ -235,9 +242,7 @@ public abstract class DeleteHandlerV1 {
}
else
{
}
else
{
AtlasEdge
edge
=
graphHelper
.
getEdgeForLabel
(
vertex
,
edgeLabel
);
AtlasEdge
edge
=
graphHelper
.
getEdgeForLabel
(
vertex
,
edgeLabel
);
needToSkip
=
(
edge
==
null
||
RequestContext
.
get
().
isPurgeRequested
()
?
if
(
edge
==
null
||
(
getState
(
edge
)
==
(
isPurgeRequested
?
ACTIVE
:
DELETED
)))
{
getState
(
edge
)
==
ACTIVE
:
getState
(
edge
)
==
DELETED
);
if
(
needToSkip
)
{
continue
;
continue
;
}
}
...
@@ -290,9 +295,7 @@ public abstract class DeleteHandlerV1 {
...
@@ -290,9 +295,7 @@ public abstract class DeleteHandlerV1 {
if
(
CollectionUtils
.
isNotEmpty
(
edges
))
{
if
(
CollectionUtils
.
isNotEmpty
(
edges
))
{
for
(
AtlasEdge
edge
:
edges
)
{
for
(
AtlasEdge
edge
:
edges
)
{
needToSkip
=
(
edge
==
null
||
RequestContext
.
get
().
isPurgeRequested
()
?
if
(
edge
==
null
||
(
getState
(
edge
)
==
(
isPurgeRequested
?
ACTIVE
:
DELETED
)))
{
getState
(
edge
)
==
ACTIVE
:
getState
(
edge
)
==
DELETED
);
if
(
needToSkip
)
{
continue
;
continue
;
}
}
...
@@ -852,12 +855,17 @@ public abstract class DeleteHandlerV1 {
...
@@ -852,12 +855,17 @@ public abstract class DeleteHandlerV1 {
LOG
.
debug
(
"Removing edge from {} to {} with attribute name {}"
,
string
(
outVertex
),
string
(
inVertex
),
attribute
.
getName
());
LOG
.
debug
(
"Removing edge from {} to {} with attribute name {}"
,
string
(
outVertex
),
string
(
inVertex
),
attribute
.
getName
());
}
}
final
RequestContext
requestContext
=
RequestContext
.
get
();
final
String
typeName
=
GraphHelper
.
getTypeName
(
outVertex
);
final
String
typeName
=
GraphHelper
.
getTypeName
(
outVertex
);
final
String
outId
=
GraphHelper
.
getGuid
(
outVertex
);
final
String
outId
=
GraphHelper
.
getGuid
(
outVertex
);
final
Status
state
=
getState
(
outVertex
);
final
Status
state
=
getState
(
outVertex
);
final
boolean
needToSkip
;
boolean
needToSkip
=
RequestContext
.
get
().
isPurgeRequested
()
?
state
==
ACTIVE
||
(
outId
!=
null
&&
RequestContext
.
get
().
isPurgedEntity
(
outId
))
:
if
(
requestContext
.
isPurgeRequested
())
{
state
==
DELETED
||
(
outId
!=
null
&&
RequestContext
.
get
().
isDeletedEntity
(
outId
));
needToSkip
=
state
==
ACTIVE
||
(
outId
!=
null
&&
requestContext
.
isPurgedEntity
(
outId
));
}
else
{
needToSkip
=
state
==
DELETED
||
(
outId
!=
null
&&
requestContext
.
isDeletedEntity
(
outId
));
}
if
(
needToSkip
)
{
if
(
needToSkip
)
{
return
;
return
;
...
@@ -952,8 +960,6 @@ public abstract class DeleteHandlerV1 {
...
@@ -952,8 +960,6 @@ public abstract class DeleteHandlerV1 {
if
(
edge
!=
null
)
{
if
(
edge
!=
null
)
{
deleteEdge
(
edge
,
isInternalType
(
inVertex
)
&&
isInternalType
(
outVertex
));
deleteEdge
(
edge
,
isInternalType
(
inVertex
)
&&
isInternalType
(
outVertex
));
RequestContext
requestContext
=
RequestContext
.
get
();
if
(!
requestContext
.
isUpdatedEntity
(
outId
))
{
if
(!
requestContext
.
isUpdatedEntity
(
outId
))
{
AtlasGraphUtilsV2
.
setEncodedProperty
(
outVertex
,
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
requestContext
.
getRequestTime
());
AtlasGraphUtilsV2
.
setEncodedProperty
(
outVertex
,
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
requestContext
.
getRequestTime
());
AtlasGraphUtilsV2
.
setEncodedProperty
(
outVertex
,
MODIFIED_BY_KEY
,
requestContext
.
getUser
());
AtlasGraphUtilsV2
.
setEncodedProperty
(
outVertex
,
MODIFIED_BY_KEY
,
requestContext
.
getUser
());
...
@@ -969,12 +975,13 @@ public abstract class DeleteHandlerV1 {
...
@@ -969,12 +975,13 @@ public abstract class DeleteHandlerV1 {
}
}
// Delete external references to this vertex - incoming edges from lineage or glossary term edges
// Delete external references to this vertex - incoming edges from lineage or glossary term edges
Iterable
<
AtlasEdge
>
incomingEdges
=
instanceVertex
.
getEdges
(
AtlasEdgeDirection
.
IN
);
final
Iterable
<
AtlasEdge
>
incomingEdges
=
instanceVertex
.
getEdges
(
AtlasEdgeDirection
.
IN
);
final
boolean
isPurgeRequested
=
RequestContext
.
get
().
isPurgeRequested
();
for
(
AtlasEdge
edge
:
incomingEdges
)
{
for
(
AtlasEdge
edge
:
incomingEdges
)
{
Status
edgeState
=
getState
(
edge
);
AtlasEntity
.
Status
edgeStatus
=
getStatus
(
edge
);
boolean
isProceed
=
edgeStatus
==
(
isPurgeRequested
?
DELETED
:
ACTIVE
);
boolean
isProceed
=
RequestContext
.
get
().
isPurgeRequested
()?
edgeState
==
DELETED
:
edgeState
==
ACTIVE
;
if
(
isProceed
)
{
if
(
isProceed
)
{
if
(
isRelationshipEdge
(
edge
))
{
if
(
isRelationshipEdge
(
edge
))
{
deleteRelationship
(
edge
);
deleteRelationship
(
edge
);
...
...
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