Class DiskBalancer.DiskBalancerMover

java.lang.Object
org.apache.hadoop.hdfs.server.datanode.DiskBalancer.DiskBalancerMover
All Implemented Interfaces:
DiskBalancer.BlockMover
Enclosing class:
DiskBalancer

public static class DiskBalancer.DiskBalancerMover extends Object implements DiskBalancer.BlockMover
Actual DataMover class for DiskBalancer.

  • Constructor Summary

    Constructors
    Constructor
    Description
    DiskBalancerMover(FsDatasetSpi dataset, org.apache.hadoop.conf.Configuration conf)
    Constructs diskBalancerMover.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    computeDelay(long bytesCopied, long timeUsed, org.apache.hadoop.hdfs.server.datanode.DiskBalancerWorkItem item)
    Computes sleep delay needed based on the block that just got copied. we copy using a burst mode, that is we let the copy proceed in full throttle.
    void
    copyBlocks(DiskBalancer.VolumePair pair, org.apache.hadoop.hdfs.server.datanode.DiskBalancerWorkItem item)
    Copies blocks from a set of volumes.
    Returns a pointer to the current dataset we are operating against.
    long
    Number of seconds elapsed.
    long
    Returns time when this plan started executing.
    void
    Signals copy block to exit.
    void
    Sets Diskmover copyblocks into runnable state.
    boolean
    Returns the shouldRun boolean flag.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DiskBalancerMover

      public DiskBalancerMover(FsDatasetSpi dataset, org.apache.hadoop.conf.Configuration conf)
      Constructs diskBalancerMover.
      Parameters:
      dataset - Dataset
      conf - Configuration
  • Method Details

    • setRunnable

      public void setRunnable()
      Sets Diskmover copyblocks into runnable state.
      Specified by:
      setRunnable in interface DiskBalancer.BlockMover
    • setExitFlag

      public void setExitFlag()
      Signals copy block to exit.
      Specified by:
      setExitFlag in interface DiskBalancer.BlockMover
    • shouldRun

      public boolean shouldRun()
      Returns the shouldRun boolean flag.
    • computeDelay

      @VisibleForTesting public long computeDelay(long bytesCopied, long timeUsed, org.apache.hadoop.hdfs.server.datanode.DiskBalancerWorkItem item)
      Computes sleep delay needed based on the block that just got copied. we copy using a burst mode, that is we let the copy proceed in full throttle. Once a copy is done, we compute how many bytes have been transferred and try to average it over the user specified bandwidth. In other words, This code implements a poor man's token bucket algorithm for traffic shaping.
      Parameters:
      bytesCopied - - byteCopied.
      timeUsed - in milliseconds
      item - DiskBalancerWorkItem
      Returns:
      sleep delay in Milliseconds.
    • copyBlocks

      public void copyBlocks(DiskBalancer.VolumePair pair, org.apache.hadoop.hdfs.server.datanode.DiskBalancerWorkItem item)
      Copies blocks from a set of volumes.
      Specified by:
      copyBlocks in interface DiskBalancer.BlockMover
      Parameters:
      pair - - Source and Destination Volumes.
      item - - Number of bytes to move from volumes.
    • getDataset

      public FsDatasetSpi getDataset()
      Returns a pointer to the current dataset we are operating against.
      Specified by:
      getDataset in interface DiskBalancer.BlockMover
      Returns:
      FsDatasetSpi
    • getStartTime

      public long getStartTime()
      Returns time when this plan started executing.
      Specified by:
      getStartTime in interface DiskBalancer.BlockMover
      Returns:
      Start time in milliseconds.
    • getElapsedSeconds

      public long getElapsedSeconds()
      Number of seconds elapsed.
      Specified by:
      getElapsedSeconds in interface DiskBalancer.BlockMover
      Returns:
      time in seconds