Record Class DiskUsage

java.lang.Object
java.lang.Record
org.elasticsearch.cluster.DiskUsage
All Implemented Interfaces:
Writeable, ToXContent, ToXContentFragment

public record DiskUsage(String nodeId, String nodeName, String path, long totalBytes, long freeBytes) extends Record implements ToXContentFragment, Writeable
Encapsulation class used to represent the amount of disk used on a node.
  • Constructor Details

    • DiskUsage

      public DiskUsage(StreamInput in) throws IOException
      Throws:
      IOException
    • DiskUsage

      public DiskUsage(String nodeId, String nodeName, String path, long totalBytes, long freeBytes)
      Creates an instance of a DiskUsage record class.
      Parameters:
      nodeId - the value for the nodeId record component
      nodeName - the value for the nodeName record component
      path - the value for the path record component
      totalBytes - the value for the totalBytes record component
      freeBytes - the value for the freeBytes record component
  • Method Details

    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • toXContent

      public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface ToXContent
      Throws:
      IOException
    • freeDiskAsPercentage

      public double freeDiskAsPercentage()
    • usedDiskAsPercentage

      public double usedDiskAsPercentage()
    • usedBytes

      public long usedBytes()
    • toString

      public 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
    • copyWithFreeBytes

      public DiskUsage copyWithFreeBytes(long freeBytes)
    • findLeastAvailablePath

      @Nullable public static DiskUsage findLeastAvailablePath(NodeStats nodeStats)
      Finds the path with the least available disk space and returns its disk usage. It returns null if there is no file system data in the NodeStats or if the total bytes are a negative number.
    • findMostAvailable

      @Nullable public static DiskUsage findMostAvailable(NodeStats nodeStats)
      Finds the path with the most available disk space and returns its disk usage. It returns null if there are no file system data in the node stats or if the total bytes are a negative number.
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • nodeId

      public String nodeId()
      Returns the value of the nodeId record component.
      Returns:
      the value of the nodeId record component
    • nodeName

      public String nodeName()
      Returns the value of the nodeName record component.
      Returns:
      the value of the nodeName record component
    • path

      public String path()
      Returns the value of the path record component.
      Returns:
      the value of the path record component
    • totalBytes

      public long totalBytes()
      Returns the value of the totalBytes record component.
      Returns:
      the value of the totalBytes record component
    • freeBytes

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