Class DiskBalancerCluster

java.lang.Object
org.apache.hadoop.hdfs.server.diskbalancer.datamodel.DiskBalancerCluster

public class DiskBalancerCluster extends Object
DiskBalancerCluster represents the nodes that we are working against.

Please Note : Semantics of inclusionList and exclusionLists.

If a non-empty inclusionList is specified then the diskBalancer assumes that the user is only interested in processing that list of nodes. This node list is checked against the exclusionList and only the nodes in inclusionList but not in exclusionList is processed.

if inclusionList is empty, then we assume that all live nodes in the nodes is to be processed by diskBalancer. In that case diskBalancer will avoid any nodes specified in the exclusionList but will process all nodes in the cluster.

In other words, an empty inclusionList is means all the nodes otherwise only a given list is processed and ExclusionList is always honored.

  • Constructor Details

    • DiskBalancerCluster

      public DiskBalancerCluster()
      Empty Constructor needed by Jackson.
    • DiskBalancerCluster

      public DiskBalancerCluster(ClusterConnector connector) throws IOException
      Constructs a DiskBalancerCluster.
      Parameters:
      connector - - ClusterConnector
      Throws:
      IOException
  • Method Details

    • parseJson

      public static DiskBalancerCluster parseJson(String json) throws IOException
      Parses a Json string and converts to DiskBalancerCluster.
      Parameters:
      json - - Json String
      Returns:
      DiskBalancerCluster
      Throws:
      IOException
    • readClusterInfo

      public void readClusterInfo() throws Exception
      readClusterInfo connects to the cluster and reads the node's data. This data is used as basis of rest of computation in DiskBalancerCluster
      Throws:
      Exception
    • getNodes

      public List<DiskBalancerDataNode> getNodes()
      Gets all DataNodes in the Cluster.
      Returns:
      Array of DisKBalancerDataNodes
    • setNodes

      public void setNodes(List<DiskBalancerDataNode> clusterNodes)
      Sets the list of nodes of this cluster.
      Parameters:
      clusterNodes - List of Nodes
    • getExclusionList

      public Set<String> getExclusionList()
      Returns the current ExclusionList.
      Returns:
      List of Nodes that are excluded from diskBalancer right now.
    • setExclusionList

      public void setExclusionList(Set<String> excludedNodes)
      sets the list of nodes to exclude from process of diskBalancer.
      Parameters:
      excludedNodes - - exclusionList of nodes.
    • getThreshold

      public float getThreshold()
      Returns the threshold value. This is used for indicating how much skew is acceptable, This is expressed as a percentage. For example to say 20% skew between volumes is acceptable set this value to 20.
      Returns:
      float
    • setThreshold

      public void setThreshold(float thresholdPercent)
      Sets the threshold value.
      Parameters:
      thresholdPercent - - float - in percentage
    • getInclusionList

      public Set<String> getInclusionList()
      Gets the Inclusion list.
      Returns:
      List of machine to be processed by diskBalancer.
    • setInclusionList

      public void setInclusionList(Set<String> includeNodes)
      Sets the inclusionList.
      Parameters:
      includeNodes - - set of machines to be processed by diskBalancer.
    • toJson

      public String toJson() throws IOException
      returns a serialized json string.
      Returns:
      String - json
      Throws:
      IOException
    • getNodesToProcess

      public List<DiskBalancerDataNode> getNodesToProcess()
      Returns the Nodes to Process which is the real list of nodes processed by diskBalancer.
      Returns:
      List of DiskBalancerDataNodes
    • setNodesToProcess

      public void setNodesToProcess(List<DiskBalancerDataNode> dnNodesToProcess)
      Sets the nodes to process.
      Parameters:
      dnNodesToProcess - - List of DataNodes to process
    • getOutput

      public String getOutput()
      Returns th output path for this cluster.
    • setOutput

      public void setOutput(String output)
      Sets the output path for this run.
      Parameters:
      output - - Path
    • createSnapshot

      public void createSnapshot(String snapShotName) throws IOException
      Writes a snapshot of the cluster to the specified directory.
      Parameters:
      snapShotName - - name of the snapshot
      Throws:
      IOException
    • computePlan

      public List<NodePlan> computePlan(double thresholdPercent)
      Compute plan takes a node and constructs a planner that creates a plan that we would like to follow.

      This function creates a thread pool and executes a planner on each node that we are supposed to plan for. Each of these planners return a NodePlan that we can persist or schedule for execution with a diskBalancer Executor.

      Parameters:
      thresholdPercent - - in percentage
      Returns:
      list of NodePlans
    • getNodeByUUID

      public DiskBalancerDataNode getNodeByUUID(String uuid)
      Returns a node by UUID.
      Parameters:
      uuid - - Node's UUID
      Returns:
      DiskBalancerDataNode.
    • getNodeByIPAddress

      public DiskBalancerDataNode getNodeByIPAddress(String ipAddresss)
      Returns a node by IP Address.
      Parameters:
      ipAddresss - - IP address String.
      Returns:
      DiskBalancerDataNode.
    • getNodeByName

      public DiskBalancerDataNode getNodeByName(String hostName)
      Returns a node by hostName.
      Parameters:
      hostName - - HostName.
      Returns:
      DiskBalancerDataNode.