Module org.elasticsearch.server
Class HealthTracker<T>
java.lang.Object
org.elasticsearch.health.node.tracker.HealthTracker<T>
- Type Parameters:
T
- the type of the health check result they track
- Direct Known Subclasses:
DiskHealthTracker
,RepositoriesHealthTracker
Base class for health trackers that will be executed by the
LocalHealthMonitor
. It keeps track of the last
reported value and can retrieve the current health status when requested.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
A record for storing the previous and current value of a health check. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
addToRequestBuilder
(UpdateHealthInfoCacheAction.Request.Builder builder, T healthInfo) Add the health info to the request builder.abstract T
Determine the health info for this health check.void
reset()
Reset the value oflastReportedValue
tonull
.Create a newHealthTracker.HealthProgress
instance by getting the current last reported value and determining the health info at this time.void
updateLastReportedHealth
(T previous, T current) Update the last reported health info tocurrent
, but only when the value insidelastReportedValue
is equal toprevious
.
-
Constructor Details
-
HealthTracker
public HealthTracker()
-
-
Method Details
-
checkCurrentHealth
Determine the health info for this health check.- Returns:
- the health info.
-
addToRequestBuilder
public abstract void addToRequestBuilder(UpdateHealthInfoCacheAction.Request.Builder builder, T healthInfo) Add the health info to the request builder.- Parameters:
builder
- the builder to add the health info to.healthInfo
- the health info to add.
-
trackHealth
Create a newHealthTracker.HealthProgress
instance by getting the current last reported value and determining the health info at this time.- Returns:
- the new
HealthTracker.HealthProgress
instance.
-
updateLastReportedHealth
Update the last reported health info tocurrent
, but only when the value insidelastReportedValue
is equal toprevious
.- Parameters:
previous
- the previous value that should be inlastReportedValue
at the time of execution.current
- the value that should be stored inlastReportedValue
.
-
reset
public void reset()Reset the value oflastReportedValue
tonull
. Should be used when, for example, the master or health node has changed. -
getLastReportedValue
-