Class RaftHealthCheck

java.lang.Object
com.loomcache.server.consensus.RaftHealthCheck

public final class RaftHealthCheck extends Object
Health check and diagnostic utility for Raft consensus nodes.

Purpose: Provides methods to assess the health status of a Raft node, including role validation, log consistency, and heartbeat tracking.

Thread Safety: This class is thread-safe. Multiple threads can safely invoke diagnostic methods concurrently.

Since:
1.0
  • Constructor Details

    • RaftHealthCheck

      public RaftHealthCheck(RaftNode raftNode)
      Creates a new RaftHealthCheck for monitoring the given Raft node.
      Parameters:
      raftNode - the Raft node to monitor (must not be null)
      Throws:
      NullPointerException - if raftNode is null
  • Method Details

    • isHealthy

      public boolean isHealthy()
      Determines if the Raft node is in a healthy state.

      A node is considered healthy if: - It is in a valid state (FOLLOWER, CANDIDATE, or LEADER) - Its log is accessible and consistent - For followers: it receives heartbeats periodically

      Returns:
      true if the node is healthy, false otherwise
    • getStatus

      public RaftHealthCheck.Status getStatus()
      Get detailed status of the Raft node.
      Returns:
      Status record with current node state (never null)
    • getDiagnostics

      public Map<String,Object> getDiagnostics()
      Get diagnostics information for debugging.
      Returns:
      unmodifiable map of diagnostic keys and values (never null)