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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Fields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopyWithFreeBytes
(long freeBytes) final boolean
Indicates whether some other object is "equal to" this one.static DiskUsage
findLeastAvailablePath
(NodeStats nodeStats) Finds the path with the least available disk space and returns its disk usage.static DiskUsage
findMostAvailable
(NodeStats nodeStats) Finds the path with the most available disk space and returns its disk usage.long
Returns the value of thefreeBytes
record component.long
double
getPath()
long
long
double
final int
hashCode()
Returns a hash code value for this object.nodeId()
Returns the value of thenodeId
record component.nodeName()
Returns the value of thenodeName
record component.path()
Returns the value of thepath
record component.toString()
Returns a string representation of this record class.long
Returns the value of thetotalBytes
record component.toXContent
(XContentBuilder builder, ToXContent.Params params) void
writeTo
(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.elasticsearch.xcontent.ToXContentFragment
isFragment
-
Constructor Details
-
DiskUsage
- Throws:
IOException
-
DiskUsage
Creates an instance of aDiskUsage
record class.- Parameters:
nodeId
- the value for thenodeId
record componentnodeName
- the value for thenodeName
record componentpath
- the value for thepath
record componenttotalBytes
- the value for thetotalBytes
record componentfreeBytes
- the value for thefreeBytes
record component
-
-
Method Details
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Throws:
IOException
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContent
in interfaceToXContent
- Throws:
IOException
-
getNodeId
-
getNodeName
-
getPath
-
getFreeDiskAsPercentage
public double getFreeDiskAsPercentage() -
getUsedDiskAsPercentage
public double getUsedDiskAsPercentage() -
getFreeBytes
public long getFreeBytes() -
getTotalBytes
public long getTotalBytes() -
getUsedBytes
public long getUsedBytes() -
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. -
copyWithFreeBytes
-
findLeastAvailablePath
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
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. -
equals
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 withObjects::equals(Object,Object)
; primitive components are compared with '=='. -
nodeId
Returns the value of thenodeId
record component.- Returns:
- the value of the
nodeId
record component
-
nodeName
Returns the value of thenodeName
record component.- Returns:
- the value of the
nodeName
record component
-
path
Returns the value of thepath
record component.- Returns:
- the value of the
path
record component
-
totalBytes
public long totalBytes()Returns the value of thetotalBytes
record component.- Returns:
- the value of the
totalBytes
record component
-
freeBytes
public long freeBytes()Returns the value of thefreeBytes
record component.- Returns:
- the value of the
freeBytes
record component
-