HealthInformation Class

  • java.lang.Object
    • system.fabric.health.HealthInformation

public class HealthInformation

Contains the health information about the entity. This information is included in the health report. It is also provided as part of the health event.

Field Summary

Modifier and Type Field and Description
final long autoSequenceNumber
final long unknownSequenceNumber

Constructor Summary

Constructor Description
HealthInformation(String sourceId, String property, HealthState healthState)

Initializes a new instance of the system.fabric.health.HealthInformation class.

Method Summary

Modifier and Type Method and Description
String getDescription()

Gets the description of the health information. It represents free text used to add human readable information about the report.

Remarks:The maximum string length for the description is 4096 characters.

HealthState getHealthState()

Gets the health state of the health information.

Remarks:The accepted health states are system.fabric.health.HealthState#Ok, system.fabric.health.HealthState#Warning and system.fabric.health.HealthState#Error.

String getProperty()

Gets the property of the health report.

Remarks:The property is a String and not a fixed enumeration to allow the reporter to categorize the health event for a specific property of the entity. For example, reporter A can report the health of the Node01 "storage" property and reporter B can report the health of the Node01 "connectivity" property. In the health store, these reports are treated as separate health events for the Node01 entity.

long getSequenceNumber()

Gets the sequence number associated with the report. Must be greater than system.fabric.health.HealthInformation#unknownSequenceNumber.

Remarks:The report sequence number is used by health store to detect stale reports. Most of the times, the reporter doesn't need to specify the sequence number. The default value AutoSequenceNumber can be used instead. When a health client receives a report with Auto sequence number, it replaces the auto sequence number with a valid sequence number. The sequence number is guaranteed to increase in the same process, even if the client machine time goes backwards.

String getSourceId()

Gets the source Identifier which identifies the watchdog/system component which generated the health information.

Duration getTimeToLive()

Gets how long the health report is valid. Must be larger than TimeSpan.Zero.

Remarks:When clients report periodically, they should send reports with higher frequency than time to live. If clients report on transition, they can set the time to live to infinite. When time to live expires, the health event that contains the health information is either removed from health store, if RemoveWhenExpired is true or evaluated at error, if RemoveWhenExpired is false.

boolean isRemoveWhenExpired()

Gets a value that indicates whether the report is removed from health store when it expires. If set to false, the report is treated as an error when expired. false by default.

Remarks:When clients report periodically, they should set RemoveWhenExpired false (default). This way, is the reporter has issues (eg. deadlock) and can't report, the entity is evaluated at error when the health report expires, and this will flag the entity as system.fabric.health.HealthState#Error. Periodic health clients should send reports with higher frequency than time to live to account for delays due to health client batching, message transport over the wire and health store processing.

void setDescription(String description)

Sets the description of the health information. It represents free text used to add human readable information about the report.

Remarks:The maximum string length for the description is 4096 characters.

void setRemoveWhenExpired(boolean removeWhenExpired)

Sets a value that indicates whether the report is removed from health store when it expires. If set to false, the report is treated as an error when expired. false by default.

Remarks:When clients report periodically, they should set RemoveWhenExpired false (default). This way, is the reporter has issues (eg. deadlock) and can't report, the entity is evaluated at error when the health report expires, and this will flag the entity as system.fabric.health.HealthState#Error. Periodic health clients should send reports with higher frequency than time to live to account for delays due to health client batching, message transport over the wire and health store processing.

void setSequenceNumber(long sequenceNumber)

Sets the sequence number associated with the report. Must be greater than system.fabric.health.HealthInformation#unknownSequenceNumber.

Remarks:The report sequence number is used by health store to detect stale reports. Most of the times, the reporter doesn't need to specify the sequence number. The default value AutoSequenceNumber can be used instead. When a health client receives a report with Auto sequence number, it replaces the auto sequence number with a valid sequence number. The sequence number is guaranteed to increase in the same process, even if the client machine time goes backwards.

void setTimeToLiveSeconds(Duration timeToLive)

Sets how long the health report is valid. Must be larger than TimeSpan.Zero.

Remarks:When clients report periodically, they should send reports with higher frequency than time to live. If clients report on transition, they can set the time to live to infinite. When time to live expires, the health event that contains the health information is either removed from health store, if RemoveWhenExpired is true or evaluated at error, if RemoveWhenExpired is false.

Field Details

autoSequenceNumber

public final long autoSequenceNumber= 0

unknownSequenceNumber

public final long unknownSequenceNumber= -1

Constructor Details

HealthInformation

public HealthInformation(String sourceId, String property, HealthState healthState)

Initializes a new instance of the system.fabric.health.HealthInformation class.

Parameters:

sourceId - The source of the report. Cannot be null or empty. It can't start with "System.", which is reserved keyword for system components reporting.
property - The property of the report. Cannot be null or empty.
healthState - he health state of the report. Must be specified. Must be one of the values of HealthState.

