Class DiskBalancer
java.lang.Object
org.apache.hadoop.hdfs.server.datanode.DiskBalancer
Worker class for Disk Balancer.
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceBlockMover supports moving blocks across Volumes.static classActual DataMover class for DiskBalancer.static classHolds source and dest volumes UUIDs and their BasePaths that disk balancer will be operating against. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDiskBalancer(String dataNodeUUID, org.apache.hadoop.conf.Configuration conf, DiskBalancer.BlockMover blockMover) Constructs a Disk Balancer object. -
Method Summary
Modifier and TypeMethodDescriptionvoidcancelPlan(String planID) Cancels a running plan.longReturns the current bandwidth.longGets maximum amount of time disk balancer plan is valid.longGets maximum amount of time disk balancer plan is valid in config.Returns a volume ID to Volume base path map.booleanReturns the value indicating if diskBalancer is enabled.org.apache.hadoop.hdfs.server.datanode.DiskBalancerWorkStatusReturns the current work status of a previously submitted Plan.voidsetDiskBalancerEnabled(boolean diskBalancerEnabled) Sets Disk balancer is to enable or not to enable.voidsetPlanValidityInterval(long planValidityInterval) Sets maximum amount of time disk balancer plan is valid.voidshutdown()Shutdown disk balancer services.voidsubmitPlan(String planId, long planVersion, String planFileName, String planData, boolean force) Takes a client submitted plan and converts into a set of work items that can be executed by the blockMover.
-
Field Details
-
LOG
@VisibleForTesting public static final org.slf4j.Logger LOG
-
-
Constructor Details
-
DiskBalancer
public DiskBalancer(String dataNodeUUID, org.apache.hadoop.conf.Configuration conf, DiskBalancer.BlockMover blockMover) Constructs a Disk Balancer object. This object takes care of reading a NodePlan and executing it against a set of volumes.- Parameters:
dataNodeUUID- - Data node UUIDconf- - Hdfs ConfigblockMover- - Object that supports moving blocks.
-
-
Method Details
-
shutdown
public void shutdown()Shutdown disk balancer services. -
submitPlan
public void submitPlan(String planId, long planVersion, String planFileName, String planData, boolean force) throws DiskBalancerException Takes a client submitted plan and converts into a set of work items that can be executed by the blockMover.- Parameters:
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.- Throws:
DiskBalancerException
-
queryWorkStatus
public org.apache.hadoop.hdfs.server.datanode.DiskBalancerWorkStatus queryWorkStatus() throws DiskBalancerExceptionReturns the current work status of a previously submitted Plan.- Returns:
- DiskBalancerWorkStatus.
- Throws:
DiskBalancerException
-
cancelPlan
Cancels a running plan.- Parameters:
planID- - Hash of the plan to cancel.- Throws:
DiskBalancerException
-
getVolumeNames
Returns a volume ID to Volume base path map.- Returns:
- Json string of the volume map.
- Throws:
DiskBalancerException
-
getBandwidth
Returns the current bandwidth.- Returns:
- string representation of bandwidth.
- Throws:
DiskBalancerException
-
setDiskBalancerEnabled
public void setDiskBalancerEnabled(boolean diskBalancerEnabled) Sets Disk balancer is to enable or not to enable.- Parameters:
diskBalancerEnabled- true, enable diskBalancer, otherwise false to disable it.
-
isDiskBalancerEnabled
@VisibleForTesting public boolean isDiskBalancerEnabled()Returns the value indicating if diskBalancer is enabled.- Returns:
- boolean.
-
setPlanValidityInterval
public void setPlanValidityInterval(long planValidityInterval) Sets maximum amount of time disk balancer plan is valid.- Parameters:
planValidityInterval- - maximum amount of time in the unit of milliseconds.
-
getPlanValidityInterval
@VisibleForTesting public long getPlanValidityInterval()Gets maximum amount of time disk balancer plan is valid.- Returns:
- the maximum amount of time in milliseconds.
-
getPlanValidityIntervalInConfig
@VisibleForTesting public long getPlanValidityIntervalInConfig()Gets maximum amount of time disk balancer plan is valid in config.- Returns:
- the maximum amount of time in milliseconds.
-