|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hdfs.server.namenode.BlockPlacementPolicy
org.apache.hadoop.hdfs.server.namenode.BlockPlacementPolicyDefault
@InterfaceAudience.Private public class BlockPlacementPolicyDefault
The class is responsible for choosing the desired number of targets for placing block replicas. The replica placement strategy is that 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.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.apache.hadoop.hdfs.server.namenode.BlockPlacementPolicy |
---|
BlockPlacementPolicy.NotEnoughReplicasException |
Method Summary | |
---|---|
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<org.apache.hadoop.net.Node,org.apache.hadoop.net.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(org.apache.hadoop.conf.Configuration conf,
FSClusterStats stats,
org.apache.hadoop.net.NetworkTopology clusterMap)
Used to setup a BlockPlacementPolicy object. |
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. |
Methods inherited from class org.apache.hadoop.hdfs.server.namenode.BlockPlacementPolicy |
---|
getInstance |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public void initialize(org.apache.hadoop.conf.Configuration conf, FSClusterStats stats, org.apache.hadoop.net.NetworkTopology clusterMap)
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)
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<org.apache.hadoop.net.Node,org.apache.hadoop.net.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.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.
public int verifyBlockPlacement(String srcPath, LocatedBlock lBlk, int minRacks)
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 to
public DatanodeDescriptor chooseReplicaToDelete(FSInodeInfo inode, Block block, short replicationFactor, Collection<DatanodeDescriptor> first, Collection<DatanodeDescriptor> second)
chooseReplicaToDelete
in class 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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |