Gitlab Community Edition Instance
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cdstar
cdstar
Commits
d3f0d3e9
Commit
d3f0d3e9
authored
Dec 03, 2019
by
mhellka
Browse files
Added (undocumented) /v3/_gc endpoint.
Triggering full GCs should not be required. Only for testing.
parent
1a9f15e7
Pipeline
#115891
passed with stages
in 10 minutes and 3 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
cdstar-rest/src/main/java/de/gwdg/cdstar/rest/v3/ApiV3Module.java
View file @
d3f0d3e9
...
...
@@ -14,6 +14,7 @@ public class ApiV3Module implements RestBlueprint {
cfg
.
install
(
new
ServiceEndpoint
());
cfg
.
install
(
new
ServiceHealthEndpoint
());
cfg
.
install
(
new
ServiceMetricsEndpoint
());
cfg
.
install
(
new
ServiceGCEndpoint
());
cfg
.
install
(
new
TransactionEndpoint
());
cfg
.
install
(
new
VaultEndpoint
());
cfg
.
install
(
new
ArchiveEndpoint
());
...
...
cdstar-rest/src/main/java/de/gwdg/cdstar/rest/v3/ServiceGCEndpoint.java
0 → 100644
View file @
d3f0d3e9
package
de.gwdg.cdstar.rest.v3
;
import
java.io.IOException
;
import
java.lang.management.ManagementFactory
;
import
java.lang.management.MemoryMXBean
;
import
java.lang.management.MemoryUsage
;
import
de.gwdg.cdstar.rest.api.RestBlueprint
;
import
de.gwdg.cdstar.rest.api.RestConfig
;
import
de.gwdg.cdstar.rest.api.RestContext
;
import
de.gwdg.cdstar.rest.utils.SessionHelper
;
import
de.gwdg.cdstar.runtime.client.auth.ServicePermission
;
/**
* Undocumented API to trigger a full GC run.
*/
public
class
ServiceGCEndpoint
implements
RestBlueprint
{
@Override
public
void
configure
(
RestConfig
cfg
)
{
cfg
.
route
(
"/_gc"
).
POST
(
this
::
handlePostGC
);
}
public
GCResult
handlePostGC
(
RestContext
ctx
)
throws
IOException
{
SessionHelper
.
ensurePermitted
(
ctx
,
ServicePermission
.
HEALTH
.
asStringPermission
());
return
new
GCResult
(
ManagementFactory
.
getMemoryMXBean
());
}
public
class
GCResult
{
public
final
MemoryUsage
before
;
public
final
MemoryUsage
after
;
public
final
double
time
;
public
GCResult
(
MemoryMXBean
mem
)
{
before
=
mem
.
getHeapMemoryUsage
();
final
long
t1
=
System
.
nanoTime
();
System
.
gc
();
time
=
((
double
)
(
System
.
nanoTime
()
-
t1
))
/
1000000000
;
after
=
mem
.
getHeapMemoryUsage
();
}
}
}
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