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
d343a486
Commit
d343a486
authored
May 22, 2018
by
Sarath Subramanian
Committed by
Madhan Neethiraj
May 22, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2712: Update v2 Audit API to handle v1 to v2 conversion
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
47ec9f7a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
300 additions
and
87 deletions
+300
-87
EntityAuditEventV2.java
...java/org/apache/atlas/model/audit/EntityAuditEventV2.java
+36
-15
AbstractStorageBasedAuditRepository.java
...repository/audit/AbstractStorageBasedAuditRepository.java
+9
-10
CassandraBasedAuditRepository.java
...atlas/repository/audit/CassandraBasedAuditRepository.java
+1
-3
EntityAuditListener.java
...rg/apache/atlas/repository/audit/EntityAuditListener.java
+40
-2
EntityAuditListenerV2.java
.../apache/atlas/repository/audit/EntityAuditListenerV2.java
+58
-18
HBaseBasedAuditRepository.java
...che/atlas/repository/audit/HBaseBasedAuditRepository.java
+134
-17
AtlasInstanceConverter.java
...e/atlas/repository/converters/AtlasInstanceConverter.java
+14
-14
AtlasEntityChangeNotifier.java
.../repository/store/graph/v1/AtlasEntityChangeNotifier.java
+4
-4
AuditRepositoryTestBase.java
...pache/atlas/repository/audit/AuditRepositoryTestBase.java
+4
-4
No files found.
intg/src/main/java/org/apache/atlas/model/audit/EntityAuditEventV2.java
View file @
d343a486
...
...
@@ -32,6 +32,7 @@ import java.util.Objects;
import
static
com
.
fasterxml
.
jackson
.
annotation
.
JsonAutoDetect
.
Visibility
.
NONE
;
import
static
com
.
fasterxml
.
jackson
.
annotation
.
JsonAutoDetect
.
Visibility
.
PUBLIC_ONLY
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditType
.
ENTITY_AUDIT_V2
;
/**
* Structure of v2 entity audit event
...
...
@@ -42,13 +43,15 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
@XmlRootElement
@XmlAccessorType
(
XmlAccessType
.
PROPERTY
)
public
class
EntityAuditEventV2
implements
Serializable
{
public
enum
EntityAuditAction
{
public
enum
EntityAuditType
{
ENTITY_AUDIT_V1
,
ENTITY_AUDIT_V2
}
public
enum
EntityAuditActionV2
{
ENTITY_CREATE
,
ENTITY_UPDATE
,
ENTITY_DELETE
,
ENTITY_IMPORT_CREATE
,
ENTITY_IMPORT_UPDATE
,
ENTITY_IMPORT_DELETE
,
CLASSIFICATION_ADD
,
CLASSIFICATION_DELETE
,
CLASSIFICATION_UPDATE
,
PROPAGATED_CLASSIFICATION_ADD
,
PROPAGATED_CLASSIFICATION_DELETE
,
PROPAGATED_CLASSIFICATION_UPDATE
;
public
static
EntityAuditAction
fromString
(
String
strValue
)
{
public
static
EntityAuditAction
V2
fromString
(
String
strValue
)
{
switch
(
strValue
)
{
case
"ENTITY_CREATE"
:
return
ENTITY_CREATE
;
...
...
@@ -79,28 +82,35 @@ public class EntityAuditEventV2 implements Serializable {
return
PROPAGATED_CLASSIFICATION_UPDATE
;
}
throw
new
IllegalArgumentException
(
"No enum constant "
+
EntityAuditAction
.
class
.
getCanonicalName
()
+
"."
+
strValue
);
throw
new
IllegalArgumentException
(
"No enum constant "
+
EntityAuditAction
V2
.
class
.
getCanonicalName
()
+
"."
+
strValue
);
}
}
private
String
entityId
;
private
long
timestamp
;
private
String
user
;
private
EntityAuditAction
action
;
private
String
details
;
private
String
eventKey
;
private
AtlasEntity
entity
;
private
String
entityId
;
private
long
timestamp
;
private
String
user
;
private
EntityAuditActionV2
action
;
private
String
details
;
private
String
eventKey
;
private
AtlasEntity
entity
;
private
EntityAuditType
type
;
public
EntityAuditEventV2
()
{
}
public
EntityAuditEventV2
(
String
entityId
,
long
timestamp
,
String
user
,
EntityAuditAction
action
,
String
details
,
public
EntityAuditEventV2
(
String
entityId
,
long
timestamp
,
String
user
,
EntityAuditAction
V2
action
,
String
details
,
AtlasEntity
entity
)
{
this
(
entityId
,
timestamp
,
user
,
action
,
details
,
entity
,
ENTITY_AUDIT_V2
);
}
public
EntityAuditEventV2
(
String
entityId
,
long
timestamp
,
String
user
,
EntityAuditActionV2
action
,
String
details
,
AtlasEntity
entity
,
EntityAuditType
auditType
)
{
setEntityId
(
entityId
);
setTimestamp
(
timestamp
);
setUser
(
user
);
setAction
(
action
);
setDetails
(
details
);
setEntity
(
entity
);
setType
(
auditType
);
}
public
String
getEntityId
()
{
...
...
@@ -127,11 +137,11 @@ public class EntityAuditEventV2 implements Serializable {
this
.
user
=
user
;
}
public
EntityAuditAction
getAction
()
{
public
EntityAuditAction
V2
getAction
()
{
return
action
;
}
public
void
setAction
(
EntityAuditAction
action
)
{
public
void
setAction
(
EntityAuditAction
V2
action
)
{
this
.
action
=
action
;
}
...
...
@@ -159,6 +169,14 @@ public class EntityAuditEventV2 implements Serializable {
this
.
entity
=
entity
;
}
public
EntityAuditType
getType
()
{
return
type
;
}
public
void
setType
(
EntityAuditType
type
)
{
this
.
type
=
type
;
}
@JsonIgnore
public
String
getEntityDefinitionString
()
{
if
(
entity
!=
null
)
{
...
...
@@ -185,17 +203,19 @@ public class EntityAuditEventV2 implements Serializable {
action
==
that
.
action
&&
Objects
.
equals
(
details
,
that
.
details
)
&&
Objects
.
equals
(
eventKey
,
that
.
eventKey
)
&&
Objects
.
equals
(
entity
,
that
.
entity
);
Objects
.
equals
(
entity
,
that
.
entity
)
&&
Objects
.
equals
(
type
,
that
.
type
);
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
entityId
,
timestamp
,
user
,
action
,
details
,
eventKey
,
entity
);
return
Objects
.
hash
(
entityId
,
timestamp
,
user
,
action
,
details
,
eventKey
,
entity
,
type
);
}
@Override
public
String
toString
()
{
final
StringBuilder
sb
=
new
StringBuilder
(
"EntityAuditEventV2{"
);
sb
.
append
(
"entityId='"
).
append
(
entityId
).
append
(
'\''
);
sb
.
append
(
", timestamp="
).
append
(
timestamp
);
sb
.
append
(
", user='"
).
append
(
user
).
append
(
'\''
);
...
...
@@ -203,6 +223,7 @@ public class EntityAuditEventV2 implements Serializable {
sb
.
append
(
", details='"
).
append
(
details
).
append
(
'\''
);
sb
.
append
(
", eventKey='"
).
append
(
eventKey
).
append
(
'\''
);
sb
.
append
(
", entity="
).
append
(
entity
);
sb
.
append
(
", type="
).
append
(
type
);
sb
.
append
(
'}'
);
return
sb
.
toString
();
...
...
repository/src/main/java/org/apache/atlas/repository/audit/AbstractStorageBasedAuditRepository.java
View file @
d343a486
...
...
@@ -42,17 +42,16 @@ import java.util.Map;
public
abstract
class
AbstractStorageBasedAuditRepository
implements
Service
,
EntityAuditRepository
,
ActiveStateChangeHandler
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
HBaseBasedAuditRepository
.
class
);
private
static
final
String
AUDIT_REPOSITORY_MAX_SIZE_PROPERTY
=
"atlas.hbase.client.keyvalue.maxsize"
;
private
static
final
String
AUDIT_EXCLUDE_ATTRIBUTE_PROPERTY
=
"atlas.audit.hbase.entity"
;
pr
otected
static
final
String
FIELD_SEPARATOR
=
":"
;
p
rivate
static
final
long
ATLAS_HBASE_KEYVALUE_DEFAULT_SIZE
=
1024
*
1024
;
p
rotected
static
Configuration
APPLICATION_PROPERTIES
=
null
;
p
ublic
static
final
String
CONFIG_PREFIX
=
"atlas.audit
"
;
public
static
final
String
CONFIG_PERSIST_ENTITY_DEFINITION
=
CONFIG_PREFIX
+
".persistEntityDefinition"
;
private
static
final
String
AUDIT_REPOSITORY_MAX_SIZE_PROPERTY
=
"atlas.hbase.client.keyvalue.maxsize"
;
private
static
final
String
AUDIT_EXCLUDE_ATTRIBUTE_PROPERTY
=
"atlas.audit.hbase.entity"
;
pr
ivate
static
final
long
ATLAS_HBASE_KEYVALUE_DEFAULT_SIZE
=
1024
*
1024
;
p
ublic
static
final
String
CONFIG_PREFIX
=
"atlas.audit"
;
p
ublic
static
final
String
CONFIG_PERSIST_ENTITY_DEFINITION
=
CONFIG_PREFIX
+
".persistEntityDefinition"
;
p
rotected
static
final
String
FIELD_SEPARATOR
=
":
"
;
protected
static
Configuration
APPLICATION_PROPERTIES
=
null
;
protected
Map
<
String
,
List
<
String
>>
auditExcludedAttributesCache
=
new
HashMap
<>();
protected
static
boolean
persistEntityDefinition
;
protected
static
boolean
persistEntityDefinition
;
static
{
try
{
...
...
repository/src/main/java/org/apache/atlas/repository/audit/CassandraBasedAuditRepository.java
View file @
d343a486
...
...
@@ -25,13 +25,11 @@ import com.datastax.driver.core.ResultSet;
import
com.datastax.driver.core.Row
;
import
com.datastax.driver.core.Session
;
import
com.google.common.annotations.VisibleForTesting
;
import
org.apache.atlas.ApplicationProperties
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.EntityAuditEvent
;
import
org.apache.atlas.annotation.ConditionalOnAtlasProperty
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.audit.EntityAuditEventV2
;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -176,7 +174,7 @@ public class CassandraBasedAuditRepository extends AbstractStorageBasedAuditRepo
}
EntityAuditEventV2
event
=
new
EntityAuditEventV2
();
event
.
setEntityId
(
rowEntityId
);
event
.
setAction
(
EntityAuditEventV2
.
EntityAuditAction
.
fromString
(
row
.
getString
(
ACTION
)));
event
.
setAction
(
EntityAuditEventV2
.
EntityAuditAction
V2
.
fromString
(
row
.
getString
(
ACTION
)));
event
.
setDetails
(
row
.
getString
(
DETAIL
));
event
.
setUser
(
row
.
getString
(
USER
));
event
.
setTimestamp
(
row
.
getLong
(
CREATED
));
...
...
repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java
View file @
d343a486
...
...
@@ -146,7 +146,7 @@ public class EntityAuditListener implements EntityChangeListener {
private
String
getAuditEventDetail
(
Referenceable
entity
,
EntityAuditAction
action
)
throws
AtlasException
{
Map
<
String
,
Object
>
prunedAttributes
=
pruneEntityAttributesForAudit
(
entity
);
String
auditPrefix
=
getAuditPrefix
(
action
);
String
auditPrefix
=
get
V1
AuditPrefix
(
action
);
String
auditString
=
auditPrefix
+
AtlasType
.
toV1Json
(
entity
);
byte
[]
auditBytes
=
auditString
.
getBytes
(
StandardCharsets
.
UTF_8
);
long
auditSize
=
auditBytes
!=
null
?
auditBytes
.
length
:
0
;
...
...
@@ -259,7 +259,7 @@ public class EntityAuditListener implements EntityChangeListener {
}
}
p
rivate
String
get
AuditPrefix
(
EntityAuditAction
action
)
{
p
ublic
static
String
getV1
AuditPrefix
(
EntityAuditAction
action
)
{
final
String
ret
;
switch
(
action
)
{
...
...
@@ -296,4 +296,42 @@ public class EntityAuditListener implements EntityChangeListener {
return
ret
;
}
public
static
String
getV2AuditPrefix
(
EntityAuditAction
action
)
{
final
String
ret
;
switch
(
action
)
{
case
ENTITY_CREATE:
ret
=
"Created: "
;
break
;
case
ENTITY_UPDATE:
ret
=
"Updated: "
;
break
;
case
ENTITY_DELETE:
ret
=
"Deleted: "
;
break
;
case
TAG_ADD:
ret
=
"Added classification: "
;
break
;
case
TAG_DELETE:
ret
=
"Deleted classification: "
;
break
;
case
TAG_UPDATE:
ret
=
"Updated classification: "
;
break
;
case
ENTITY_IMPORT_CREATE:
ret
=
"Created by import: "
;
break
;
case
ENTITY_IMPORT_UPDATE:
ret
=
"Updated by import: "
;
break
;
case
ENTITY_IMPORT_DELETE:
ret
=
"Deleted by import: "
;
break
;
default
:
ret
=
"Unknown: "
;
}
return
ret
;
}
}
repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListenerV2.java
View file @
d343a486
...
...
@@ -17,9 +17,11 @@
*/
package
org
.
apache
.
atlas
.
repository
.
audit
;
import
org.apache.atlas.EntityAuditEvent
;
import
org.apache.atlas.EntityAuditEvent.EntityAuditAction
;
import
org.apache.atlas.RequestContextV1
;
import
org.apache.atlas.model.audit.EntityAuditEventV2
;
import
org.apache.atlas.model.audit.EntityAuditEventV2.EntityAuditAction
;
import
org.apache.atlas.model.audit.EntityAuditEventV2.EntityAuditAction
V2
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.listener.EntityChangeListenerV2
;
import
org.apache.atlas.model.instance.AtlasClassification
;
...
...
@@ -42,18 +44,18 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
.
CLASSIFICATION_ADD
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
.
CLASSIFICATION_DELETE
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
.
CLASSIFICATION_UPDATE
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
.
ENTITY_CREATE
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
.
ENTITY_DELETE
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
.
ENTITY_IMPORT_CREATE
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
.
ENTITY_IMPORT_DELETE
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
.
ENTITY_IMPORT_UPDATE
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
.
ENTITY_UPDATE
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
.
PROPAGATED_CLASSIFICATION_ADD
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
.
PROPAGATED_CLASSIFICATION_DELETE
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
.
PROPAGATED_CLASSIFICATION_UPDATE
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
V2
.
CLASSIFICATION_ADD
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
V2
.
CLASSIFICATION_DELETE
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
V2
.
CLASSIFICATION_UPDATE
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
V2
.
ENTITY_CREATE
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
V2
.
ENTITY_DELETE
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
V2
.
ENTITY_IMPORT_CREATE
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
V2
.
ENTITY_IMPORT_DELETE
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
V2
.
ENTITY_IMPORT_UPDATE
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
V2
.
ENTITY_UPDATE
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
V2
.
PROPAGATED_CLASSIFICATION_ADD
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
V2
.
PROPAGATED_CLASSIFICATION_DELETE
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
V2
.
PROPAGATED_CLASSIFICATION_UPDATE
;
@Component
public
class
EntityAuditListenerV2
implements
EntityChangeListenerV2
{
...
...
@@ -165,21 +167,21 @@ public class EntityAuditListenerV2 implements EntityChangeListenerV2 {
}
}
private
EntityAuditEventV2
createEvent
(
AtlasEntity
entity
,
EntityAuditAction
action
,
String
details
)
{
private
EntityAuditEventV2
createEvent
(
AtlasEntity
entity
,
EntityAuditAction
V2
action
,
String
details
)
{
return
new
EntityAuditEventV2
(
entity
.
getGuid
(),
RequestContextV1
.
get
().
getRequestTime
(),
RequestContextV1
.
get
().
getUser
(),
action
,
details
,
entity
);
}
private
EntityAuditEventV2
createEvent
(
AtlasEntity
entity
,
EntityAuditAction
action
)
{
private
EntityAuditEventV2
createEvent
(
AtlasEntity
entity
,
EntityAuditAction
V2
action
)
{
String
detail
=
getAuditEventDetail
(
entity
,
action
);
return
createEvent
(
entity
,
action
,
detail
);
}
private
String
getAuditEventDetail
(
AtlasEntity
entity
,
EntityAuditAction
action
)
{
private
String
getAuditEventDetail
(
AtlasEntity
entity
,
EntityAuditAction
V2
action
)
{
Map
<
String
,
Object
>
prunedAttributes
=
pruneEntityAttributesForAudit
(
entity
);
String
auditPrefix
=
getAuditPrefix
(
action
);
String
auditPrefix
=
get
V2
AuditPrefix
(
action
);
String
auditString
=
auditPrefix
+
AtlasType
.
toJson
(
entity
);
byte
[]
auditBytes
=
auditString
.
getBytes
(
StandardCharsets
.
UTF_8
);
long
auditSize
=
auditBytes
!=
null
?
auditBytes
.
length
:
0
;
...
...
@@ -277,7 +279,45 @@ public class EntityAuditListenerV2 implements EntityChangeListenerV2 {
}
}
private
String
getAuditPrefix
(
EntityAuditAction
action
)
{
private
String
getV1AuditPrefix
(
EntityAuditAction
action
)
{
final
String
ret
;
switch
(
action
)
{
case
ENTITY_CREATE:
ret
=
"Created: "
;
break
;
case
ENTITY_UPDATE:
ret
=
"Updated: "
;
break
;
case
ENTITY_DELETE:
ret
=
"Deleted: "
;
break
;
case
TAG_ADD:
ret
=
"Added classification: "
;
break
;
case
TAG_DELETE:
ret
=
"Deleted classification: "
;
break
;
case
TAG_UPDATE:
ret
=
"Updated classification: "
;
break
;
case
ENTITY_IMPORT_CREATE:
ret
=
"Created by import: "
;
break
;
case
ENTITY_IMPORT_UPDATE:
ret
=
"Updated by import: "
;
break
;
case
ENTITY_IMPORT_DELETE:
ret
=
"Deleted by import: "
;
break
;
default
:
ret
=
"Unknown: "
;
}
return
ret
;
}
private
String
getV2AuditPrefix
(
EntityAuditActionV2
action
)
{
final
String
ret
;
switch
(
action
)
{
...
...
repository/src/main/java/org/apache/atlas/repository/audit/HBaseBasedAuditRepository.java
View file @
d343a486
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
View file @
d343a486
...
...
@@ -348,7 +348,7 @@ public class AtlasInstanceConverter {
return
ret
;
}
private
EntityAuditEvent
.
EntityAuditAction
getV1AuditAction
(
EntityAuditEventV2
.
EntityAuditAction
v2AuditAction
)
{
private
EntityAuditEvent
.
EntityAuditAction
getV1AuditAction
(
EntityAuditEventV2
.
EntityAuditAction
V2
v2AuditAction
)
{
switch
(
v2AuditAction
)
{
case
ENTITY_CREATE:
return
EntityAuditEvent
.
EntityAuditAction
.
ENTITY_CREATE
;
...
...
@@ -379,32 +379,32 @@ public class AtlasInstanceConverter {
return
null
;
}
private
EntityAuditEventV2
.
EntityAuditAction
getV2AuditAction
(
EntityAuditEvent
.
EntityAuditAction
v1AuditAction
)
{
private
EntityAuditEventV2
.
EntityAuditAction
V2
getV2AuditAction
(
EntityAuditEvent
.
EntityAuditAction
v1AuditAction
)
{
switch
(
v1AuditAction
)
{
case
ENTITY_CREATE:
return
EntityAuditEventV2
.
EntityAuditAction
.
ENTITY_CREATE
;
return
EntityAuditEventV2
.
EntityAuditAction
V2
.
ENTITY_CREATE
;
case
ENTITY_UPDATE:
return
EntityAuditEventV2
.
EntityAuditAction
.
ENTITY_UPDATE
;
return
EntityAuditEventV2
.
EntityAuditAction
V2
.
ENTITY_UPDATE
;
case
ENTITY_DELETE:
return
EntityAuditEventV2
.
EntityAuditAction
.
ENTITY_DELETE
;
return
EntityAuditEventV2
.
EntityAuditAction
V2
.
ENTITY_DELETE
;
case
ENTITY_IMPORT_CREATE:
return
EntityAuditEventV2
.
EntityAuditAction
.
ENTITY_IMPORT_CREATE
;
return
EntityAuditEventV2
.
EntityAuditAction
V2
.
ENTITY_IMPORT_CREATE
;
case
ENTITY_IMPORT_UPDATE:
return
EntityAuditEventV2
.
EntityAuditAction
.
ENTITY_IMPORT_UPDATE
;
return
EntityAuditEventV2
.
EntityAuditAction
V2
.
ENTITY_IMPORT_UPDATE
;
case
ENTITY_IMPORT_DELETE:
return
EntityAuditEventV2
.
EntityAuditAction
.
ENTITY_IMPORT_DELETE
;
return
EntityAuditEventV2
.
EntityAuditAction
V2
.
ENTITY_IMPORT_DELETE
;
case
TAG_ADD:
return
EntityAuditEventV2
.
EntityAuditAction
.
CLASSIFICATION_ADD
;
return
EntityAuditEventV2
.
EntityAuditAction
V2
.
CLASSIFICATION_ADD
;
case
TAG_DELETE:
return
EntityAuditEventV2
.
EntityAuditAction
.
CLASSIFICATION_DELETE
;
return
EntityAuditEventV2
.
EntityAuditAction
V2
.
CLASSIFICATION_DELETE
;
case
TAG_UPDATE:
return
EntityAuditEventV2
.
EntityAuditAction
.
CLASSIFICATION_UPDATE
;
return
EntityAuditEventV2
.
EntityAuditAction
V2
.
CLASSIFICATION_UPDATE
;
case
PROPAGATED_TAG_ADD:
return
EntityAuditEventV2
.
EntityAuditAction
.
PROPAGATED_CLASSIFICATION_ADD
;
return
EntityAuditEventV2
.
EntityAuditAction
V2
.
PROPAGATED_CLASSIFICATION_ADD
;
case
PROPAGATED_TAG_DELETE:
return
EntityAuditEventV2
.
EntityAuditAction
.
PROPAGATED_CLASSIFICATION_DELETE
;
return
EntityAuditEventV2
.
EntityAuditAction
V2
.
PROPAGATED_CLASSIFICATION_DELETE
;
case
PROPAGATED_TAG_UPDATE:
return
EntityAuditEventV2
.
EntityAuditAction
.
PROPAGATED_CLASSIFICATION_UPDATE
;
return
EntityAuditEventV2
.
EntityAuditAction
V2
.
PROPAGATED_CLASSIFICATION_UPDATE
;
}
return
null
;
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityChangeNotifier.java
View file @
d343a486
...
...
@@ -24,7 +24,7 @@ import org.apache.atlas.RequestContextV1;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.listener.EntityChangeListener
;
import
org.apache.atlas.listener.EntityChangeListenerV2
;
import
org.apache.atlas.model.audit.EntityAuditEventV2.EntityAuditAction
;
import
org.apache.atlas.model.audit.EntityAuditEventV2.EntityAuditAction
V2
;
import
org.apache.atlas.model.instance.AtlasClassification
;
import
org.apache.atlas.model.instance.AtlasEntity
;
...
...
@@ -57,8 +57,8 @@ import java.util.Map;
import
java.util.Objects
;
import
java.util.Set
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
.
PROPAGATED_CLASSIFICATION_ADD
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
.
PROPAGATED_CLASSIFICATION_DELETE
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
V2
.
PROPAGATED_CLASSIFICATION_ADD
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditAction
V2
.
PROPAGATED_CLASSIFICATION_DELETE
;
import
static
org
.
apache
.
atlas
.
util
.
AtlasRepositoryConfiguration
.
isV2EntityNotificationEnabled
;
...
...
@@ -201,7 +201,7 @@ public class AtlasEntityChangeNotifier {
notifyPropagatedEntities
(
removedPropagations
,
PROPAGATED_CLASSIFICATION_DELETE
);
}
private
void
notifyPropagatedEntities
(
Map
<
String
,
List
<
AtlasClassification
>>
entityPropagationMap
,
EntityAuditAction
action
)
throws
AtlasBaseException
{
private
void
notifyPropagatedEntities
(
Map
<
String
,
List
<
AtlasClassification
>>
entityPropagationMap
,
EntityAuditAction
V2
action
)
throws
AtlasBaseException
{
if
(
MapUtils
.
isEmpty
(
entityPropagationMap
)
||
action
==
null
)
{
return
;
}
...
...
repository/src/test/java/org/apache/atlas/repository/audit/AuditRepositoryTestBase.java
View file @
d343a486
...
...
@@ -110,7 +110,7 @@ public class AuditRepositoryTestBase {
@Test
public
void
testAddEventsV2
()
throws
Exception
{
EntityAuditEventV2
event
=
new
EntityAuditEventV2
(
rand
(),
System
.
currentTimeMillis
(),
"u1"
,
EntityAuditEventV2
.
EntityAuditAction
.
ENTITY_CREATE
,
"d1"
,
new
AtlasEntity
(
rand
()));
EntityAuditEventV2
.
EntityAuditAction
V2
.
ENTITY_CREATE
,
"d1"
,
new
AtlasEntity
(
rand
()));
eventRepository
.
putEventsV2
(
event
);
...
...
@@ -131,12 +131,12 @@ public class AuditRepositoryTestBase {
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
//Add events for both ids
EntityAuditEventV2
event
=
new
EntityAuditEventV2
(
id2
,
ts
-
i
,
"user"
+
i
,
EntityAuditEventV2
.
EntityAuditAction
.
ENTITY_UPDATE
,
"details"
+
i
,
entity
);
EntityAuditEventV2
event
=
new
EntityAuditEventV2
(
id2
,
ts
-
i
,
"user"
+
i
,
EntityAuditEventV2
.
EntityAuditAction
V2
.
ENTITY_UPDATE
,
"details"
+
i
,
entity
);
eventRepository
.
putEventsV2
(
event
);
expectedEvents
.
add
(
event
);
eventRepository
.
putEventsV2
(
new
EntityAuditEventV2
(
id1
,
ts
-
i
,
"user"
+
i
,
EntityAuditEventV2
.
EntityAuditAction
.
ENTITY_DELETE
,
"details"
+
i
,
entity
));
eventRepository
.
putEventsV2
(
new
EntityAuditEventV2
(
id3
,
ts
-
i
,
"user"
+
i
,
EntityAuditEventV2
.
EntityAuditAction
.
ENTITY_CREATE
,
"details"
+
i
,
entity
));
eventRepository
.
putEventsV2
(
new
EntityAuditEventV2
(
id1
,
ts
-
i
,
"user"
+
i
,
EntityAuditEventV2
.
EntityAuditAction
V2
.
ENTITY_DELETE
,
"details"
+
i
,
entity
));
eventRepository
.
putEventsV2
(
new
EntityAuditEventV2
(
id3
,
ts
-
i
,
"user"
+
i
,
EntityAuditEventV2
.
EntityAuditAction
V2
.
ENTITY_CREATE
,
"details"
+
i
,
entity
));
}
//Use ts for which there is no event - ts + 2
...
...
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