Record Class ElectionStats

java.lang.Object
java.lang.Record
com.loomcache.server.consensus.ElectionStats
Record Components:
totalElections - Total number of election attempts (candidates)
totalPreVotes - Total number of pre-vote protocol initiations
successfulElections - Number of successful elections (became leader)
failedElections - Number of failed election attempts
avgElectionTimeMs - Average time to complete an election attempt (ms)
lastElectionTerm - The most recent term in which an election occurred

public record ElectionStats(long totalElections, long totalPreVotes, long successfulElections, long failedElections, double avgElectionTimeMs, long lastElectionTerm) extends Record
Statistics snapshot of election activity.

Captures metrics related to leader elections including pre-voting, voting attempts, success rates, and timing information.

  • Constructor Details

    • ElectionStats

      public ElectionStats(long totalElections, long totalPreVotes, long successfulElections, long failedElections, double avgElectionTimeMs, long lastElectionTerm)
      Creates an instance of a ElectionStats record class.
      Parameters:
      totalElections - the value for the totalElections record component
      totalPreVotes - the value for the totalPreVotes record component
      successfulElections - the value for the successfulElections record component
      failedElections - the value for the failedElections record component
      avgElectionTimeMs - the value for the avgElectionTimeMs record component
      lastElectionTerm - the value for the lastElectionTerm record component
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • totalElections

      public long totalElections()
      Returns the value of the totalElections record component.
      Returns:
      the value of the totalElections record component
    • totalPreVotes

      public long totalPreVotes()
      Returns the value of the totalPreVotes record component.
      Returns:
      the value of the totalPreVotes record component
    • successfulElections

      public long successfulElections()
      Returns the value of the successfulElections record component.
      Returns:
      the value of the successfulElections record component
    • failedElections

      public long failedElections()
      Returns the value of the failedElections record component.
      Returns:
      the value of the failedElections record component
    • avgElectionTimeMs

      public double avgElectionTimeMs()
      Returns the value of the avgElectionTimeMs record component.
      Returns:
      the value of the avgElectionTimeMs record component
    • lastElectionTerm

      public long lastElectionTerm()
      Returns the value of the lastElectionTerm record component.
      Returns:
      the value of the lastElectionTerm record component