org.apache.hadoop.hdfs.server.diskbalancer.datamodel

## Class DiskBalancerDataNode

- java.lang.Object
- - org.apache.hadoop.hdfs.server.diskbalancer.datamodel.DiskBalancerDataNode

- All Implemented Interfaces:
    Comparable<DiskBalancerDataNode>

      public class DiskBalancerDataNode
      extends Object
      implements Comparable<DiskBalancerDataNode>

  DiskBalancerDataNode represents a DataNode that exists in the cluster. It also contains a metric called nodeDataDensity which allows us to compare between a set of Nodes.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DiskBalancerDataNode()` Constructs an Empty Data Node.
    `DiskBalancerDataNode(String dataNodeID)` Constructs a DataNode.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addVolume(DiskBalancerVolume volume)` Adds a volume to the DataNode.
    `int` | `compareTo(DiskBalancerDataNode that)` Compares this object with the specified object for order.
    `void` | `computeNodeDensity()` computes nodes data density.
    `boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
    `String` | `getDataNodeIP()` Returns the IP address of this Node.
    `String` | `getDataNodeName()` Get DataNode DNS name.
    `int` | `getDataNodePort()` Returns the Port of this DataNode.
    `String` | `getDataNodeUUID()` Returns datanode ID.
    `double` | `getNodeDataDensity()` returns NodeDataDensity Metric.
    `int` | `getVolumeCount()` Returns how many volumes are in the DataNode.
    `Map<String,DiskBalancerVolumeSet>` | `getVolumeSets()` Returns the Volume sets on this node.
    `int` | `hashCode()` Returns a hash code value for the object.
    `boolean` | `isBalancingNeeded(double threshold)` Computes if this node needs balancing at all.
    `void` | `setDataNodeIP(String ipaddress)` Sets the IP address of this Node.
    `void` | `setDataNodeName(String name)` Sets node's DNS name.
    `void` | `setDataNodePort(int port)` Sets the DataNode Port number.
    `void` | `setDataNodeUUID(String nodeID)` Sets Datanode UUID.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DiskBalancerDataNode

          public DiskBalancerDataNode()

      Constructs an Empty Data Node.

    - #### DiskBalancerDataNode

          public DiskBalancerDataNode(String dataNodeID)

      Constructs a DataNode.
      Parameters:
        `dataNodeID` - - Node ID

  - ### Method Detail

    - #### getDataNodeIP

          public String getDataNodeIP()

      Returns the IP address of this Node.
      Returns:
        IP Address string

    - #### setDataNodeIP

          public void setDataNodeIP(String ipaddress)

      Sets the IP address of this Node.
      Parameters:
        `ipaddress` - - IP Address

    - #### getDataNodePort

          public int getDataNodePort()

      Returns the Port of this DataNode.
      Returns:
        Port Number

    - #### setDataNodePort

          public void setDataNodePort(int port)

      Sets the DataNode Port number.
      Parameters:
        `port` - - Datanode Port Number

    - #### getDataNodeName

          public String getDataNodeName()

      Get DataNode DNS name.
      Returns:
        name of the node

    - #### setDataNodeName

          public void setDataNodeName(String name)

      Sets node's DNS name.
      Parameters:
        `name` - - Data node name

    - #### getVolumeSets

          public Map<String,DiskBalancerVolumeSet> getVolumeSets()

      Returns the Volume sets on this node.
      Returns:
        a Map of VolumeSets

    - #### getDataNodeUUID

          public String getDataNodeUUID()

      Returns datanode ID.

    - #### setDataNodeUUID

          public void setDataNodeUUID(String nodeID)

      Sets Datanode UUID.
      Parameters:
        `nodeID` - - Node ID.

    - #### equals

          public boolean equals(Object obj)

      Indicates whether some other object is "equal to" this one.
      Overrides:
        `equals` in class `Object`

    - #### compareTo

          public int compareTo(DiskBalancerDataNode that)

      Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
      Specified by:
        `compareTo` in interface `Comparable<DiskBalancerDataNode>`
      Parameters:
        `that` - the object to be compared.
      Returns:
        a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
      Throws:
        `NullPointerException` - if the specified object is null
        `ClassCastException` - if the specified object's type prevents it from being compared to this object.

    - #### hashCode

          public int hashCode()

      Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by `HashMap`.
      Overrides:
        `hashCode` in class `Object`

    - #### getNodeDataDensity

          public double getNodeDataDensity()

      returns NodeDataDensity Metric.
      Returns:
        float

    - #### computeNodeDensity

          public void computeNodeDensity()

      computes nodes data density.

      This metric allows us to compare different nodes and how well the data is spread across a set of volumes inside the node.

    - #### isBalancingNeeded

          public boolean isBalancingNeeded(double threshold)

      Computes if this node needs balancing at all.
      Parameters:
        `threshold` - - Percentage
      Returns:
        true or false

    - #### addVolume

          public void addVolume(DiskBalancerVolume volume)
                         throws Exception

      Adds a volume to the DataNode.

      it is assumed that we have one thread per node hence this call is not synchronised neither is the map is protected.
      Parameters:
        `volume` - - volume
      Throws:
        `Exception`

    - #### getVolumeCount

          public int getVolumeCount()

      Returns how many volumes are in the DataNode.
      Returns:
        int

Copyright © 2008–2022 Apache Software Foundation. All rights reserved.