Spark学习之路Spark在简书spark

一篇漫画理解HDFS读写工作原理

2017-05-15  本文已影响459人  俺是亮哥

浅显易懂的介绍,很多资料对File Blocks副本Location位置的描述是有误的,正确的理解请参考本漫画,后附Hadoop 2.7.3 BlockPlacementPolicyDefault类来佐证

**漫画转载自 - 卓寿杰 Soul Joy - 博客频道 - CSDN.NET http://blog.csdn.net/u011239443/article/details/51751462
**





Hadoop 2.7.3 BlockPlacementPolicyDefault.java
默认的3副本存放规则:

/**
 * 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.
 */
@InterfaceAudience.Private
public class BlockPlacementPolicyDefault extends BlockPlacementPolicy {

  private static final String enableDebugLogging =
    "For more information, please enable DEBUG log level on "
    + BlockPlacementPolicy.class.getName();

  private static final ThreadLocal<StringBuilder> debugLoggingBuilder
      = new ThreadLocal<StringBuilder>() {
        @Override
        protected StringBuilder initialValue() {
          return new StringBuilder();
        }
      };

关于block副本数需要注意的地方:

补充一点HDFS机架感知技术介绍
HDFS机架感知功能原理(rack awareness)
这是篇好文章,我很喜欢
HDFS文件读写及机制介绍

上一篇下一篇

猜你喜欢

热点阅读