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
5389b9bd
Commit
5389b9bd
authored
Apr 17, 2019
by
Madhan Neethiraj
Committed by
Sarath Subramanian
Apr 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3147: added periodic logging of stats
Signed-off-by:
Sarath Subramanian
<
ssubramanian@hortonworks.com
>
parent
0174bac0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
26 deletions
+45
-26
AtlasMetricsCounter.java
.../main/java/org/apache/atlas/util/AtlasMetricsCounter.java
+33
-26
NotificationHookConsumer.java
...g/apache/atlas/notification/NotificationHookConsumer.java
+12
-0
No files found.
repository/src/main/java/org/apache/atlas/util/AtlasMetricsCounter.java
View file @
5389b9bd
...
...
@@ -105,43 +105,50 @@ public class AtlasMetricsCounter {
updateForTime
(
clock
.
instant
());
}
protected
void
updateForTime
(
Instant
instant
)
{
if
(
instant
.
isAfter
(
dayEndTime
))
{
rolloverDay
(
instant
);
rolloverHour
(
instant
);
}
else
if
(
instant
.
isAfter
(
hourEndTime
))
{
rolloverHour
(
instant
);
protected
void
updateForTime
(
Instant
now
)
{
Instant
dayEndTime
=
this
.
dayEndTime
;
Instant
hourEndTime
=
this
.
hourEndTime
;
if
(
now
.
isAfter
(
dayEndTime
))
{
rolloverDay
(
dayEndTime
,
now
);
rolloverHour
(
hourEndTime
,
now
);
}
else
if
(
now
.
isAfter
(
hourEndTime
))
{
rolloverHour
(
hourEndTime
,
now
);
}
}
protected
void
rolloverDay
(
Instant
instant
)
{
Instant
dayStartTime
=
getDayStartTime
(
instant
);
protected
synchronized
void
rolloverDay
(
Instant
fromDayEndTime
,
Instant
now
)
{
if
(
fromDayEndTime
==
dayEndTime
)
{
// only if rollover was not done already
Instant
dayStartTime
=
getDayStartTime
(
now
);
if
(
dayStartTime
.
equals
(
dayEndTime
))
{
stats
.
copy
(
CURR_DAY
,
PREV_DAY
);
}
else
{
stats
.
reset
(
PREV_DAY
);
}
if
(
dayStartTime
.
equals
(
dayEndTime
))
{
stats
.
copy
(
CURR_DAY
,
PREV_DAY
);
}
else
{
stats
.
reset
(
PREV_DAY
);
}
stats
.
reset
(
CURR_DAY
);
stats
.
reset
(
CURR_DAY
);
this
.
dayStartTime
=
dayStartTime
;
this
.
dayEndTime
=
getNextDayStartTime
(
instant
);
this
.
dayStartTime
=
dayStartTime
;
this
.
dayEndTime
=
getNextDayStartTime
(
now
);
}
}
protected
void
rolloverHour
(
Instant
instant
)
{
Instant
hourStartTime
=
getHourStartTime
(
instant
);
protected
synchronized
void
rolloverHour
(
Instant
fromHourEndTime
,
Instant
now
)
{
if
(
fromHourEndTime
==
hourEndTime
)
{
// only if rollover was not done already
Instant
hourStartTime
=
getHourStartTime
(
now
);
if
(
hourStartTime
.
equals
(
hourEndTime
))
{
stats
.
copy
(
CURR_HOUR
,
PREV_HOUR
);
}
else
{
stats
.
reset
(
PREV_HOUR
);
}
if
(
hourStartTime
.
equals
(
hourEndTime
))
{
stats
.
copy
(
CURR_HOUR
,
PREV_HOUR
);
}
else
{
stats
.
reset
(
PREV_HOUR
);
}
stats
.
reset
(
CURR_HOUR
);
stats
.
reset
(
CURR_HOUR
);
this
.
hourStartTime
=
hourStartTime
;
this
.
hourEndTime
=
getNextHourStartTime
(
instant
);
this
.
hourStartTime
=
hourStartTime
;
this
.
hourEndTime
=
getNextHourStartTime
(
now
);
}
}
public
static
LocalDateTime
getLocalDateTime
(
Instant
instant
)
{
...
...
webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java
View file @
5389b9bd
...
...
@@ -46,6 +46,8 @@ import org.apache.atlas.notification.NotificationInterface.NotificationType;
import
org.apache.atlas.notification.preprocessor.EntityPreprocessor
;
import
org.apache.atlas.notification.preprocessor.PreprocessorContext
;
import
org.apache.atlas.notification.preprocessor.PreprocessorContext.PreprocessAction
;
import
org.apache.atlas.util.AtlasMetricsCounter
;
import
org.apache.atlas.utils.AtlasJson
;
import
org.apache.atlas.utils.LruCache
;
import
org.apache.atlas.util.AtlasMetricsUtil
;
import
org.apache.atlas.util.AtlasMetricsUtil.NotificationStat
;
...
...
@@ -78,6 +80,7 @@ import org.springframework.core.annotation.Order;
import
org.springframework.stereotype.Component
;
import
javax.inject.Inject
;
import
java.time.Instant
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
...
...
@@ -160,6 +163,7 @@ public class NotificationHookConsumer implements Service, ActiveStateChangeHandl
private
final
NotificationInterface
notificationInterface
;
private
final
Configuration
applicationProperties
;
private
ExecutorService
executors
;
private
Instant
nextStatsLogTime
=
AtlasMetricsCounter
.
getNextHourStartTime
(
Instant
.
now
());
@VisibleForTesting
final
int
consumerRetryInterval
;
...
...
@@ -712,6 +716,14 @@ public class NotificationHookConsumer implements Service, ActiveStateChangeHandl
AuditFilter
.
audit
(
auditLog
);
}
Instant
now
=
Instant
.
now
();
if
(
now
.
isAfter
(
nextStatsLogTime
))
{
LOG
.
info
(
"STATS: {}"
,
AtlasJson
.
toJson
(
metricsUtil
.
getStats
()));
nextStatsLogTime
=
AtlasMetricsCounter
.
getNextHourStartTime
(
now
);
}
}
}
...
...
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