Class MachineIdHealthIndicator

java.lang.Object
me.ahoo.cosid.spring.boot.starter.machine.MachineIdHealthIndicator
All Implemented Interfaces:
org.springframework.boot.actuate.health.HealthContributor, org.springframework.boot.actuate.health.HealthIndicator

public class MachineIdHealthIndicator extends Object implements org.springframework.boot.actuate.health.HealthIndicator
A Spring Boot Actuator HealthIndicator that monitors the health of machine ID guarding. This indicator checks the status of all guardian states managed by the MachineIdGuarder and reports the overall health of the machine ID distribution system.

The health check returns UP if all guardian states are healthy (not failed), or DOWN if any guardian state has failed, including details about the failure.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a MachineIdHealthIndicator with the specified MachineIdGuarder.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.boot.actuate.health.Health
    Performs a health check on the machine ID guarding system.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.boot.actuate.health.HealthIndicator

    getHealth
  • Constructor Details

    • MachineIdHealthIndicator

      public MachineIdHealthIndicator(MachineIdGuarder machineIdGuarder)
      Constructs a MachineIdHealthIndicator with the specified MachineIdGuarder.

      This constructor initializes the health indicator to monitor the provided MachineIdGuarder instance for any failed guardian states that could indicate issues with machine ID distribution.

      Parameters:
      machineIdGuarder - the MachineIdGuarder instance to monitor for health status; must not be null and should contain the guardian states to check
      Throws:
      IllegalArgumentException - if machineIdGuarder is null
  • Method Details

    • health

      public org.springframework.boot.actuate.health.Health health()
      Performs a health check on the machine ID guarding system.

      This method inspects all guardian states from the MachineIdGuarder to determine if the machine ID distribution is functioning correctly. It returns a healthy status if no guardian states are in a failed state, or an unhealthy status with details about the first encountered failure.

      The health check includes:

      • Checking if any GuardianState is marked as failed
      • If failed, including the error cause and timestamp in the health details
      Specified by:
      health in interface org.springframework.boot.actuate.health.HealthIndicator
      Returns:
      a Health object indicating UP if all guardian states are healthy, or DOWN with error details if any guardian state has failed
      Throws:
      RuntimeException - if an unexpected error occurs during health check processing