org.apache.hadoop.hdfs.server.namenode
Class BlockPlacementPolicy

java.lang.Object
  extended by org.apache.hadoop.hdfs.server.namenode.BlockPlacementPolicy
Direct Known Subclasses:
BlockPlacementPolicyDefault

@InterfaceAudience.Private
public abstract class BlockPlacementPolicy
extends Object

This interface is used for choosing the desired number of targets for placing block replicas.


Nested Class Summary
static class BlockPlacementPolicy.NotEnoughReplicasException
           
 
Constructor Summary
BlockPlacementPolicy()
           
 
Method Summary
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.
static BlockPlacementPolicy getInstance(org.apache.hadoop.conf.Configuration conf, FSClusterStats stats, org.apache.hadoop.net.NetworkTopology clusterMap)
          Get an instance of the configured Block Placement Policy based on the value of the configuration paramater dfs.block.replicator.classname.
protected abstract  void initialize(org.apache.hadoop.conf.Configuration conf, FSClusterStats stats, org.apache.hadoop.net.NetworkTopology clusterMap)
          Used to setup a BlockPlacementPolicy object.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlockPlacementPolicy

public BlockPlacementPolicy()
Method Detail

verifyBlockPlacement

public 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.

Parameters:
srcPath - the full pathname of the file to be verified
lBlk - block with locations
minRacks - number of racks the block should be replicated to
Returns:
the difference between the required and the actual number of racks the block is replicated to.

chooseReplicaToDelete

public 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.

Parameters:
srcInode - The inode of the file to which the block-to-be-deleted belongs
block - The block to be deleted
replicationFactor - The required number of replicas for this block
existingReplicas - 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.
Returns:
the replica that is the best candidate for deletion

initialize

protected abstract void initialize(org.apache.hadoop.conf.Configuration conf,
                                   FSClusterStats stats,
                                   org.apache.hadoop.net.NetworkTopology clusterMap)
Used to setup a BlockPlacementPolicy object. This should be defined by all implementations of a BlockPlacementPolicy.

Parameters:
conf - the configuration object
stats - retrieve cluster status from here
clusterMap - cluster topology

getInstance

public static BlockPlacementPolicy getInstance(org.apache.hadoop.conf.Configuration conf,
                                               FSClusterStats stats,
                                               org.apache.hadoop.net.NetworkTopology clusterMap)
Get an instance of the configured Block Placement Policy based on the value of the configuration paramater dfs.block.replicator.classname.

Parameters:
conf - the configuration to be used
stats - an object thatis used to retrieve the load on the cluster
clusterMap - the network topology of the cluster
Returns:
an instance of BlockPlacementPolicy


Copyright © 2009 The Apache Software Foundation