Record Class NodeSlice

java.lang.Object
java.lang.Record
com.yahoo.config.provision.zone.NodeSlice

public record NodeSlice(OptionalDouble fraction, OptionalLong minCount) extends Record
A slice of nodes, satisfied by either a minimum count or a fraction.
Author:
mpolden
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final NodeSlice
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    NodeSlice(OptionalDouble fraction, OptionalLong minCount)
    Creates an instance of a NodeSlice record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the fraction record component.
    static NodeSlice
    fraction(double fraction)
    Returns a slice matching the given fraction of nodes
    final int
    Returns a hash code value for this object.
    Returns the value of the minCount record component.
    static NodeSlice
    minCount(long count)
    Returns a slice matching the given minimum number of nodes
    boolean
    satisfiedBy(long count, long totalCount)
    Returns whether this slice is satisfied by given node count, out of totalCount
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • NodeSlice

      public NodeSlice(OptionalDouble fraction, OptionalLong minCount)
      Creates an instance of a NodeSlice record class.
      Parameters:
      fraction - the value for the fraction record component
      minCount - the value for the minCount record component
  • Method Details

    • satisfiedBy

      public boolean satisfiedBy(long count, long totalCount)
      Returns whether this slice is satisfied by given node count, out of totalCount
    • fraction

      public static NodeSlice fraction(double fraction)
      Returns a slice matching the given fraction of nodes
    • minCount

      public static NodeSlice minCount(long count)
      Returns a slice matching the given minimum number of nodes
    • 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 Objects::equals(Object,Object).
      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.
    • fraction

      public OptionalDouble fraction()
      Returns the value of the fraction record component.
      Returns:
      the value of the fraction record component
    • minCount

      public OptionalLong minCount()
      Returns the value of the minCount record component.
      Returns:
      the value of the minCount record component