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
ee99930f
Commit
ee99930f
authored
6 years ago
by
Nikhil Bonte
Committed by
Madhan Neethiraj
6 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3052: removed caching of metrics query results
Change-Id: Ifeabb13acb387781a72d00146d4acd4ea9a279d8 Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
a0e4cd1a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
32 deletions
+6
-32
MetricsService.java
...c/main/java/org/apache/atlas/services/MetricsService.java
+3
-29
MetricsServiceTest.java
...st/java/org/apache/atlas/services/MetricsServiceTest.java
+1
-1
AdminResource.java
...in/java/org/apache/atlas/web/resources/AdminResource.java
+2
-2
No files found.
repository/src/main/java/org/apache/atlas/services/MetricsService.java
View file @
ee99930f
...
@@ -59,30 +59,21 @@ public class MetricsService {
...
@@ -59,30 +59,21 @@ public class MetricsService {
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"
;
public
static
final
String
METRIC_QUERY_CACHE_TTL
=
"atlas.metric.query.cache.ttlInSecs"
;
public
static
final
String
METRIC_QUERY_GREMLIN_TYPES_BATCH_SIZE
=
"atlas.metric.query.gremlin.typesBatchSize"
;
public
static
final
int
DEFAULT_CACHE_TTL_IN_SECS
=
900
;
public
static
final
String
METRIC_COLLECTION_TIME
=
"collectionTime"
;
public
static
final
String
METRIC_COLLECTION_TIME
=
"collectionTime"
;
private
final
AtlasGraph
atlasGraph
;
private
final
AtlasGraph
atlasGraph
;
private
final
AtlasTypeRegistry
typeRegistry
;
private
final
AtlasTypeRegistry
typeRegistry
;
private
final
int
cacheTTLInSecs
;
private
final
String
indexSearchPrefix
=
AtlasGraphUtilsV2
.
getIndexSearchPrefix
();
private
final
String
indexSearchPrefix
=
AtlasGraphUtilsV2
.
getIndexSearchPrefix
();
private
AtlasMetrics
cachedMetrics
=
null
;
private
long
cacheExpirationTime
=
0
;
@Inject
@Inject
public
MetricsService
(
final
Configuration
configuration
,
final
AtlasGraph
graph
,
final
AtlasTypeRegistry
typeRegistry
)
{
public
MetricsService
(
final
AtlasGraph
graph
,
final
AtlasTypeRegistry
typeRegistry
)
{
this
.
atlasGraph
=
graph
;
this
.
atlasGraph
=
graph
;
this
.
cacheTTLInSecs
=
configuration
!=
null
?
configuration
.
getInt
(
METRIC_QUERY_CACHE_TTL
,
DEFAULT_CACHE_TTL_IN_SECS
)
:
DEFAULT_CACHE_TTL_IN_SECS
;
this
.
typeRegistry
=
typeRegistry
;
this
.
typeRegistry
=
typeRegistry
;
}
}
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
public
AtlasMetrics
getMetrics
(
boolean
ignoreCache
)
{
public
AtlasMetrics
getMetrics
()
{
if
(
ignoreCache
||
!
isCacheValid
())
{
AtlasMetrics
metrics
=
new
AtlasMetrics
();
AtlasMetrics
metrics
=
new
AtlasMetrics
();
metrics
.
addMetric
(
GENERAL
,
METRIC_TYPE_COUNT
,
getAllTypesCount
());
metrics
.
addMetric
(
GENERAL
,
METRIC_TYPE_COUNT
,
getAllTypesCount
());
...
@@ -156,11 +147,7 @@ public class MetricsService {
...
@@ -156,11 +147,7 @@ public class MetricsService {
metrics
.
addMetric
(
GENERAL
,
METRIC_COLLECTION_TIME
,
collectionTime
);
metrics
.
addMetric
(
GENERAL
,
METRIC_COLLECTION_TIME
,
collectionTime
);
this
.
cachedMetrics
=
metrics
;
return
metrics
;
this
.
cacheExpirationTime
=
(
collectionTime
+
cacheTTLInSecs
*
1000
);
}
return
cachedMetrics
;
}
}
private
Long
getTypeCount
(
String
typeName
,
Status
status
)
{
private
Long
getTypeCount
(
String
typeName
,
Status
status
)
{
...
@@ -183,16 +170,4 @@ public class MetricsService {
...
@@ -183,16 +170,4 @@ public class MetricsService {
return
CollectionUtils
.
isNotEmpty
(
allTagNames
)
?
allTagNames
.
size
()
:
0
;
return
CollectionUtils
.
isNotEmpty
(
allTagNames
)
?
allTagNames
.
size
()
:
0
;
}
}
private
boolean
isCacheValid
()
{
boolean
valid
=
cachedMetrics
!=
null
&&
System
.
currentTimeMillis
()
<
cacheExpirationTime
;
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"cachedMetrics: {}"
,
cachedMetrics
!=
null
);
LOG
.
debug
(
"cacheExpirationTime: {}"
,
cacheExpirationTime
);
LOG
.
debug
(
"valid: {}"
,
valid
);
}
return
valid
;
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
repository/src/test/java/org/apache/atlas/services/MetricsServiceTest.java
View file @
ee99930f
...
@@ -124,7 +124,7 @@ public class MetricsServiceTest {
...
@@ -124,7 +124,7 @@ public class MetricsServiceTest {
@Test
@Test
public
void
testGetMetrics
()
{
public
void
testGetMetrics
()
{
AtlasMetrics
metrics
=
metricsService
.
getMetrics
(
true
);
AtlasMetrics
metrics
=
metricsService
.
getMetrics
();
assertNotNull
(
metrics
);
assertNotNull
(
metrics
);
...
...
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
View file @
ee99930f
...
@@ -319,12 +319,12 @@ public class AdminResource {
...
@@ -319,12 +319,12 @@ public class AdminResource {
@GET
@GET
@Path
(
"metrics"
)
@Path
(
"metrics"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasMetrics
getMetrics
(
@QueryParam
(
"ignoreCache"
)
boolean
ignoreCache
)
{
public
AtlasMetrics
getMetrics
()
{
if
(
LOG
.
isDebugEnabled
())
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> AdminResource.getMetrics()"
);
LOG
.
debug
(
"==> AdminResource.getMetrics()"
);
}
}
AtlasMetrics
metrics
=
metricsService
.
getMetrics
(
ignoreCache
);
AtlasMetrics
metrics
=
metricsService
.
getMetrics
();
if
(
LOG
.
isDebugEnabled
())
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== AdminResource.getMetrics()"
);
LOG
.
debug
(
"<== AdminResource.getMetrics()"
);
...
...
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