@InterfaceAudience.Private public abstract class BlockPlacementPolicy extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static class |
BlockPlacementPolicy.NotEnoughReplicasException |
| 构造器和说明 |
|---|
BlockPlacementPolicy() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
adjustSetsWithChosenReplica(Map<String,List<DatanodeDescriptor>> rackMap,
List<DatanodeDescriptor> moreThanOne,
List<DatanodeDescriptor> exactlyOne,
DatanodeInfo cur)
Adjust rackmap, moreThanOne, and exactlyOne after removing replica on cur.
|
abstract DatanodeDescriptor |
chooseReplicaToDelete(FSInodeInfo srcInode,
Block block,
short replicationFactor,
Collection<DatanodeDescriptor> existingReplicas,
Collection<DatanodeDescriptor> moreExistingReplicas)
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,
HashMap<Node,Node> excludedNodes,
long blocksize)
choose numOfReplicas nodes for writer to replicate
a block with size blocksize
If not, return as many as we can.
|
abstract 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.
|
static BlockPlacementPolicy |
getInstance(Configuration conf,
FSClusterStats stats,
NetworkTopology clusterMap)
Get an instance of the configured Block Placement Policy based on the
value of the configuration paramater dfs.block.replicator.classname.
|
protected String |
getRack(DatanodeInfo datanode)
Get rack string from a data node
|
protected abstract void |
initialize(Configuration conf,
FSClusterStats stats,
NetworkTopology clusterMap)
Used to setup a BlockPlacementPolicy object.
|
void |
splitNodesWithRack(Collection<DatanodeDescriptor> dataNodes,
Map<String,List<DatanodeDescriptor>> rackMap,
List<DatanodeDescriptor> moreThanOne,
List<DatanodeDescriptor> exactlyOne)
Split data nodes into two sets, one set includes nodes on rack with
more than one replica, the other set contains the remaining nodes.
|
abstract 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.
|
public abstract DatanodeDescriptor[] chooseTarget(String srcPath, int numOfReplicas, DatanodeDescriptor writer, List<DatanodeDescriptor> chosenNodes, HashMap<Node,Node> excludedNodes, 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.excludedNodes: - datanodes that should not be considered as targets.blocksize - size of the data to be written.public abstract int verifyBlockPlacement(String srcPath, LocatedBlock lBlk, int minRacks)
srcPath - the full pathname of the file to be verifiedlBlk - block with locationsminRacks - number of racks the block should be replicated topublic abstract DatanodeDescriptor chooseReplicaToDelete(FSInodeInfo srcInode, Block block, short replicationFactor, Collection<DatanodeDescriptor> existingReplicas, Collection<DatanodeDescriptor> moreExistingReplicas)
srcInode - 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 blockexistingReplicas - The replica locations of this block that are present
on at least two unique racks.moreExistingReplicas - Replica locations of this block that are not
listed in the previous parameter.protected abstract void initialize(Configuration conf, FSClusterStats stats, NetworkTopology clusterMap)
conf - the configuration objectstats - retrieve cluster status from hereclusterMap - cluster topologypublic static BlockPlacementPolicy getInstance(Configuration conf, FSClusterStats stats, NetworkTopology clusterMap)
conf - the configuration to be usedstats - an object that is used to retrieve the load on the clusterclusterMap - the network topology of the clusterpublic DatanodeDescriptor[] chooseTarget(String srcPath, int numOfReplicas, DatanodeDescriptor writer, HashMap<Node,Node> excludedNodes, long blocksize)
srcPath - a string representation of the file for which chooseTarget is invokednumOfReplicas - number of replicas wanted.writer - the writer's machine, null if not in the cluster.blocksize - size of the data to be written.excludedNodes - datanodes that should not be considered as targets.public void adjustSetsWithChosenReplica(Map<String,List<DatanodeDescriptor>> rackMap, List<DatanodeDescriptor> moreThanOne, List<DatanodeDescriptor> exactlyOne, DatanodeInfo cur)
rackMap - a map from rack to replicamoreThanOne - The List of replica nodes on rack which has more than
one replicaexactlyOne - The List of replica nodes on rack with only one replicacur - current replica to removeprotected String getRack(DatanodeInfo datanode)
datanode - public void splitNodesWithRack(Collection<DatanodeDescriptor> dataNodes, Map<String,List<DatanodeDescriptor>> rackMap, List<DatanodeDescriptor> moreThanOne, List<DatanodeDescriptor> exactlyOne)
dataNodes - rackMap - a map from rack to datanodesmoreThanOne - contains nodes on rack with more than one replicaexactlyOne - remains contains the remaining nodesCopyright © 2009 The Apache Software Foundation