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, suspend
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
unwrap
public DefaultHealthCheckService()
public DefaultHealthCheckService(CamelContext camelContext)
public void setCamelContext(CamelContext camelContext)
CamelContextAware
CamelContext
setCamelContext
in interface CamelContextAware
camelContext
- the Camel contextpublic CamelContext getCamelContext()
CamelContextAware
CamelContext
getCamelContext
in interface CamelContextAware
public 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)
HealthCheckService
addStateChangeListener
in interface HealthCheckService
consumer
- the event listener.public void removeStateChangeListener(BiConsumer<HealthCheck.State,HealthCheck> consumer)
HealthCheckService
removeStateChangeListener
in interface HealthCheckService
consumer
- the event listener to remove.public void setHealthCheckOptions(String id, Map<String,Object> options)
HealthCheckService
setHealthCheckOptions
in interface HealthCheckService
id
- the health check id.options
- the health check options.public Optional<HealthCheck.Result> call(String id)
call
in interface HealthCheckService
id
- 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)
HealthCheckService
id
with the given
options
.call
in interface HealthCheckService
id
- the health check id.options
- the health check options.Optional.empty()
if the id is unknown.public void notify(HealthCheck check, HealthCheck.Result result)
HealthCheckService
notify
in interface HealthCheckService
check
- the health check.result
- the health check result.public Collection<HealthCheck.Result> getResults()
HealthCheckService
getResults
in interface HealthCheckService
protected void doStart() throws Exception
ServiceSupport
ServiceSupport.doStop()
for more details.doStart
in class ServiceSupport
Exception
ServiceSupport.doStop()
protected void doStop() throws Exception
ServiceSupport
ServiceSupport.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 ServiceSupport
Exception
ServiceSupport.doStart()
Apache Camel