Class DiskBalancerDataNode
java.lang.Object
org.apache.hadoop.hdfs.server.diskbalancer.datamodel.DiskBalancerDataNode
- All Implemented Interfaces:
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
ConstructorsConstructorDescriptionConstructs an Empty Data Node.DiskBalancerDataNode(String dataNodeID) Constructs a DataNode. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddVolume(DiskBalancerVolume volume) Adds a volume to the DataNode.intCompares this object with the specified object for order.voidComputes nodes data density.booleanIndicates whether some other object is "equal to" this one.Returns the IP address of this Node.Get DataNode DNS name.intReturns the Port of this DataNode.Returns datanode ID.doubleReturns NodeDataDensity Metric.intReturns how many volumes are in the DataNode.Returns the Volume sets on this node.inthashCode()Returns a hash code value for the object.booleanisBalancingNeeded(double threshold) Computes if this node needs balancing at all.voidsetDataNodeIP(String ipaddress) Sets the IP address of this Node.voidsetDataNodeName(String name) Sets node's DNS name.voidsetDataNodePort(int port) Sets the DataNode Port number.voidsetDataNodeUUID(String nodeID) Sets Datanode UUID.
-
Constructor Details
-
DiskBalancerDataNode
public DiskBalancerDataNode()Constructs an Empty Data Node. -
DiskBalancerDataNode
Constructs a DataNode.- Parameters:
dataNodeID- - Node ID
-
-
Method Details
-
getDataNodeIP
Returns the IP address of this Node.- Returns:
- IP Address string
-
setDataNodeIP
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
Get DataNode DNS name.- Returns:
- name of the node
-
setDataNodeName
Sets node's DNS name.- Parameters:
name- - Data node name
-
getVolumeSets
Returns the Volume sets on this node.- Returns:
- a Map of VolumeSets
-
getDataNodeUUID
Returns datanode ID. -
setDataNodeUUID
Sets Datanode UUID.- Parameters:
nodeID- - Node ID.
-
equals
Indicates whether some other object is "equal to" this one. -
compareTo
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:
compareToin interfaceComparable<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 nullClassCastException- 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 byHashMap. -
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
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
-