public final class DefaultHealthCheckService extends ServiceSupport implements HealthCheckService
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending| Constructor and Description |
|---|
DefaultHealthCheckService() |
DefaultHealthCheckService(CamelContext camelContext) |
| Modifier and Type | Method and Description |
|---|---|
void |
addStateChangeListener(BiConsumer<HealthCheck.State,HealthCheck> consumer)
Add a listener to invoke when the state of a check change.
|
Optional<HealthCheck.Result> |
call(String id) |
Optional<HealthCheck.Result> |
call(String id,
Map<String,Object> options)
Invokes the check identified by the given
id with the given
options. |
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
protected void |
doStop()
Implementations override this method to support customized start/stop.
|
CamelContext |
getCamelContext()
Get the
CamelContext |
long |
getCheckInterval() |
TimeUnit |
getCheckIntervalUnit() |
HealthCheckRegistry |
getHealthCheckRegistry() |
Collection<HealthCheck.Result> |
getResults()
Return a list of the known checks status.
|
void |
notify(HealthCheck check,
HealthCheck.Result result)
Notify the service that a check has changed status.
|
void |
removeStateChangeListener(BiConsumer<HealthCheck.State,HealthCheck> consumer)
Remove the state change listener.
|
void |
setCamelContext(CamelContext camelContext)
Injects the
CamelContext |
void |
setCheckInterval(long checkInterval) |
void |
setCheckInterval(long interval,
TimeUnit intervalUnit) |
void |
setCheckIntervalUnit(TimeUnit checkIntervalUnit) |
void |
setHealthCheckOptions(String id,
Map<String,Object> options)
Sets the options to be used when invoking the check identified by the
given id.
|
void |
setHealthCheckRegistry(HealthCheckRegistry registry) |
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitunwrappublic DefaultHealthCheckService()
public DefaultHealthCheckService(CamelContext camelContext)
public void setCamelContext(CamelContext camelContext)
CamelContextAwareCamelContextsetCamelContext in interface CamelContextAwarecamelContext - the Camel contextpublic CamelContext getCamelContext()
CamelContextAwareCamelContextgetCamelContext in interface CamelContextAwarepublic HealthCheckRegistry getHealthCheckRegistry()
public void setHealthCheckRegistry(HealthCheckRegistry registry)
public long getCheckInterval()
public void setCheckInterval(long checkInterval)
public void setCheckInterval(long interval, TimeUnit intervalUnit)
public TimeUnit getCheckIntervalUnit()
public void setCheckIntervalUnit(TimeUnit checkIntervalUnit)
public void addStateChangeListener(BiConsumer<HealthCheck.State,HealthCheck> consumer)
HealthCheckServiceaddStateChangeListener in interface HealthCheckServiceconsumer - the event listener.public void removeStateChangeListener(BiConsumer<HealthCheck.State,HealthCheck> consumer)
HealthCheckServiceremoveStateChangeListener in interface HealthCheckServiceconsumer - the event listener to remove.public void setHealthCheckOptions(String id, Map<String,Object> options)
HealthCheckServicesetHealthCheckOptions in interface HealthCheckServiceid - the health check id.options - the health check options.public Optional<HealthCheck.Result> call(String id)
call in interface HealthCheckServiceid - the health check id.Optional.empty() if the id is unknown.#call(String, Map)}public Optional<HealthCheck.Result> call(String id, Map<String,Object> options)
HealthCheckServiceid with the given
options.call in interface HealthCheckServiceid - the health check id.options - the health check options.Optional.empty() if the id is unknown.public void notify(HealthCheck check, HealthCheck.Result result)
HealthCheckServicenotify in interface HealthCheckServicecheck - the health check.result - the health check result.public Collection<HealthCheck.Result> getResults()
HealthCheckServicegetResults in interface HealthCheckServiceprotected void doStart() throws Exception
ServiceSupportServiceSupport.doStop() for more details.doStart in class ServiceSupportExceptionServiceSupport.doStop()protected void doStop() throws Exception
ServiceSupportServiceSupport.doStop() method when
the service is being stopped. This method will also be invoked
if the service is still in uninitialized state (eg has not
been started). The method is always called to allow the service
to do custom logic when the service is being stopped, such as when
CamelContext is shutting down.doStop in class ServiceSupportExceptionServiceSupport.doStart()Apache Camel