Package org.opennms.core.health.api
Class DefaultPassiveHealthCheck
- java.lang.Object
-
- org.opennms.core.health.api.DefaultPassiveHealthCheck
-
- All Implemented Interfaces:
CachingHealthCheck
,HealthCheck
,HealthCheckResponseCache
public class DefaultPassiveHealthCheck extends Object implements CachingHealthCheck
A health check that does no action by its own but relies on being informed about healthiness.
-
-
Constructor Summary
Constructors Constructor Description DefaultPassiveHealthCheck(String description, List<String> tags, Status initialStatus)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getDescription()
The description of theHealthCheck
, e.g.List<String>
getTags()
A tag to indicate the category of the health-check.Response
perform(Context context)
Implements the check itself, e.g.void
setResponse(Response response)
Sets the cached response forHealthCheck.perform(Context)
calls.
-
-
-
Method Detail
-
setResponse
public void setResponse(Response response)
Description copied from interface:HealthCheckResponseCache
Sets the cached response forHealthCheck.perform(Context)
calls.A
CachingHealthCheck
saves the current time as the timestamp of the given response. When the health check is performed theContext.getMaxAge()
property is checked if the cached response can be used.- Specified by:
setResponse
in interfaceHealthCheckResponseCache
-
getDescription
public String getDescription()
Description copied from interface:HealthCheck
The description of theHealthCheck
, e.g. "Connecting to OpenNMS ReST API". This is used when visualizing the progress or result of the checks.- Specified by:
getDescription
in interfaceHealthCheck
- Returns:
- The string, describing the check.
-
getTags
public List<String> getTags()
Description copied from interface:HealthCheck
A tag to indicate the category of the health-check.- Specified by:
getTags
in interfaceHealthCheck
- Returns:
- The HealthTag type, describing category of the health-check.
-
perform
public Response perform(Context context) throws Exception
Description copied from interface:HealthCheck
Implements the check itself, e.g. Connecting to a HTTP Endpoint. As the method is called by theHealthCheckService
, it is advised that all timeout restrictions etc are handled by the service instead of theHealthCheck
implementation. Implementations might throw an Exception, which should be handled by theHealthCheckService
as well. The response indicates if the check was successful, or encountered other problems. If null is returned, theHealthCheckService
should consider this asStatus.Unknown
.- Specified by:
perform
in interfaceHealthCheck
- Returns:
- The response indicating the Success/Failure/Timeout/etc of the check
- Throws:
Exception
- In case of an error- See Also:
HealthCheckService
-
-