@Private
public class DiskBalancer
extends java.lang.Object
Here is the high level logic executed by this class. Users can submit disk balancing plans using submitPlan calls. After a set of sanity checks the plan is admitted and put into workMap.
The executePlan launches a thread that picks up work from workMap and hands it over to the BlockMover#copyBlocks function.
Constraints :
Only one plan can be executing in a datanode at any given time. This is ensured by checking the future handle of the worker thread in submitPlan.
| Modifier and Type | Class | Description |
|---|---|---|
static interface |
DiskBalancer.BlockMover |
BlockMover supports moving blocks across Volumes.
|
static class |
DiskBalancer.DiskBalancerMover |
Actual DataMover class for DiskBalancer.
|
static class |
DiskBalancer.VolumePair |
Holds source and dest volumes UUIDs and their BasePaths
that disk balancer will be operating against.
|
| Modifier and Type | Field | Description |
|---|---|---|
static org.slf4j.Logger |
LOG |
| Constructor | Description |
|---|---|
DiskBalancer(java.lang.String dataNodeUUID,
org.apache.hadoop.conf.Configuration conf,
DiskBalancer.BlockMover blockMover) |
Constructs a Disk Balancer object.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
cancelPlan(java.lang.String planID) |
Cancels a running plan.
|
long |
getBandwidth() |
Returns the current bandwidth.
|
long |
getPlanValidityInterval() |
Gets maximum amount of time disk balancer plan is valid.
|
long |
getPlanValidityIntervalInConfig() |
Gets maximum amount of time disk balancer plan is valid in config.
|
java.lang.String |
getVolumeNames() |
Returns a volume ID to Volume base path map.
|
boolean |
isDiskBalancerEnabled() |
Returns the value indicating if diskBalancer is enabled.
|
org.apache.hadoop.hdfs.server.datanode.DiskBalancerWorkStatus |
queryWorkStatus() |
Returns the current work status of a previously submitted Plan.
|
void |
setDiskBalancerEnabled(boolean diskBalancerEnabled) |
Sets Disk balancer is to enable or not to enable.
|
void |
setPlanValidityInterval(long planValidityInterval) |
Sets maximum amount of time disk balancer plan is valid.
|
void |
shutdown() |
Shutdown disk balancer services.
|
void |
submitPlan(java.lang.String planId,
long planVersion,
java.lang.String planFileName,
java.lang.String planData,
boolean force) |
Takes a client submitted plan and converts into a set of work items that
can be executed by the blockMover.
|
public DiskBalancer(java.lang.String dataNodeUUID,
org.apache.hadoop.conf.Configuration conf,
DiskBalancer.BlockMover blockMover)
dataNodeUUID - - Data node UUIDconf - - Hdfs ConfigblockMover - - Object that supports moving blocks.public void shutdown()
public void submitPlan(java.lang.String planId,
long planVersion,
java.lang.String planFileName,
java.lang.String planData,
boolean force)
throws DiskBalancerException
planId - - A SHA-1 of the plan stringplanVersion - - version of the plan string - for future use.planFileName - - Plan file nameplanData - - Plan data in json formatforce - - Skip some validations and execute the plan file.DiskBalancerExceptionpublic org.apache.hadoop.hdfs.server.datanode.DiskBalancerWorkStatus queryWorkStatus()
throws DiskBalancerException
DiskBalancerExceptionpublic void cancelPlan(java.lang.String planID)
throws DiskBalancerException
planID - - Hash of the plan to cancel.DiskBalancerExceptionpublic java.lang.String getVolumeNames()
throws DiskBalancerException
DiskBalancerExceptionpublic long getBandwidth()
throws DiskBalancerException
DiskBalancerExceptionpublic void setDiskBalancerEnabled(boolean diskBalancerEnabled)
diskBalancerEnabled - true, enable diskBalancer, otherwise false to disable it.@VisibleForTesting public boolean isDiskBalancerEnabled()
public void setPlanValidityInterval(long planValidityInterval)
planValidityInterval - - maximum amount of time in the unit of milliseconds.@VisibleForTesting public long getPlanValidityInterval()
@VisibleForTesting public long getPlanValidityIntervalInConfig()
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.