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
34d235f3
Commit
34d235f3
authored
8 years ago
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1471: avoid unnecessary overhead in debug log calls
parent
9c0c46db
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
100 additions
and
34 deletions
+100
-34
DeleteHandler.java
...java/org/apache/atlas/repository/graph/DeleteHandler.java
+40
-13
FullTextMapper.java
...ava/org/apache/atlas/repository/graph/FullTextMapper.java
+8
-2
GraphBackedMetadataRepository.java
...atlas/repository/graph/GraphBackedMetadataRepository.java
+34
-9
GraphBackedSearchIndexer.java
...ache/atlas/repository/graph/GraphBackedSearchIndexer.java
+18
-10
GraphHelper.java
...n/java/org/apache/atlas/repository/graph/GraphHelper.java
+0
-0
GraphToTypedInstanceMapper.java
...he/atlas/repository/graph/GraphToTypedInstanceMapper.java
+0
-0
TypedInstanceToGraphMapper.java
...he/atlas/repository/graph/TypedInstanceToGraphMapper.java
+0
-0
No files found.
repository/src/main/java/org/apache/atlas/repository/graph/DeleteHandler.java
View file @
34d235f3
...
...
@@ -79,8 +79,11 @@ public abstract class DeleteHandler {
String
guid
=
GraphHelper
.
getGuid
(
instanceVertex
);
Id
.
EntityState
state
=
GraphHelper
.
getState
(
instanceVertex
);
if
(
requestContext
.
getDeletedEntityIds
().
contains
(
guid
)
||
state
==
Id
.
EntityState
.
DELETED
)
{
LOG
.
debug
(
"Skipping deletion of {} as it is already deleted"
,
guid
);
continue
;
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Skipping deletion of {} as it is already deleted"
,
guid
);
}
continue
;
}
// Get GUIDs and vertices for all deletion candidates.
...
...
@@ -131,13 +134,19 @@ public abstract class DeleteHandler {
* @throws AtlasException
*/
protected
void
deleteTypeVertex
(
AtlasVertex
instanceVertex
,
boolean
force
)
throws
AtlasException
{
LOG
.
debug
(
"Deleting {}"
,
string
(
instanceVertex
));
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Deleting {}"
,
string
(
instanceVertex
));
}
String
typeName
=
GraphHelper
.
getTypeName
(
instanceVertex
);
IDataType
type
=
typeSystem
.
getDataType
(
IDataType
.
class
,
typeName
);
FieldMapping
fieldMapping
=
getFieldMapping
(
type
);
for
(
AttributeInfo
attributeInfo
:
fieldMapping
.
fields
.
values
())
{
LOG
.
debug
(
"Deleting attribute {} for {}"
,
attributeInfo
.
name
,
string
(
instanceVertex
));
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Deleting attribute {} for {}"
,
attributeInfo
.
name
,
string
(
instanceVertex
));
}
String
edgeLabel
=
GraphHelper
.
getEdgeLabel
(
type
,
attributeInfo
);
switch
(
attributeInfo
.
dataType
().
getTypeCategory
())
{
...
...
@@ -200,7 +209,10 @@ public abstract class DeleteHandler {
*/
public
boolean
deleteEdgeReference
(
AtlasEdge
edge
,
DataTypes
.
TypeCategory
typeCategory
,
boolean
isComposite
,
boolean
forceDeleteStructTrait
)
throws
AtlasException
{
LOG
.
debug
(
"Deleting {}"
,
string
(
edge
));
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Deleting {}"
,
string
(
edge
));
}
boolean
forceDelete
=
(
typeCategory
==
DataTypes
.
TypeCategory
.
STRUCT
||
typeCategory
==
DataTypes
.
TypeCategory
.
TRAIT
)
&&
forceDeleteStructTrait
;
if
(
typeCategory
==
DataTypes
.
TypeCategory
.
STRUCT
||
typeCategory
==
DataTypes
.
TypeCategory
.
TRAIT
...
...
@@ -247,7 +259,9 @@ public abstract class DeleteHandler {
protected
void
deleteVertex
(
AtlasVertex
instanceVertex
,
boolean
force
)
throws
AtlasException
{
//Update external references(incoming edges) to this vertex
LOG
.
debug
(
"Setting the external references to {} to null(removing edges)"
,
string
(
instanceVertex
));
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Setting the external references to {} to null(removing edges)"
,
string
(
instanceVertex
));
}
for
(
AtlasEdge
edge
:
(
Iterable
<
AtlasEdge
>)
instanceVertex
.
getEdges
(
AtlasEdgeDirection
.
IN
))
{
Id
.
EntityState
edgeState
=
GraphHelper
.
getState
(
edge
);
...
...
@@ -271,8 +285,11 @@ public abstract class DeleteHandler {
* @throws AtlasException
*/
protected
void
deleteEdgeBetweenVertices
(
AtlasVertex
outVertex
,
AtlasVertex
inVertex
,
String
attributeName
)
throws
AtlasException
{
LOG
.
debug
(
"Removing edge from {} to {} with attribute name {}"
,
string
(
outVertex
),
string
(
inVertex
),
attributeName
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Removing edge from {} to {} with attribute name {}"
,
string
(
outVertex
),
string
(
inVertex
),
attributeName
);
}
String
typeName
=
GraphHelper
.
getTypeName
(
outVertex
);
String
outId
=
GraphHelper
.
getGuid
(
outVertex
);
Id
.
EntityState
state
=
GraphHelper
.
getState
(
outVertex
);
...
...
@@ -331,8 +348,11 @@ public abstract class DeleteHandler {
//if composite attribute, remove the reference as well. else, just remove the edge
//for example, when table is deleted, process still references the table
//but when column is deleted, table will not reference the deleted column
LOG
.
debug
(
"Removing edge {} from the array attribute {}"
,
string
(
elementEdge
),
attributeName
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Removing edge {} from the array attribute {}"
,
string
(
elementEdge
),
attributeName
);
}
elements
.
remove
(
elementEdge
.
getId
().
toString
());
GraphHelper
.
setProperty
(
outVertex
,
propertyName
,
elements
);
break
;
...
...
@@ -367,8 +387,11 @@ public abstract class DeleteHandler {
if
(
shouldUpdateReverseAttribute
)
{
//remove this key
LOG
.
debug
(
"Removing edge {}, key {} from the map attribute {}"
,
string
(
mapEdge
),
key
,
attributeName
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Removing edge {}, key {} from the map attribute {}"
,
string
(
mapEdge
),
key
,
attributeName
);
}
keys
.
remove
(
key
);
GraphHelper
.
setProperty
(
outVertex
,
propertyName
,
keys
);
GraphHelper
.
setProperty
(
outVertex
,
keyPropertyName
,
null
);
...
...
@@ -426,7 +449,11 @@ public abstract class DeleteHandler {
*/
private
void
deleteAllTraits
(
AtlasVertex
instanceVertex
)
throws
AtlasException
{
List
<
String
>
traitNames
=
GraphHelper
.
getTraitNames
(
instanceVertex
);
LOG
.
debug
(
"Deleting traits {} for {}"
,
traitNames
,
string
(
instanceVertex
));
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Deleting traits {} for {}"
,
traitNames
,
string
(
instanceVertex
));
}
String
typeName
=
GraphHelper
.
getTypeName
(
instanceVertex
);
for
(
String
traitNameToBeDeleted
:
traitNames
)
{
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/graph/FullTextMapper.java
View file @
34d235f3
...
...
@@ -56,12 +56,18 @@ public class FullTextMapper {
ITypedReferenceableInstance
typedReference
;
if
(
instanceCache
.
containsKey
(
guid
))
{
typedReference
=
instanceCache
.
get
(
guid
);
LOG
.
debug
(
"Cache hit: guid = {}, entityId = {}"
,
guid
,
typedReference
.
getId
().
_getId
());
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Cache hit: guid = {}, entityId = {}"
,
guid
,
typedReference
.
getId
().
_getId
());
}
}
else
{
typedReference
=
graphToTypedInstanceMapper
.
mapGraphToTypedInstance
(
guid
,
instanceVertex
);
instanceCache
.
put
(
guid
,
typedReference
);
LOG
.
debug
(
"Cache miss: guid = {}, entityId = {}"
,
guid
,
typedReference
.
getId
().
getId
());
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Cache miss: guid = {}, entityId = {}"
,
guid
,
typedReference
.
getId
().
getId
());
}
}
String
fullText
=
forInstance
(
typedReference
,
followReferences
);
StringBuilder
fullTextBuilder
=
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepository.java
View file @
34d235f3
...
...
@@ -136,7 +136,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
@GraphTransaction
public
List
<
String
>
createEntities
(
ITypedReferenceableInstance
...
entities
)
throws
RepositoryException
,
EntityExistsException
{
LOG
.
debug
(
"adding entities={}"
,
entities
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"adding entities={}"
,
entities
);
}
try
{
TypedInstanceToGraphMapper
instanceToGraphMapper
=
new
TypedInstanceToGraphMapper
(
graphToInstanceMapper
,
deleteHandler
);
instanceToGraphMapper
.
mapTypedInstanceToGraph
(
TypedInstanceToGraphMapper
.
Operation
.
CREATE
,
entities
);
...
...
@@ -151,7 +154,9 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
@Override
@GraphTransaction
public
ITypedReferenceableInstance
getEntityDefinition
(
String
guid
)
throws
RepositoryException
,
EntityNotFoundException
{
LOG
.
debug
(
"Retrieving entity with guid={}"
,
guid
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Retrieving entity with guid={}"
,
guid
);
}
AtlasVertex
instanceVertex
=
graphHelper
.
getVertexForGUID
(
guid
);
...
...
@@ -166,7 +171,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
@GraphTransaction
public
ITypedReferenceableInstance
getEntityDefinition
(
String
entityType
,
String
attribute
,
Object
value
)
throws
AtlasException
{
LOG
.
debug
(
"Retrieving entity with type={} and {}={}"
,
entityType
,
attribute
,
value
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Retrieving entity with type={} and {}={}"
,
entityType
,
attribute
,
value
);
}
IDataType
type
=
typeSystem
.
getDataType
(
IDataType
.
class
,
entityType
);
String
propertyKey
=
getFieldNameInVertex
(
type
,
attribute
);
AtlasVertex
instanceVertex
=
graphHelper
.
findVertex
(
propertyKey
,
value
,
...
...
@@ -180,7 +188,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
@Override
@GraphTransaction
public
List
<
String
>
getEntityList
(
String
entityType
)
throws
RepositoryException
{
LOG
.
debug
(
"Retrieving entity list for type={}"
,
entityType
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Retrieving entity list for type={}"
,
entityType
);
}
AtlasGraphQuery
query
=
graph
.
query
().
has
(
Constants
.
ENTITY_TYPE_PROPERTY_KEY
,
entityType
);
Iterator
<
AtlasVertex
>
results
=
query
.
vertices
().
iterator
();
if
(!
results
.
hasNext
())
{
...
...
@@ -206,7 +217,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
@Override
@GraphTransaction
public
List
<
String
>
getTraitNames
(
String
guid
)
throws
AtlasException
{
LOG
.
debug
(
"Retrieving trait names for entity={}"
,
guid
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Retrieving trait names for entity={}"
,
guid
);
}
AtlasVertex
instanceVertex
=
graphHelper
.
getVertexForGUID
(
guid
);
return
GraphHelper
.
getTraitNames
(
instanceVertex
);
}
...
...
@@ -224,7 +238,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
public
void
addTrait
(
String
guid
,
ITypedStruct
traitInstance
)
throws
RepositoryException
{
Preconditions
.
checkNotNull
(
traitInstance
,
"Trait instance cannot be null"
);
final
String
traitName
=
traitInstance
.
getTypeName
();
LOG
.
debug
(
"Adding a new trait={} for entity={}"
,
traitName
,
guid
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Adding a new trait={} for entity={}"
,
traitName
,
guid
);
}
try
{
AtlasVertex
instanceVertex
=
graphHelper
.
getVertexForGUID
(
guid
);
...
...
@@ -260,7 +277,9 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
@Override
@GraphTransaction
public
void
deleteTrait
(
String
guid
,
String
traitNameToBeDeleted
)
throws
TraitNotFoundException
,
EntityNotFoundException
,
RepositoryException
{
LOG
.
debug
(
"Deleting trait={} from entity={}"
,
traitNameToBeDeleted
,
guid
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Deleting trait={} from entity={}"
,
traitNameToBeDeleted
,
guid
);
}
AtlasVertex
instanceVertex
=
graphHelper
.
getVertexForGUID
(
guid
);
...
...
@@ -303,7 +322,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
@Override
@GraphTransaction
public
AtlasClient
.
EntityResult
updateEntities
(
ITypedReferenceableInstance
...
entitiesUpdated
)
throws
RepositoryException
{
LOG
.
debug
(
"updating entity {}"
,
entitiesUpdated
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"updating entity {}"
,
entitiesUpdated
);
}
try
{
TypedInstanceToGraphMapper
instanceToGraphMapper
=
new
TypedInstanceToGraphMapper
(
graphToInstanceMapper
,
deleteHandler
);
instanceToGraphMapper
.
mapTypedInstanceToGraph
(
TypedInstanceToGraphMapper
.
Operation
.
UPDATE_FULL
,
...
...
@@ -319,7 +341,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
@Override
@GraphTransaction
public
AtlasClient
.
EntityResult
updatePartial
(
ITypedReferenceableInstance
entity
)
throws
RepositoryException
{
LOG
.
debug
(
"updating entity {}"
,
entity
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"updating entity {}"
,
entity
);
}
try
{
TypedInstanceToGraphMapper
instanceToGraphMapper
=
new
TypedInstanceToGraphMapper
(
graphToInstanceMapper
,
deleteHandler
);
instanceToGraphMapper
.
mapTypedInstanceToGraph
(
TypedInstanceToGraphMapper
.
Operation
.
UPDATE_PARTIAL
,
entity
);
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java
View file @
34d235f3
...
...
@@ -233,7 +233,10 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateCh
AtlasGraphManagement
management
=
provider
.
get
().
getManagementSystem
();
for
(
IDataType
dataType
:
dataTypes
)
{
LOG
.
debug
(
"Creating indexes for type name={}, definition={}"
,
dataType
.
getName
(),
dataType
.
getClass
());
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Creating indexes for type name={}, definition={}"
,
dataType
.
getName
(),
dataType
.
getClass
());
}
try
{
addIndexForType
(
management
,
dataType
);
LOG
.
info
(
"Index creation for type {} complete"
,
dataType
.
getName
());
...
...
@@ -506,17 +509,17 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateCh
AtlasPropertyKey
propertyKey
,
boolean
enforceUniqueness
)
{
String
propertyName
=
propertyKey
.
getName
();
LOG
.
debug
(
"Creating composite index for property {} of type {} "
,
propertyName
,
propertyClass
.
getName
());
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Creating composite index for property {} of type {}; isUnique={} "
,
propertyName
,
propertyClass
.
getName
(),
enforceUniqueness
);
}
AtlasGraphIndex
existingIndex
=
management
.
getGraphIndex
(
propertyName
);
if
(
existingIndex
==
null
)
{
if
(
enforceUniqueness
)
{
LOG
.
debug
(
"Enabling unique index for property {} of type {} "
,
propertyName
,
propertyClass
.
getName
());
}
management
.
createExactMatchIndex
(
propertyName
,
enforceUniqueness
,
Collections
.
singletonList
(
propertyKey
));
}
LOG
.
info
(
"Created composite index for property {} of type {} "
,
propertyName
,
propertyClass
.
getName
());
LOG
.
info
(
"Created composite index for property {} of type {}; isUnique={} "
,
propertyName
,
propertyClass
.
getName
(),
enforceUniqueness
);
}
...
...
@@ -536,8 +539,10 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateCh
Class
propertyClass
,
AtlasPropertyKey
propertyKey
,
final
String
systemPropertyKey
,
AtlasCardinality
cardinality
)
{
LOG
.
debug
(
"Creating composite index for property {} of type {} and {}"
,
propertyKey
.
getName
(),
propertyClass
.
getName
(),
systemPropertyKey
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Creating composite index for property {} of type {} and {}"
,
propertyKey
.
getName
(),
propertyClass
.
getName
(),
systemPropertyKey
);
}
AtlasPropertyKey
typePropertyKey
=
management
.
getPropertyKey
(
systemPropertyKey
);
if
(
typePropertyKey
==
null
)
{
...
...
@@ -562,9 +567,12 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateCh
private
void
updateVertexIndex
(
AtlasGraphManagement
management
,
String
propertyName
,
Class
propertyClass
,
AtlasCardinality
cardinality
,
AtlasPropertyKey
propertyKey
)
{
if
(
checkIfVertexIndexApplicable
(
propertyClass
,
cardinality
))
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Creating backing index for property {} of type {} "
,
propertyName
,
propertyClass
.
getName
());
}
// Use backing index
management
.
addVertexIndexKey
(
Constants
.
VERTEX_INDEX
,
propertyKey
);
LOG
.
debug
(
"Creating backing index for property {} of type {} "
,
propertyName
,
propertyClass
.
getName
());
LOG
.
info
(
"Created backing index for property {} of type {} "
,
propertyName
,
propertyClass
.
getName
());
}
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
View file @
34d235f3
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/graph/GraphToTypedInstanceMapper.java
View file @
34d235f3
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java
View file @
34d235f3
This diff is collapsed.
Click to expand it.
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