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
660b91af
Commit
660b91af
authored
Sep 16, 2019
by
Sarath Subramanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3412: Update atlas metrics API to show shell entity count
parent
5ab09475
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
6 deletions
+35
-6
MetricsService.java
...c/main/java/org/apache/atlas/services/MetricsService.java
+35
-6
No files found.
repository/src/main/java/org/apache/atlas/services/MetricsService.java
View file @
660b91af
...
@@ -22,6 +22,8 @@ import org.apache.atlas.annotation.GraphTransaction;
...
@@ -22,6 +22,8 @@ import org.apache.atlas.annotation.GraphTransaction;
import
org.apache.atlas.model.instance.AtlasEntity.Status
;
import
org.apache.atlas.model.instance.AtlasEntity.Status
;
import
org.apache.atlas.model.metrics.AtlasMetrics
;
import
org.apache.atlas.model.metrics.AtlasMetrics
;
import
org.apache.atlas.repository.graphdb.AtlasGraph
;
import
org.apache.atlas.repository.graphdb.AtlasGraph
;
import
org.apache.atlas.repository.graphdb.AtlasIndexQuery
;
import
org.apache.atlas.repository.graphdb.AtlasVertex
;
import
org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2
;
import
org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.util.AtlasMetricsUtil
;
import
org.apache.atlas.util.AtlasMetricsUtil
;
...
@@ -30,16 +32,14 @@ import org.slf4j.Logger;
...
@@ -30,16 +32,14 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
java.util.Collection
;
import
java.util.*
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
org
.
apache
.
atlas
.
discovery
.
SearchProcessor
.
AND_STR
;
import
static
org
.
apache
.
atlas
.
discovery
.
SearchProcessor
.
AND_STR
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
AtlasEntity
.
Status
.
ACTIVE
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
AtlasEntity
.
Status
.
ACTIVE
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
AtlasEntity
.
Status
.
DELETED
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
AtlasEntity
.
Status
.
DELETED
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
ENTITY_TYPE_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
*
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
STATE_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
getTypeName
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
VERTEX_INDEX
;
import
static
org
.
apache
.
atlas
.
repository
.
store
.
graph
.
v2
.
AtlasGraphUtilsV2
.
getIndexSearchPrefix
;
@AtlasService
@AtlasService
public
class
MetricsService
{
public
class
MetricsService
{
...
@@ -59,6 +59,7 @@ public class MetricsService {
...
@@ -59,6 +59,7 @@ public class MetricsService {
protected
static
final
String
METRIC_ENTITY_COUNT
=
ENTITY
+
"Count"
;
protected
static
final
String
METRIC_ENTITY_COUNT
=
ENTITY
+
"Count"
;
protected
static
final
String
METRIC_ENTITY_DELETED
=
ENTITY
+
"Deleted"
;
protected
static
final
String
METRIC_ENTITY_DELETED
=
ENTITY
+
"Deleted"
;
protected
static
final
String
METRIC_ENTITY_ACTIVE
=
ENTITY
+
"Active"
;
protected
static
final
String
METRIC_ENTITY_ACTIVE
=
ENTITY
+
"Active"
;
protected
static
final
String
METRIC_ENTITY_SHELL
=
ENTITY
+
"Shell"
;
protected
static
final
String
METRIC_TAG_COUNT
=
TAG
+
"Count"
;
protected
static
final
String
METRIC_TAG_COUNT
=
TAG
+
"Count"
;
protected
static
final
String
METRIC_ENTITIES_PER_TAG
=
TAG
+
"Entities"
;
protected
static
final
String
METRIC_ENTITIES_PER_TAG
=
TAG
+
"Entities"
;
...
@@ -127,6 +128,7 @@ public class MetricsService {
...
@@ -127,6 +128,7 @@ public class MetricsService {
metrics
.
addMetric
(
ENTITY
,
METRIC_ENTITY_ACTIVE
,
activeEntityCount
);
metrics
.
addMetric
(
ENTITY
,
METRIC_ENTITY_ACTIVE
,
activeEntityCount
);
metrics
.
addMetric
(
ENTITY
,
METRIC_ENTITY_DELETED
,
deletedEntityCount
);
metrics
.
addMetric
(
ENTITY
,
METRIC_ENTITY_DELETED
,
deletedEntityCount
);
metrics
.
addMetric
(
ENTITY
,
METRIC_ENTITY_SHELL
,
getShellEntityCount
());
metrics
.
addMetric
(
TAG
,
METRIC_ENTITIES_PER_TAG
,
taggedEntityCount
);
metrics
.
addMetric
(
TAG
,
METRIC_ENTITIES_PER_TAG
,
taggedEntityCount
);
...
@@ -149,6 +151,33 @@ public class MetricsService {
...
@@ -149,6 +151,33 @@ public class MetricsService {
return
ret
==
null
?
0L
:
ret
;
return
ret
==
null
?
0L
:
ret
;
}
}
private
Map
<
String
,
Long
>
getShellEntityCount
()
{
Map
<
String
,
Long
>
ret
=
new
HashMap
<>();
String
idxQueryString
=
getIndexSearchPrefix
()
+
"\""
+
IS_INCOMPLETE_PROPERTY_KEY
+
"\" : "
+
INCOMPLETE_ENTITY_VALUE
.
intValue
();
AtlasIndexQuery
idxQuery
=
atlasGraph
.
indexQuery
(
VERTEX_INDEX
,
idxQueryString
);
try
{
Iterator
<
AtlasIndexQuery
.
Result
<
Object
,
Object
>>
results
=
idxQuery
.
vertices
();
while
(
results
!=
null
&&
results
.
hasNext
())
{
AtlasVertex
entityVertex
=
results
.
next
().
getVertex
();
String
typeName
=
getTypeName
(
entityVertex
);
if
(!
ret
.
containsKey
(
typeName
))
{
ret
.
put
(
typeName
,
1L
);
}
else
{
ret
.
put
(
typeName
,
ret
.
get
(
typeName
)
+
1
);
}
}
}
catch
(
Throwable
t
)
{
LOG
.
warn
(
"getShellEntityCount(): Returned empty result"
,
t
);
}
finally
{
atlasGraph
.
commit
();
}
return
ret
;
}
private
int
getAllTypesCount
()
{
private
int
getAllTypesCount
()
{
Collection
<
String
>
allTypeNames
=
typeRegistry
.
getAllTypeNames
();
Collection
<
String
>
allTypeNames
=
typeRegistry
.
getAllTypeNames
();
...
...
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