Search code examples
hdfshadoop2

Hdfs replication factor 1 override default behaviour


Is there a way to override default behaviour for the first replica block on hdfs?

What I'd like to do is to assure that the copy of a block is on a different datanode when I set dfs.replication=1


Solution

  • You need to implement your own Block Placement Policy. But this is really not hard at all. Your class should extend org.apache.hadoop.hdfs.server.blockmanagement.BlockPlacementPolicy. What you want to implement is very simple, so just copy the default block placement policy class and modify it so that it behaves as desired.