@InterfaceAudience.Private public class BlockPlacementPolicyDefault extends BlockPlacementPolicy
BlockPlacementPolicy.NotEnoughReplicasException
限定符和类型 | 字段和说明 |
---|---|
protected NetworkTopology |
clusterMap |
protected boolean |
considerLoad |
限定符和类型 | 方法和说明 |
---|---|
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(FSInodeInfo inode,
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(FSInodeInfo srcInode,
int numOfReplicas,
DatanodeDescriptor writer,
List<DatanodeDescriptor> chosenNodes,
long blocksize)
choose numOfReplicas data nodes for writer
If not, return as many as we can.
|
DatanodeDescriptor[] |
chooseTarget(String srcPath,
int numOfReplicas,
DatanodeDescriptor writer,
List<DatanodeDescriptor> chosenNodes,
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 maxTargetPerLoc,
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, chooseTarget, getInstance, getRack, splitNodesWithRack
protected boolean considerLoad
protected NetworkTopology clusterMap
public void initialize(Configuration conf, FSClusterStats stats, NetworkTopology clusterMap)
initialize
在类中 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)
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, HashMap<Node,Node> excludedNodes, long blocksize)
chooseTarget
在类中 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(FSInodeInfo srcInode, int numOfReplicas, DatanodeDescriptor writer, List<DatanodeDescriptor> chosenNodes, long blocksize)
srcInode
- The inode of the file for which chooseTarget 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.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 maxTargetPerLoc, boolean considerLoad, List<DatanodeDescriptor> results, boolean avoidStaleNodes)
node
- The target nodeblockSize
- Size of blockmaxTargetPerLoc
- 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 nodes.public int verifyBlockPlacement(String srcPath, LocatedBlock lBlk, int minRacks)
verifyBlockPlacement
在类中 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(FSInodeInfo inode, Block block, short replicationFactor, Collection<DatanodeDescriptor> first, Collection<DatanodeDescriptor> second)
chooseReplicaToDelete
在类中 BlockPlacementPolicy
inode
- The inode of the file to which the 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 © 2009 The Apache Software Foundation