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
f687fb7d
Commit
f687fb7d
authored
Oct 24, 2019
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3492: updated object-id attributes in audit logs to replace…
ATLAS-3492: updated object-id attributes in audit logs to replace unassigned-guids with assigned-guids
parent
c04c0ab3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
10 deletions
+91
-10
EntityGraphMapper.java
...he/atlas/repository/store/graph/v2/EntityGraphMapper.java
+56
-6
RequestContext.java
...er-api/src/main/java/org/apache/atlas/RequestContext.java
+35
-4
No files found.
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java
View file @
f687fb7d
...
...
@@ -597,6 +597,8 @@ public class EntityGraphMapper {
true
,
ctx
.
getAttribute
().
getRelationshipEdgeDirection
(),
ctx
.
getReferringVertex
());
}
setAssignedGuid
(
ctx
.
getValue
(),
context
.
getGuidAssignments
());
return
newEdge
;
}
...
...
@@ -626,6 +628,8 @@ public class EntityGraphMapper {
}
}
setAssignedGuid
(
ctx
.
getValue
(),
context
.
getGuidAssignments
());
return
ret
;
}
...
...
@@ -886,10 +890,16 @@ public class EntityGraphMapper {
AtlasVertex
entityVertex
=
context
.
getDiscoveryContext
().
getResolvedEntityVertex
(
guid
);
if
(
entityVertex
==
null
)
{
AtlasObjectId
objId
=
getObjectId
(
ctx
.
getValue
());
if
(
AtlasTypeUtil
.
isAssignedGuid
(
guid
))
{
entityVertex
=
context
.
getVertex
(
guid
);
}
if
(
entityVertex
==
null
)
{
AtlasObjectId
objId
=
getObjectId
(
ctx
.
getValue
());
if
(
objId
!=
null
)
{
entityVertex
=
context
.
getDiscoveryContext
().
getResolvedEntityVertex
(
objId
);
if
(
objId
!=
null
)
{
entityVertex
=
context
.
getDiscoveryContext
().
getResolvedEntityVertex
(
objId
);
}
}
}
...
...
@@ -921,14 +931,21 @@ public class EntityGraphMapper {
LOG
.
debug
(
"==> mapObjectIdValueUsingRelationship({})"
,
ctx
);
}
AtlasVertex
attributeVertex
=
context
.
getDiscoveryContext
().
getResolvedEntityVertex
(
getGuid
(
ctx
.
getValue
()));
String
guid
=
getGuid
(
ctx
.
getValue
());
AtlasVertex
attributeVertex
=
context
.
getDiscoveryContext
().
getResolvedEntityVertex
(
guid
);
AtlasVertex
entityVertex
=
ctx
.
getReferringVertex
();
AtlasEdge
ret
;
if
(
attributeVertex
==
null
)
{
AtlasObjectId
objectId
=
getObjectId
(
ctx
.
getValue
());
if
(
AtlasTypeUtil
.
isAssignedGuid
(
guid
))
{
attributeVertex
=
context
.
getVertex
(
guid
);
}
if
(
attributeVertex
==
null
)
{
AtlasObjectId
objectId
=
getObjectId
(
ctx
.
getValue
());
attributeVertex
=
(
objectId
!=
null
)
?
context
.
getDiscoveryContext
().
getResolvedEntityVertex
(
objectId
)
:
null
;
attributeVertex
=
(
objectId
!=
null
)
?
context
.
getDiscoveryContext
().
getResolvedEntityVertex
(
objectId
)
:
null
;
}
}
if
(
attributeVertex
==
null
)
{
...
...
@@ -1287,6 +1304,39 @@ public class EntityGraphMapper {
return
null
;
}
private
static
void
setAssignedGuid
(
Object
val
,
Map
<
String
,
String
>
guidAssignements
)
{
if
(
val
!=
null
&&
MapUtils
.
isNotEmpty
(
guidAssignements
))
{
if
(
val
instanceof
AtlasObjectId
)
{
AtlasObjectId
objId
=
(
AtlasObjectId
)
val
;
String
guid
=
objId
.
getGuid
();
if
(
StringUtils
.
isNotEmpty
(
guid
)
&&
!
AtlasTypeUtil
.
isAssignedGuid
(
guid
))
{
String
assignedGuid
=
guidAssignements
.
get
(
guid
);
if
(
StringUtils
.
isNotEmpty
(
assignedGuid
))
{
RequestContext
.
get
().
recordEntityGuidUpdate
(
objId
,
guid
);
objId
.
setGuid
(
assignedGuid
);
}
}
}
else
if
(
val
instanceof
Map
)
{
Map
objId
=
(
Map
)
val
;
Object
guidVal
=
objId
.
get
(
AtlasObjectId
.
KEY_GUID
);
String
guid
=
objId
!=
null
?
guidVal
.
toString
()
:
null
;
if
(
StringUtils
.
isNotEmpty
(
guid
)
&&
!
AtlasTypeUtil
.
isAssignedGuid
(
guid
))
{
String
assignedGuid
=
guidAssignements
.
get
(
guid
);
if
(
StringUtils
.
isNotEmpty
(
assignedGuid
))
{
RequestContext
.
get
().
recordEntityGuidUpdate
(
objId
,
guid
);
objId
.
put
(
AtlasObjectId
.
KEY_GUID
,
assignedGuid
);
}
}
}
}
}
private
static
Map
<
String
,
Object
>
getRelationshipAttributes
(
Object
val
)
throws
AtlasBaseException
{
if
(
val
instanceof
AtlasRelatedObjectId
)
{
AtlasStruct
relationshipStruct
=
((
AtlasRelatedObjectId
)
val
).
getRelationshipAttributes
();
...
...
server-api/src/main/java/org/apache/atlas/RequestContext.java
View file @
f687fb7d
...
...
@@ -22,6 +22,7 @@ import org.apache.atlas.model.instance.AtlasClassification;
import
org.apache.atlas.model.instance.AtlasEntity
;
import
org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo
;
import
org.apache.atlas.model.instance.AtlasEntityHeader
;
import
org.apache.atlas.model.instance.AtlasObjectId
;
import
org.apache.atlas.store.DeleteType
;
import
org.apache.atlas.utils.AtlasPerfMetrics
;
import
org.apache.atlas.utils.AtlasPerfMetrics.MetricRecorder
;
...
...
@@ -37,6 +38,8 @@ import java.util.ArrayList;
import
java.util.HashSet
;
import
java.util.HashMap
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
AtlasObjectId
.
KEY_GUID
;
public
class
RequestContext
{
private
static
final
Logger
METRICS
=
LoggerFactory
.
getLogger
(
"METRICS"
);
...
...
@@ -337,11 +340,23 @@ public class RequestContext {
}
public
void
recordEntityGuidUpdate
(
AtlasEntity
entity
,
String
guidInRequest
)
{
recordEntityGuidUpdate
(
new
EntityGuidPair
(
entity
,
guidInRequest
));
}
public
void
recordEntityGuidUpdate
(
AtlasObjectId
entity
,
String
guidInRequest
)
{
recordEntityGuidUpdate
(
new
EntityGuidPair
(
entity
,
guidInRequest
));
}
public
void
recordEntityGuidUpdate
(
Map
entity
,
String
guidInRequest
)
{
recordEntityGuidUpdate
(
new
EntityGuidPair
(
entity
,
guidInRequest
));
}
public
void
recordEntityGuidUpdate
(
EntityGuidPair
record
)
{
if
(
entityGuidInRequest
==
null
)
{
entityGuidInRequest
=
new
ArrayList
<>();
}
entityGuidInRequest
.
add
(
new
EntityGuidPair
(
entity
,
guidInRequest
)
);
entityGuidInRequest
.
add
(
record
);
}
public
void
resetEntityGuidUpdates
()
{
...
...
@@ -353,16 +368,32 @@ public class RequestContext {
}
public
class
EntityGuidPair
{
private
final
AtlasEntity
entity
;
private
final
String
guid
;
private
final
Object
entity
;
private
final
String
guid
;
public
EntityGuidPair
(
AtlasEntity
entity
,
String
guid
)
{
this
.
entity
=
entity
;
this
.
guid
=
guid
;
}
public
EntityGuidPair
(
AtlasObjectId
entity
,
String
guid
)
{
this
.
entity
=
entity
;
this
.
guid
=
guid
;
}
public
EntityGuidPair
(
Map
entity
,
String
guid
)
{
this
.
entity
=
entity
;
this
.
guid
=
guid
;
}
public
void
resetEntityGuid
()
{
entity
.
setGuid
(
guid
);
if
(
entity
instanceof
AtlasEntity
)
{
((
AtlasEntity
)
entity
).
setGuid
(
guid
);
}
else
if
(
entity
instanceof
AtlasObjectId
)
{
((
AtlasObjectId
)
entity
).
setGuid
(
guid
);
}
else
if
(
entity
instanceof
Map
)
{
((
Map
)
entity
).
put
(
KEY_GUID
,
guid
);
}
}
}
...
...
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