@InterfaceAudience.Private public class BlockPlacementPolicyDefault extends BlockPlacementPolicy
BlockPlacementPolicy.NotEnoughReplicasException
Modifier and Type | Field and Description |
---|---|
protected NetworkTopology |
clusterMap |
protected boolean |
considerLoad |
protected long |
heartbeatInterval |
protected ThreadLocal<StringBuilder> |
threadLocalBuilder |
protected int |
tolerateHeartbeatMultiplier
A miss of that many heartbeats is tolerated for replica deletion policy.
|
Modifier | Constructor and Description |
---|---|
protected |
BlockPlacementPolicyDefault() |
Modifier and Type | Method and Description |
---|---|
protected int |
addToExcludedNodes(DatanodeDescriptor localMachine,
HashMap<Node,Node> excludedNodes)
Add localMachine and related nodes to excludedNodes
for next replica choosing.
|
protected void |
adjustExcludedNodes(HashMap<Node,Node> excludedNodes,
Node chosenNode)
After choosing a node to place replica, adjust excluded nodes accordingly.
|
protected DatanodeDescriptor |
chooseLocalNode(DatanodeDescriptor localMachine,
HashMap<Node,Node> excludedNodes,
long blocksize,
int maxNodesPerRack,
List<DatanodeDescriptor> results,
boolean avoidStaleNodes) |
protected DatanodeDescriptor |
chooseLocalRack(DatanodeDescriptor localMachine,
HashMap<Node,Node> excludedNodes,
long blocksize,
int maxNodesPerRack,
List<DatanodeDescriptor> results,
boolean avoidStaleNodes) |
protected void |
chooseRandom(int numOfReplicas,
String nodes,
HashMap<Node,Node> excludedNodes,
long blocksize,
int maxNodesPerRack,
List<DatanodeDescriptor> results,
boolean avoidStaleNodes) |
protected DatanodeDescriptor |
chooseRandom(String nodes,
HashMap<Node,Node> excludedNodes,
long blocksize,
int maxNodesPerRack,
List<DatanodeDescriptor> results,
boolean avoidStaleNodes) |
protected void |
chooseRemoteRack(int numOfReplicas,
DatanodeDescriptor localMachine,
HashMap<Node,Node> excludedNodes,
long blocksize,
int maxReplicasPerRack,
List<DatanodeDescriptor> results,
boolean avoidStaleNodes) |
DatanodeDescriptor |
chooseReplicaToDelete(BlockCollection bc,
Block block,
short replicationFactor,
Collection<DatanodeDescriptor> first,
Collection<DatanodeDescriptor> second)
Decide whether deleting the specified replica of the block still makes
the block conform to the configured block placement policy.
|
DatanodeDescriptor[] |
chooseTarget(String srcPath,
int numOfReplicas,
DatanodeDescriptor writer,
List<DatanodeDescriptor> chosenNodes,
boolean returnChosenNodes,
HashMap<Node,Node> excludedNodes,
long blocksize)
choose numOfReplicas data nodes for writer
to re-replicate a block with size blocksize
If not, return as many as we can.
|
DatanodeDescriptor[] |
chooseTarget(String srcPath,
int numOfReplicas,
DatanodeDescriptor writer,
List<DatanodeDescriptor> chosenNodes,
long blocksize)
choose numOfReplicas data nodes for writer
to re-replicate a block with size blocksize
If not, return as many as we can.
|
void |
initialize(Configuration conf,
FSClusterStats stats,
NetworkTopology clusterMap)
Used to setup a BlockPlacementPolicy object.
|
protected boolean |
isGoodTarget(DatanodeDescriptor node,
long blockSize,
int maxTargetPerRack,
boolean considerLoad,
List<DatanodeDescriptor> results,
boolean avoidStaleNodes)
Determine if a node is a good target.
|
protected Iterator<DatanodeDescriptor> |
pickupReplicaSet(Collection<DatanodeDescriptor> first,
Collection<DatanodeDescriptor> second)
Pick up replica node set for deleting replica as over-replicated.
|
int |
verifyBlockPlacement(String srcPath,
LocatedBlock lBlk,
int minRacks)
Verify that the block is replicated on at least minRacks different racks
if there is more than minRacks rack in the system.
|
adjustSetsWithChosenReplica, getInstance, getRack, splitNodesWithRack
protected boolean considerLoad
protected NetworkTopology clusterMap
protected long heartbeatInterval
protected int tolerateHeartbeatMultiplier
protected ThreadLocal<StringBuilder> threadLocalBuilder
public void initialize(Configuration conf, FSClusterStats stats, NetworkTopology clusterMap)
BlockPlacementPolicy
initialize
in class BlockPlacementPolicy
conf
- the configuration objectstats
- retrieve cluster status from hereclusterMap
- cluster topologypublic DatanodeDescriptor[] chooseTarget(String srcPath, int numOfReplicas, DatanodeDescriptor writer, List<DatanodeDescriptor> chosenNodes, long blocksize)
BlockPlacementPolicy
srcPath
- the file to which this chooseTargets is being invoked.numOfReplicas
- additional number of replicas wanted.writer
- the writer's machine, null if not in the cluster.chosenNodes
- datanodes that have been chosen as targets.blocksize
- size of the data to be written.public DatanodeDescriptor[] chooseTarget(String srcPath, int numOfReplicas, DatanodeDescriptor writer, List<DatanodeDescriptor> chosenNodes, boolean returnChosenNodes, HashMap<Node,Node> excludedNodes, long blocksize)
BlockPlacementPolicy
chooseTarget
in class BlockPlacementPolicy
srcPath
- the file to which this chooseTargets is being invoked.numOfReplicas
- additional number of replicas wanted.writer
- the writer's machine, null if not in the cluster.chosenNodes
- datanodes that have been chosen as targets.returnChosenNodes
- decide if the chosenNodes are returned.excludedNodes
- datanodes that should not be considered as targets.blocksize
- size of the data to be written.protected DatanodeDescriptor chooseLocalNode(DatanodeDescriptor localMachine, HashMap<Node,Node> excludedNodes, long blocksize, int maxNodesPerRack, List<DatanodeDescriptor> results, boolean avoidStaleNodes) throws BlockPlacementPolicy.NotEnoughReplicasException
protected int addToExcludedNodes(DatanodeDescriptor localMachine, HashMap<Node,Node> excludedNodes)
protected DatanodeDescriptor chooseLocalRack(DatanodeDescriptor localMachine, HashMap<Node,Node> excludedNodes, long blocksize, int maxNodesPerRack, List<DatanodeDescriptor> results, boolean avoidStaleNodes) throws BlockPlacementPolicy.NotEnoughReplicasException
protected void chooseRemoteRack(int numOfReplicas, DatanodeDescriptor localMachine, HashMap<Node,Node> excludedNodes, long blocksize, int maxReplicasPerRack, List<DatanodeDescriptor> results, boolean avoidStaleNodes) throws BlockPlacementPolicy.NotEnoughReplicasException
protected DatanodeDescriptor chooseRandom(String nodes, HashMap<Node,Node> excludedNodes, long blocksize, int maxNodesPerRack, List<DatanodeDescriptor> results, boolean avoidStaleNodes) throws BlockPlacementPolicy.NotEnoughReplicasException
protected void chooseRandom(int numOfReplicas, String nodes, HashMap<Node,Node> excludedNodes, long blocksize, int maxNodesPerRack, List<DatanodeDescriptor> results, boolean avoidStaleNodes) throws BlockPlacementPolicy.NotEnoughReplicasException
protected void adjustExcludedNodes(HashMap<Node,Node> excludedNodes, Node chosenNode)
excludedNodes
- chosenNode
- protected boolean isGoodTarget(DatanodeDescriptor node, long blockSize, int maxTargetPerRack, boolean considerLoad, List<DatanodeDescriptor> results, boolean avoidStaleNodes)
node
- The target nodeblockSize
- Size of blockmaxTargetPerRack
- Maximum number of targets per rack. The value of
this parameter depends on the number of racks in
the cluster and total number of replicas for a blockconsiderLoad
- whether or not to consider load of the target noderesults
- A list containing currently chosen nodes. Used to check if
too many nodes has been chosen in the target rack.avoidStaleNodes
- Whether or not to avoid choosing stale nodespublic int verifyBlockPlacement(String srcPath, LocatedBlock lBlk, int minRacks)
BlockPlacementPolicy
verifyBlockPlacement
in class BlockPlacementPolicy
srcPath
- the full pathname of the file to be verifiedlBlk
- block with locationsminRacks
- number of racks the block should be replicated topublic DatanodeDescriptor chooseReplicaToDelete(BlockCollection bc, Block block, short replicationFactor, Collection<DatanodeDescriptor> first, Collection<DatanodeDescriptor> second)
BlockPlacementPolicy
chooseReplicaToDelete
in class BlockPlacementPolicy
bc
- block collection of file to which block-to-be-deleted belongsblock
- The block to be deletedreplicationFactor
- The required number of replicas for this blockfirst
- The replica locations of this block that are present
on at least two unique racks.second
- Replica locations of this block that are not
listed in the previous parameter.protected Iterator<DatanodeDescriptor> pickupReplicaSet(Collection<DatanodeDescriptor> first, Collection<DatanodeDescriptor> second)
Copyright © 2013 Apache Software Foundation. All rights reserved.