This is the codeAbility Sharing Platform! Learn more about the
codeAbility Sharing Platform
.
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
codeAbility Sharing Platform
Manage
Activity
Members
Labels
Plan
Issues
41
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
development
sharing
codeAbility Sharing Platform
Commits
dc7e2de7
Commit
dc7e2de7
authored
2 years ago
by
Johannes Kainz
Browse files
Options
Downloads
Patches
Plain Diff
disabled the mapping of exercises to number of views, likes and downloads
parent
00ce69cf
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!120
Bringing monitoring to production
,
!100
Monitoring
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/at/ac/uibk/gitsearch/service/MonitoringService.java
+72
-32
72 additions, 32 deletions
.../java/at/ac/uibk/gitsearch/service/MonitoringService.java
with
72 additions
and
32 deletions
src/main/java/at/ac/uibk/gitsearch/service/MonitoringService.java
+
72
−
32
View file @
dc7e2de7
...
@@ -52,10 +52,15 @@ public class MonitoringService {
...
@@ -52,10 +52,15 @@ public class MonitoringService {
private
final
AtomicLong
numberUsers
;
private
final
AtomicLong
numberUsers
;
private
final
AtomicLong
numberActiveUsers
;
private
final
AtomicLong
numberActiveUsers
;
private
final
AtomicLong
numberLikes
;
private
final
AtomicLong
numberViews
;
private
final
AtomicLong
numberDownloads
;
private
final
Map
<
String
,
AtomicInteger
>
numberExercises
;
private
final
Map
<
String
,
AtomicInteger
>
numberExercises
;
private
final
Map
<
String
,
AtomicLong
>
numberLikes
;
private
final
Map
<
String
,
AtomicLong
>
numberViews
;
private
final
Map
<
String
,
AtomicLong
>
numberLikesMap
;
private
final
Map
<
String
,
AtomicLong
>
numberDownloads
;
private
final
Map
<
String
,
AtomicLong
>
numberViewsMap
;
private
final
Map
<
String
,
AtomicLong
>
numberDownloadsMap
;
private
final
MeterRegistry
meterRegistry
;
private
final
MeterRegistry
meterRegistry
;
...
@@ -74,9 +79,9 @@ public class MonitoringService {
...
@@ -74,9 +79,9 @@ public class MonitoringService {
this
.
statisticsService
=
statisticsService
;
this
.
statisticsService
=
statisticsService
;
this
.
numberExercises
=
new
HashMap
<>();
this
.
numberExercises
=
new
HashMap
<>();
this
.
numberLikes
=
new
HashMap
<>();
this
.
numberLikes
Map
=
new
HashMap
<>();
this
.
numberViews
=
new
HashMap
<>();
this
.
numberViews
Map
=
new
HashMap
<>();
this
.
numberDownloads
=
new
HashMap
<>();
this
.
numberDownloads
Map
=
new
HashMap
<>();
this
.
numberUsers
=
this
.
numberUsers
=
meterRegistry
.
gauge
(
meterRegistry
.
gauge
(
...
@@ -101,6 +106,24 @@ public class MonitoringService {
...
@@ -101,6 +106,24 @@ public class MonitoringService {
}
catch
(
IOException
exception
)
{
}
catch
(
IOException
exception
)
{
log
.
warn
(
"An IOException occurred when searching for all exercises\n"
+
Arrays
.
toString
(
exception
.
getStackTrace
()));
log
.
warn
(
"An IOException occurred when searching for all exercises\n"
+
Arrays
.
toString
(
exception
.
getStackTrace
()));
}
}
this
.
numberLikes
=
meterRegistry
.
gauge
(
NUMBER_LIKE_NAME
,
Tags
.
of
(
HOURLY_TAG
),
new
AtomicLong
(
this
.
numberLikesMap
.
values
().
stream
().
mapToLong
(
AtomicLong:
:
get
).
sum
())
);
this
.
numberViews
=
meterRegistry
.
gauge
(
NUMBER_VIEW_NAME
,
Tags
.
of
(
HOURLY_TAG
),
new
AtomicLong
(
this
.
numberViewsMap
.
values
().
stream
().
mapToLong
(
AtomicLong:
:
get
).
sum
())
);
this
.
numberDownloads
=
meterRegistry
.
gauge
(
NUMBER_DOWNLOAD_NAME
,
Tags
.
of
(
HOURLY_TAG
),
new
AtomicLong
(
this
.
numberDownloadsMap
.
values
().
stream
().
mapToLong
(
AtomicLong:
:
get
).
sum
())
);
}
}
/**
/**
...
@@ -122,6 +145,8 @@ public class MonitoringService {
...
@@ -122,6 +145,8 @@ public class MonitoringService {
}
catch
(
IOException
exception
)
{
}
catch
(
IOException
exception
)
{
log
.
warn
(
"An IOException occurred\n"
+
Arrays
.
toString
(
exception
.
getStackTrace
()));
log
.
warn
(
"An IOException occurred\n"
+
Arrays
.
toString
(
exception
.
getStackTrace
()));
}
}
this
.
setExerciseStatistics
();
log
.
debug
(
"Finished monitoring cron job"
);
log
.
debug
(
"Finished monitoring cron job"
);
}
}
...
@@ -141,17 +166,28 @@ public class MonitoringService {
...
@@ -141,17 +166,28 @@ public class MonitoringService {
log
.
debug
(
"set the exercise statistics for {}"
,
exerciseIDs
);
log
.
debug
(
"set the exercise statistics for {}"
,
exerciseIDs
);
exerciseIDs
.
forEach
(
exerciseID
->
{
exerciseIDs
.
forEach
(
exerciseID
->
{
this
.
setNumberLikes
ForExerciseID
(
exerciseID
);
this
.
setNumberLikes
(
exerciseID
);
final
Optional
<
StatisticsDTO
>
statisticOptional
=
this
.
statisticsService
.
findOneByExerciseID
(
exerciseID
);
final
Optional
<
StatisticsDTO
>
statisticOptional
=
this
.
statisticsService
.
findOneByExerciseID
(
exerciseID
);
if
(
statisticOptional
.
isPresent
())
{
if
(
statisticOptional
.
isPresent
())
{
StatisticsDTO
statistic
=
statisticOptional
.
get
();
StatisticsDTO
statistic
=
statisticOptional
.
get
();
this
.
setNumberViews
ForExerciseID
(
exerciseID
,
statistic
.
getViews
());
this
.
setNumberViews
(
exerciseID
,
statistic
.
getViews
());
this
.
setNumberDownloads
ForExerciseID
(
exerciseID
,
statistic
.
getDownloads
());
this
.
setNumberDownloads
(
exerciseID
,
statistic
.
getDownloads
());
}
}
});
});
}
}
/**
* Sets likes, views and downloads
*
*/
private
void
setExerciseStatistics
()
{
log
.
debug
(
"set the exercise statistics"
);
this
.
numberLikes
.
set
(
this
.
numberLikesMap
.
values
().
stream
().
mapToLong
(
AtomicLong:
:
get
).
sum
());
this
.
numberViews
.
set
(
this
.
numberViewsMap
.
values
().
stream
().
mapToLong
(
AtomicLong:
:
get
).
sum
());
this
.
numberDownloads
.
set
(
this
.
numberDownloadsMap
.
values
().
stream
().
mapToLong
(
AtomicLong:
:
get
).
sum
());
}
/**
/**
* Sets the given value as number of all exercises
* Sets the given value as number of all exercises
*
*
...
@@ -226,20 +262,20 @@ public class MonitoringService {
...
@@ -226,20 +262,20 @@ public class MonitoringService {
*
*
* @param exerciseID given exercise ID
* @param exerciseID given exercise ID
*/
*/
private
void
setNumberLikes
ForExerciseID
(
String
exerciseID
)
{
private
void
setNumberLikes
(
String
exerciseID
)
{
long
numberLikes
=
this
.
likesService
.
findNumberOfLikesByExerciseID
(
exerciseID
);
long
numberLikes
=
this
.
likesService
.
findNumberOfLikesByExerciseID
(
exerciseID
);
if
(!
this
.
numberLikes
.
containsKey
(
exerciseID
))
{
if
(!
this
.
numberLikes
Map
.
containsKey
(
exerciseID
))
{
this
.
numberLikes
.
put
(
this
.
numberLikes
Map
.
put
(
exerciseID
,
exerciseID
,
meterRegistry
.
gauge
(
//
meterRegistry.gauge(
NUMBER_LIKE_NAME
,
//
NUMBER_LIKE_NAME,
Tags
.
of
(
HOURLY_TAG
,
Tag
.
of
(
EXERCISE_TAG
,
exerciseID
)),
//
Tags.of(HOURLY_TAG, Tag.of(EXERCISE_TAG, exerciseID)),
new
AtomicLong
(
numberLikes
)
new
AtomicLong
(
numberLikes
)
)
//
)
);
);
}
else
{
}
else
{
this
.
numberLikes
.
get
(
exerciseID
).
set
(
numberLikes
);
this
.
numberLikes
Map
.
get
(
exerciseID
).
set
(
numberLikes
);
}
}
}
}
...
@@ -249,14 +285,18 @@ public class MonitoringService {
...
@@ -249,14 +285,18 @@ public class MonitoringService {
* @param exerciseID given exercise ID
* @param exerciseID given exercise ID
* @param views given number of views
* @param views given number of views
*/
*/
private
void
setNumberViews
ForExerciseID
(
String
exerciseID
,
long
views
)
{
private
void
setNumberViews
(
String
exerciseID
,
long
views
)
{
if
(!
this
.
numberViews
.
containsKey
(
exerciseID
))
{
if
(!
this
.
numberViews
Map
.
containsKey
(
exerciseID
))
{
this
.
numberViews
.
put
(
this
.
numberViews
Map
.
put
(
exerciseID
,
exerciseID
,
meterRegistry
.
gauge
(
NUMBER_VIEW_NAME
,
Tags
.
of
(
HOURLY_TAG
,
Tag
.
of
(
EXERCISE_TAG
,
exerciseID
)),
new
AtomicLong
(
views
))
//meterRegistry.gauge(
// NUMBER_VIEW_NAME,
// Tags.of(HOURLY_TAG, Tag.of(EXERCISE_TAG, exerciseID)),
new
AtomicLong
(
views
)
//)
);
);
}
else
{
}
else
{
this
.
numberViews
.
get
(
exerciseID
).
set
(
views
);
this
.
numberViews
Map
.
get
(
exerciseID
).
set
(
views
);
}
}
}
}
...
@@ -266,18 +306,18 @@ public class MonitoringService {
...
@@ -266,18 +306,18 @@ public class MonitoringService {
* @param exerciseID given exercise ID
* @param exerciseID given exercise ID
* @param downloads given number of downloads
* @param downloads given number of downloads
*/
*/
private
void
setNumberDownloads
ForExerciseID
(
String
exerciseID
,
long
downloads
)
{
private
void
setNumberDownloads
(
String
exerciseID
,
long
downloads
)
{
if
(!
this
.
numberDownloads
.
containsKey
(
exerciseID
))
{
if
(!
this
.
numberDownloads
Map
.
containsKey
(
exerciseID
))
{
this
.
numberDownloads
.
put
(
this
.
numberDownloads
Map
.
put
(
exerciseID
,
exerciseID
,
meterRegistry
.
gauge
(
//
meterRegistry.gauge(
NUMBER_DOWNLOAD_NAME
,
//
NUMBER_DOWNLOAD_NAME,
Tags
.
of
(
HOURLY_TAG
,
Tag
.
of
(
EXERCISE_TAG
,
exerciseID
)),
//
Tags.of(HOURLY_TAG, Tag.of(EXERCISE_TAG, exerciseID)),
new
AtomicLong
(
downloads
)
new
AtomicLong
(
downloads
)
)
//
)
);
);
}
else
{
}
else
{
this
.
numberDownloads
.
get
(
exerciseID
).
set
(
downloads
);
this
.
numberDownloads
Map
.
get
(
exerciseID
).
set
(
downloads
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment