public class ServiceHealthAggregator extends Object implements HealthService<HealthcheckStatus>, Healthcheck
HealthService implementation,
which can be used to register a set of IsolatedHealthMonitors and get an aggregated health of the service.
The aggregated health is maintained by scheduling and running the set of registered (enabled) monitors at regular intervals.| Constructor and Description |
|---|
ServiceHealthAggregator() |
| Modifier and Type | Method and Description |
|---|---|
void |
addInlineMonitor(Monitor<HealthcheckStatus> monitor)
this method can be used to add a
Monitor
this monitor will not be scheduled in a separate isolated thread,
but instead its execution will happen inline, in a single thread, along with other inline monitors |
void |
addIsolatedMonitor(IsolatedHealthMonitor<HealthcheckStatus> monitor)
this method can be used to add a
IsolatedHealthMonitor which will later be
scheduled at regular intervals and monitored to generate and maintain an aggregated health of the service
the scheduling will happen in an isolated thread |
HealthcheckStatus |
check()
return healthy/unhealthy status of the service
|
HealthcheckStatus |
getServiceHealth()
aggregate all registered (enabled) monitors, collect individual monitor healths, and aggregate them accordingly
|
void |
start()
start monitoring all registered monitors
(triggers a scheduled execution of all registered monitors) and saves their futures for later reference)
|
void |
stop()
stop all running monitors
|
public void addIsolatedMonitor(IsolatedHealthMonitor<HealthcheckStatus> monitor)
IsolatedHealthMonitor which will later be
scheduled at regular intervals and monitored to generate and maintain an aggregated health of the service
the scheduling will happen in an isolated threadaddIsolatedMonitor in interface HealthService<HealthcheckStatus>monitor - any extension of the IsolatedHealthMonitorpublic void addInlineMonitor(Monitor<HealthcheckStatus> monitor)
Monitor
this monitor will not be scheduled in a separate isolated thread,
but instead its execution will happen inline, in a single thread, along with other inline monitorsaddInlineMonitor in interface HealthService<HealthcheckStatus>monitor - an implementation of line Monitorpublic void start()
start in interface HealthService<HealthcheckStatus>public void stop()
stop in interface HealthService<HealthcheckStatus>public HealthcheckStatus getServiceHealth()
getServiceHealth in interface HealthService<HealthcheckStatus>public HealthcheckStatus check()
Healthcheckcheck in interface HealthcheckCopyright © 2015–2022. All rights reserved.