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 Details

    • DiskBalancerDataNode

      public DiskBalancerDataNode()
      Constructs an Empty Data Node.
    • DiskBalancerDataNode

      public DiskBalancerDataNode(String dataNodeID)
      Constructs a DataNode.
      Parameters:
      dataNodeID - - Node ID
  • Method Details

    • 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