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
4bc1c04a
Commit
4bc1c04a
authored
Sep 17, 2020
by
nixonrodrigues
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3946 : Filter TypeDefs in Metrics API and show types data accordingly
parent
9b1d4c38
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
20 deletions
+52
-20
MetricsService.java
...c/main/java/org/apache/atlas/services/MetricsService.java
+51
-18
AtlasSecurityConfig.java
...va/org/apache/atlas/web/security/AtlasSecurityConfig.java
+1
-2
No files found.
repository/src/main/java/org/apache/atlas/services/MetricsService.java
View file @
4bc1c04a
...
...
@@ -19,10 +19,16 @@ package org.apache.atlas.services;
import
org.apache.atlas.annotation.AtlasService
;
import
org.apache.atlas.annotation.GraphTransaction
;
import
org.apache.atlas.authorize.AtlasAuthorizationUtils
;
import
org.apache.atlas.authorize.AtlasTypesDefFilterRequest
;
import
org.apache.atlas.model.instance.AtlasEntity.Status
;
import
org.apache.atlas.model.metrics.AtlasMetrics
;
import
org.apache.atlas.model.typedef.AtlasClassificationDef
;
import
org.apache.atlas.model.typedef.AtlasEntityDef
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
org.apache.atlas.repository.graphdb.AtlasGraph
;
import
org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2
;
import
org.apache.atlas.type.AtlasClassificationType
;
import
org.apache.atlas.type.AtlasEntityType
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.util.AtlasMetricJVMUtil
;
...
...
@@ -32,6 +38,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
javax.inject.Inject
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -86,8 +93,11 @@ public class MetricsService {
@SuppressWarnings
(
"unchecked"
)
@GraphTransaction
public
AtlasMetrics
getMetrics
()
{
Collection
<
String
>
entityDefNames
=
typeRegistry
.
getAllEntityDefNames
();
Collection
<
String
>
classificationDefNames
=
typeRegistry
.
getAllClassificationDefNames
();
final
AtlasTypesDef
typesDef
=
getTypesDef
();
Collection
<
AtlasEntityDef
>
entityDefs
=
typesDef
.
getEntityDefs
();
Collection
<
AtlasClassificationDef
>
classificationDefs
=
typesDef
.
getClassificationDefs
();
Map
<
String
,
Long
>
activeEntityCount
=
new
HashMap
<>();
Map
<
String
,
Long
>
deletedEntityCount
=
new
HashMap
<>();
Map
<
String
,
Long
>
shellEntityCount
=
new
HashMap
<>();
...
...
@@ -100,19 +110,19 @@ public class MetricsService {
long
unusedTypeCount
=
0
;
long
totalEntities
=
0
;
if
(
entityDef
Name
s
!=
null
)
{
for
(
String
entityDefName
:
entityDefName
s
)
{
long
activeCount
=
getTypeCount
(
entityDef
Name
,
ACTIVE
);
long
deletedCount
=
getTypeCount
(
entityDef
Name
,
DELETED
);
long
shellCount
=
getTypeShellCount
(
entityDef
Name
);
if
(
entityDefs
!=
null
)
{
for
(
AtlasEntityDef
entityDef
:
entityDef
s
)
{
long
activeCount
=
getTypeCount
(
entityDef
.
getName
()
,
ACTIVE
);
long
deletedCount
=
getTypeCount
(
entityDef
.
getName
()
,
DELETED
);
long
shellCount
=
getTypeShellCount
(
entityDef
.
getName
()
);
if
(
activeCount
>
0
)
{
activeEntityCount
.
put
(
entityDef
Name
,
activeCount
);
activeEntityCount
.
put
(
entityDef
.
getName
()
,
activeCount
);
totalEntities
+=
activeCount
;
}
if
(
deletedCount
>
0
)
{
deletedEntityCount
.
put
(
entityDef
Name
,
deletedCount
);
deletedEntityCount
.
put
(
entityDef
.
getName
()
,
deletedCount
);
totalEntities
+=
deletedCount
;
}
...
...
@@ -120,14 +130,15 @@ public class MetricsService {
unusedTypeCount
++;
}
if
(
shellCount
>
0
){
shellEntityCount
.
put
(
entityDefName
,
shellCount
);
}
if
(
shellCount
>
0
)
{
shellEntityCount
.
put
(
entityDef
.
getName
(),
shellCount
);
}
}
Collection
<
AtlasEntityType
>
allEntityTypes
=
typeRegistry
.
getAllEntityTypes
();
for
(
AtlasEntityType
entityType
:
allEntityTypes
)
{
for
(
AtlasEntityDef
entityDef
:
entityDefs
)
{
AtlasEntityType
entityType
=
typeRegistry
.
getEntityTypeByName
(
entityDef
.
getName
());
long
entityActiveCount
=
0
;
long
entityDeletedCount
=
0
;
long
entityShellCount
=
0
;
...
...
@@ -148,13 +159,15 @@ public class MetricsService {
shellEntityCountTypeAndSubTypes
.
put
(
entityType
.
getTypeName
(),
entityShellCount
);
}
}
}
if
(
classificationDefNames
!=
null
)
{
for
(
String
classificationDefName
:
classificationDefNames
)
{
long
count
=
getTypeCount
(
classificationDefName
,
ACTIVE
);
if
(
classificationDefs
!=
null
)
{
for
(
AtlasClassificationDef
classificationDef
:
classificationDefs
)
{
long
count
=
getTypeCount
(
classificationDef
.
getName
(),
ACTIVE
);
if
(
count
>
0
)
{
taggedEntityCount
.
put
(
classificationDef
Name
,
count
);
taggedEntityCount
.
put
(
classificationDef
.
getName
()
,
count
);
}
}
}
...
...
@@ -226,4 +239,23 @@ public class MetricsService {
return
CollectionUtils
.
isNotEmpty
(
allTagNames
)
?
allTagNames
.
size
()
:
0
;
}
private
AtlasTypesDef
getTypesDef
()
{
AtlasTypesDef
ret
=
new
AtlasTypesDef
();
Collection
<
AtlasEntityDef
>
entityDefs
=
typeRegistry
.
getAllEntityDefs
();
if
(
CollectionUtils
.
isNotEmpty
(
entityDefs
))
{
ret
.
getEntityDefs
().
addAll
(
entityDefs
);
}
Collection
<
AtlasClassificationDef
>
classificationTypes
=
typeRegistry
.
getAllClassificationDefs
();
if
(
CollectionUtils
.
isNotEmpty
(
classificationTypes
))
{
ret
.
getClassificationDefs
().
addAll
(
classificationTypes
);
}
AtlasAuthorizationUtils
.
filterTypesDef
(
new
AtlasTypesDefFilterRequest
(
ret
));
return
ret
;
}
}
\ No newline at end of file
webapp/src/main/java/org/apache/atlas/web/security/AtlasSecurityConfig.java
View file @
4bc1c04a
...
...
@@ -171,8 +171,7 @@ public class AtlasSecurityConfig extends WebSecurityConfigurerAdapter {
"/n/js/**"
,
"/ieerror.html"
,
"/migration-status.html"
,
"/api/atlas/admin/status"
,
"/api/atlas/admin/metrics"
));
"/api/atlas/admin/status"
));
if
(!
keycloakEnabled
)
{
matchers
.
add
(
"/login.jsp"
);
...
...
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