Class BlockPlacementPolicyWithUpgradeDomain
java.lang.Object
org.apache.hadoop.hdfs.server.blockmanagement.BlockPlacementPolicy
org.apache.hadoop.hdfs.server.blockmanagement.BlockPlacementPolicyDefault
org.apache.hadoop.hdfs.server.blockmanagement.BlockPlacementPolicyWithUpgradeDomain
@Private
@Evolving
public class BlockPlacementPolicyWithUpgradeDomain
extends BlockPlacementPolicyDefault
The class is responsible for choosing the desired number of targets
for placing block replicas that honors upgrade domain policy.
Here is the replica placement strategy. If the writer is on a datanode,
the 1st replica is placed on the local machine,
otherwise a random datanode. The 2nd replica is placed on a datanode
that is on a different rack. The 3rd replica is placed on a datanode
which is on a different node of the rack as the second replica.
All 3 replicas have unique upgrade domains.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.hdfs.server.blockmanagement.BlockPlacementPolicyDefault
BlockPlacementPolicyDefault.NodeNotChosenReasonNested classes/interfaces inherited from class org.apache.hadoop.hdfs.server.blockmanagement.BlockPlacementPolicy
BlockPlacementPolicy.NotEnoughReplicasException -
Field Summary
Fields inherited from class org.apache.hadoop.hdfs.server.blockmanagement.BlockPlacementPolicyDefault
clusterMap, considerLoad, considerLoadFactor, heartbeatInterval, host2datanodeMap, tolerateHeartbeatMultiplierFields inherited from class org.apache.hadoop.hdfs.server.blockmanagement.BlockPlacementPolicy
LOG -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetUpgradeDomainWithDefaultValue(org.apache.hadoop.hdfs.protocol.DatanodeInfo datanodeInfo) voidinitialize(org.apache.hadoop.conf.Configuration conf, FSClusterStats stats, org.apache.hadoop.net.NetworkTopology clusterMap, org.apache.hadoop.hdfs.server.blockmanagement.Host2NodesMap host2datanodeMap) Used to setup a BlockPlacementPolicy object.protected booleanisGoodDatanode(DatanodeDescriptor node, int maxTargetPerRack, boolean considerLoad, List<DatanodeStorageInfo> results, boolean avoidStaleNodes) booleanisMovable(Collection<org.apache.hadoop.hdfs.protocol.DatanodeInfo> locs, org.apache.hadoop.hdfs.protocol.DatanodeInfo source, org.apache.hadoop.hdfs.protocol.DatanodeInfo target) Check if the move is allowed.protected Collection<DatanodeStorageInfo>pickupReplicaSet(Collection<DatanodeStorageInfo> moreThanOne, Collection<DatanodeStorageInfo> exactlyOne, Map<String, List<DatanodeStorageInfo>> rackMap) Pick up replica node set for deleting replica as over-replicated.verifyBlockPlacement(org.apache.hadoop.hdfs.protocol.DatanodeInfo[] locs, int numberOfReplicas) Verify if the block's placement meets requirement of placement policy, i.e. replicas are placed on no less than minRacks racks in the system.Methods inherited from class org.apache.hadoop.hdfs.server.blockmanagement.BlockPlacementPolicyDefault
addToExcludedNodes, chooseDataNode, chooseDataNode, chooseFavouredNodes, chooseLocalOrFavoredStorage, chooseLocalRack, chooseLocalStorage, chooseLocalStorage, chooseRandom, chooseRandom, chooseRemoteRack, chooseReplicasToDelete, chooseReplicaToDelete, chooseTarget, chooseTarget, chooseTargetInOrder, getExcludeSlowNodesEnabled, getMaxNodesPerRack, getMinBlocksForWrite, logNodeIsNotChosen, setExcludeSlowNodesEnabled, setMinBlocksForWriteMethods inherited from class org.apache.hadoop.hdfs.server.blockmanagement.BlockPlacementPolicy
adjustSetsWithChosenReplica, getDatanodeInfo, getRack, splitNodesWithRack
-
Constructor Details
-
BlockPlacementPolicyWithUpgradeDomain
public BlockPlacementPolicyWithUpgradeDomain()
-
-
Method Details
-
initialize
public void initialize(org.apache.hadoop.conf.Configuration conf, FSClusterStats stats, org.apache.hadoop.net.NetworkTopology clusterMap, org.apache.hadoop.hdfs.server.blockmanagement.Host2NodesMap host2datanodeMap) Description copied from class:BlockPlacementPolicyUsed to setup a BlockPlacementPolicy object. This should be defined by all implementations of a BlockPlacementPolicy.- Overrides:
initializein classBlockPlacementPolicyDefault- Parameters:
conf- the configuration objectstats- retrieve cluster status from hereclusterMap- cluster topology
-
isGoodDatanode
protected boolean isGoodDatanode(DatanodeDescriptor node, int maxTargetPerRack, boolean considerLoad, List<DatanodeStorageInfo> results, boolean avoidStaleNodes) -
getUpgradeDomainWithDefaultValue
public String getUpgradeDomainWithDefaultValue(org.apache.hadoop.hdfs.protocol.DatanodeInfo datanodeInfo) -
verifyBlockPlacement
public BlockPlacementStatus verifyBlockPlacement(org.apache.hadoop.hdfs.protocol.DatanodeInfo[] locs, int numberOfReplicas) Description copied from class:BlockPlacementPolicyVerify if the block's placement meets requirement of placement policy, i.e. replicas are placed on no less than minRacks racks in the system.- Overrides:
verifyBlockPlacementin classBlockPlacementPolicyDefault- Parameters:
locs- block with locationsnumberOfReplicas- replica number of file to be verified- Returns:
- the result of verification
-
pickupReplicaSet
protected Collection<DatanodeStorageInfo> pickupReplicaSet(Collection<DatanodeStorageInfo> moreThanOne, Collection<DatanodeStorageInfo> exactlyOne, Map<String, List<DatanodeStorageInfo>> rackMap) Description copied from class:BlockPlacementPolicyDefaultPick up replica node set for deleting replica as over-replicated. First set contains replica nodes on rack with more than one replica while second set contains remaining replica nodes. If only 1 rack, pick all. If 2 racks, pick all that have more than 1 replicas on the same rack; if no such replicas, pick all. If 3 or more racks, pick all.- Overrides:
pickupReplicaSetin classBlockPlacementPolicyDefault
-
isMovable
public boolean isMovable(Collection<org.apache.hadoop.hdfs.protocol.DatanodeInfo> locs, org.apache.hadoop.hdfs.protocol.DatanodeInfo source, org.apache.hadoop.hdfs.protocol.DatanodeInfo target) Description copied from class:BlockPlacementPolicyCheck if the move is allowed. Used by balancer and other tools.- Overrides:
isMovablein classBlockPlacementPolicyDefault- Parameters:
locs- all replicas including source and targetsource- source replica of the movetarget- target replica of the move
-