Method Details

getDescription

public String getDescription()

Gets the description of the health information. It represents free text used to add human readable information about the report.

Remarks:The maximum string length for the description is 4096 characters.

Returns:

A String which describes the health information in human readable form.

getHealthState

public HealthState getHealthState()

Gets the health state of the health information.

Remarks:The accepted health states are system.fabric.health.HealthState#Ok, system.fabric.health.HealthState#Warning and system.fabric.health.HealthState#Error.

Returns:

A HealthState representing the reported health state.

getProperty

public String getProperty()

Gets the property of the health report.

Remarks:The property is a String and not a fixed enumeration to allow the reporter to categorize the health event for a specific property of the entity. For example, reporter A can report the health of the Node01 "storage" property and reporter B can report the health of the Node01 "connectivity" property. In the health store, these reports are treated as separate health events for the Node01 entity.

Returns:

A String representing the property of the health report. Together with the SourceId, it uniquely identifies the health information.

getSequenceNumber

public long getSequenceNumber()

Gets the sequence number associated with the report. Must be greater than system.fabric.health.HealthInformation#unknownSequenceNumber.

Remarks:The report sequence number is used by health store to detect stale reports. Most of the times, the reporter doesn't need to specify the sequence number. The default value AutoSequenceNumber can be used instead. When a health client receives a report with Auto sequence number, it replaces the auto sequence number with a valid sequence number. The sequence number is guaranteed to increase in the same process, even if the client machine time goes backwards.

Returns:

A long representing the report sequence number.

getSourceId

public String getSourceId()

Gets the source Identifier which identifies the watchdog/system component which generated the health information.

Returns:

A String representing the source of the health report.

getTimeToLive

public Duration getTimeToLive()

Gets how long the health report is valid. Must be larger than TimeSpan.Zero.

Remarks:When clients report periodically, they should send reports with higher frequency than time to live. If clients report on transition, they can set the time to live to infinite. When time to live expires, the health event that contains the health information is either removed from health store, if RemoveWhenExpired is true or evaluated at error, if RemoveWhenExpired is false.

Returns:

A java.time.Duration representing the time to live of the health report.

isRemoveWhenExpired

public boolean isRemoveWhenExpired()

Gets a value that indicates whether the report is removed from health store when it expires. If set to false, the report is treated as an error when expired. false by default.

Remarks:When clients report periodically, they should set RemoveWhenExpired false (default). This way, is the reporter has issues (eg. deadlock) and can't report, the entity is evaluated at error when the health report expires, and this will flag the entity as system.fabric.health.HealthState#Error. Periodic health clients should send reports with higher frequency than time to live to account for delays due to health client batching, message transport over the wire and health store processing.

Returns:

true if the report should be removed from health store when expired; otherwise, false.

setDescription

public void setDescription(String description)

Sets the description of the health information. It represents free text used to add human readable information about the report.

Remarks:The maximum string length for the description is 4096 characters.

Parameters:

description - A String which describes the health information in human readable form.

setRemoveWhenExpired

public void setRemoveWhenExpired(boolean removeWhenExpired)

Sets a value that indicates whether the report is removed from health store when it expires. If set to false, the report is treated as an error when expired. false by default.

Remarks:When clients report periodically, they should set RemoveWhenExpired false (default). This way, is the reporter has issues (eg. deadlock) and can't report, the entity is evaluated at error when the health report expires, and this will flag the entity as system.fabric.health.HealthState#Error. Periodic health clients should send reports with higher frequency than time to live to account for delays due to health client batching, message transport over the wire and health store processing.

Parameters:

removeWhenExpired - true if the report should be removed from health store when expired; otherwise, false.

setSequenceNumber

public void setSequenceNumber(long sequenceNumber)

Sets the sequence number associated with the report. Must be greater than system.fabric.health.HealthInformation#unknownSequenceNumber.

Remarks:The report sequence number is used by health store to detect stale reports. Most of the times, the reporter doesn't need to specify the sequence number. The default value AutoSequenceNumber can be used instead. When a health client receives a report with Auto sequence number, it replaces the auto sequence number with a valid sequence number. The sequence number is guaranteed to increase in the same process, even if the client machine time goes backwards.

Parameters:

sequenceNumber - A long representing the report sequence number.

Throws:

IllegalArgumentException - if sequenceNumber is less or equals than unknownSequenceNumber

setTimeToLiveSeconds

public void setTimeToLiveSeconds(Duration timeToLive)

Sets how long the health report is valid. Must be larger than TimeSpan.Zero.

Remarks:When clients report periodically, they should send reports with higher frequency than time to live. If clients report on transition, they can set the time to live to infinite. When time to live expires, the health event that contains the health information is either removed from health store, if RemoveWhenExpired is true or evaluated at error, if RemoveWhenExpired is false.

Parameters:

timeToLive - A java.time.Duration representing the time to live of the health report.

Applies to