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
1abd5a24
Commit
1abd5a24
authored
Aug 05, 2016
by
Suma Shivaprasad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1087 Provide an option to turn off persisting entity definition in audits…
ATLAS-1087 Provide an option to turn off persisting entity definition in audits (sumasai, shwethags)
parent
91072c10
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
5 deletions
+38
-5
release-log.txt
release-log.txt
+1
-0
HBaseBasedAuditRepository.java
...che/atlas/repository/audit/HBaseBasedAuditRepository.java
+24
-2
AuditRepositoryTestBase.java
...pache/atlas/repository/audit/AuditRepositoryTestBase.java
+2
-1
HBaseBasedAuditRepositoryTest.java
...atlas/repository/audit/HBaseBasedAuditRepositoryTest.java
+11
-2
No files found.
release-log.txt
View file @
1abd5a24
...
...
@@ -6,6 +6,7 @@ INCOMPATIBLE CHANGES:
ATLAS-1060 Add composite indexes for exact match performance improvements for all attributes (sumasai via shwethags)
ALL CHANGES:
ATLAS-1087 Provide an option to turn off persisting entity definition in audits (sumasai, shwethags)
ATLAS-1097 Fix a potential NPE issue flagged by Coverity scan (mneethiraj via shwethags)
ATLAS-1090 UI: Multi-Select Tagging. (Kalyanikashikar via kevalbhatt)
ATLAS-1092 Add Table.CreateTime to process qualified Name for all hive_process (sumasai via shwethags)
...
...
repository/src/main/java/org/apache/atlas/repository/audit/HBaseBasedAuditRepository.java
View file @
1abd5a24
...
...
@@ -74,12 +74,23 @@ public class HBaseBasedAuditRepository implements Service, EntityAuditRepository
private
static
final
String
FIELD_SEPARATOR
=
":"
;
public
static
final
String
CONFIG_PERSIST_ENTITY_DEFINITION
=
CONFIG_PREFIX
+
".persistEntityDefinition"
;
public
static
final
byte
[]
COLUMN_FAMILY
=
Bytes
.
toBytes
(
"dt"
);
public
static
final
byte
[]
COLUMN_ACTION
=
Bytes
.
toBytes
(
"action"
);
public
static
final
byte
[]
COLUMN_DETAIL
=
Bytes
.
toBytes
(
"detail"
);
public
static
final
byte
[]
COLUMN_USER
=
Bytes
.
toBytes
(
"user"
);
public
static
final
byte
[]
COLUMN_DEFINITION
=
Bytes
.
toBytes
(
"def"
);
private
static
boolean
persistEntityDefinition
;
static
{
try
{
persistEntityDefinition
=
ApplicationProperties
.
get
().
getBoolean
(
CONFIG_PERSIST_ENTITY_DEFINITION
,
false
);
}
catch
(
AtlasException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
private
TableName
tableName
;
private
Connection
connection
;
...
...
@@ -111,7 +122,9 @@ public class HBaseBasedAuditRepository implements Service, EntityAuditRepository
addColumn
(
put
,
COLUMN_ACTION
,
event
.
getAction
());
addColumn
(
put
,
COLUMN_USER
,
event
.
getUser
());
addColumn
(
put
,
COLUMN_DETAIL
,
event
.
getDetails
());
if
(
persistEntityDefinition
)
{
addColumn
(
put
,
COLUMN_DEFINITION
,
event
.
getEntityDefinitionString
());
}
puts
.
add
(
put
);
}
table
.
put
(
puts
);
...
...
@@ -185,7 +198,12 @@ public class HBaseBasedAuditRepository implements Service, EntityAuditRepository
event
.
setUser
(
getResultString
(
result
,
COLUMN_USER
));
event
.
setAction
(
EntityAuditEvent
.
EntityAuditAction
.
valueOf
(
getResultString
(
result
,
COLUMN_ACTION
)));
event
.
setDetails
(
getResultString
(
result
,
COLUMN_DETAIL
));
event
.
setEntityDefinition
(
getResultString
(
result
,
COLUMN_DEFINITION
));
if
(
persistEntityDefinition
)
{
String
colDef
=
getResultString
(
result
,
COLUMN_DEFINITION
);
if
(
colDef
!=
null
)
{
event
.
setEntityDefinition
(
colDef
);
}
}
events
.
add
(
event
);
}
LOG
.
info
(
"Got events for entity id {}, starting timestamp {}, #records {}"
,
entityId
,
startKey
,
events
.
size
());
...
...
@@ -199,7 +217,11 @@ public class HBaseBasedAuditRepository implements Service, EntityAuditRepository
}
private
String
getResultString
(
Result
result
,
byte
[]
columnName
)
{
return
Bytes
.
toString
(
result
.
getValue
(
COLUMN_FAMILY
,
columnName
));
byte
[]
rawValue
=
result
.
getValue
(
COLUMN_FAMILY
,
columnName
);
if
(
rawValue
!=
null
)
{
return
Bytes
.
toString
(
rawValue
);
}
return
null
;
}
private
EntityAuditEvent
fromKey
(
byte
[]
keyBytes
)
{
...
...
repository/src/test/java/org/apache/atlas/repository/audit/AuditRepositoryTestBase.java
View file @
1abd5a24
...
...
@@ -18,6 +18,7 @@
package
org
.
apache
.
atlas
.
repository
.
audit
;
import
junit.framework.Assert
;
import
org.apache.atlas.EntityAuditEvent
;
import
org.apache.atlas.typesystem.Referenceable
;
import
org.apache.commons.lang.RandomStringUtils
;
...
...
@@ -88,7 +89,7 @@ public class AuditRepositoryTestBase {
assertEquals
(
events
.
size
(),
0
);
}
pr
ivate
void
assertEventEquals
(
EntityAuditEvent
actual
,
EntityAuditEvent
expected
)
{
pr
otected
void
assertEventEquals
(
EntityAuditEvent
actual
,
EntityAuditEvent
expected
)
{
if
(
expected
!=
null
)
{
assertNotNull
(
actual
);
}
...
...
repository/src/test/java/org/apache/atlas/repository/audit/HBaseBasedAuditRepositoryTest.java
View file @
1abd5a24
...
...
@@ -19,6 +19,7 @@
package
org
.
apache
.
atlas
.
repository
.
audit
;
import
org.apache.atlas.ApplicationProperties
;
import
org.apache.atlas.EntityAuditEvent
;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.hadoop.hbase.TableName
;
import
org.apache.hadoop.hbase.client.Admin
;
...
...
@@ -27,6 +28,7 @@ import org.testng.annotations.AfterClass;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
import
static
org
.
testng
.
Assert
.
assertNull
;
import
static
org
.
testng
.
Assert
.
assertTrue
;
public
class
HBaseBasedAuditRepositoryTest
extends
AuditRepositoryTestBase
{
...
...
@@ -36,7 +38,7 @@ public class HBaseBasedAuditRepositoryTest extends AuditRepositoryTestBase {
public
void
setup
()
throws
Exception
{
eventRepository
=
new
HBaseBasedAuditRepository
();
HBaseTestUtils
.
startCluster
();
((
HBaseBasedAuditRepository
)
eventRepository
).
start
();
((
HBaseBasedAuditRepository
)
eventRepository
).
start
();
Configuration
properties
=
ApplicationProperties
.
get
();
String
tableNameStr
=
properties
.
getString
(
HBaseBasedAuditRepository
.
CONFIG_TABLE_NAME
,
...
...
@@ -46,7 +48,7 @@ public class HBaseBasedAuditRepositoryTest extends AuditRepositoryTestBase {
@AfterClass
public
void
teardown
()
throws
Exception
{
((
HBaseBasedAuditRepository
)
eventRepository
).
stop
();
((
HBaseBasedAuditRepository
)
eventRepository
).
stop
();
HBaseTestUtils
.
stopCluster
();
}
...
...
@@ -56,4 +58,10 @@ public class HBaseBasedAuditRepositoryTest extends AuditRepositoryTestBase {
Admin
admin
=
connection
.
getAdmin
();
assertTrue
(
admin
.
tableExists
(
tableName
));
}
@Override
protected
void
assertEventEquals
(
EntityAuditEvent
actual
,
EntityAuditEvent
expected
)
{
super
.
assertEventEquals
(
actual
,
expected
);
assertNull
(
actual
.
getEntityDefinition
());
}
}
\ No newline at end of file
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