向HDFS文件append新内容

在hadoop1.2.1中,网上有很多文章说这个版本不支持文件追加模式,设置了
<property>
         <name>dfs.support.append</name>
         <value>true</value>
 </property>

无效

由于我现在做的项目需要这个功能,而升级hadoop似乎不太可能,然后查看源码发现,其中allowBrokenAppend是用于判断是否支持追加的标识符

this.allowBrokenAppend = conf.getBoolean("dfs.support.broken.append", false);
    if (conf.getBoolean("dfs.support.append", false)) {
      LOG.warn("The dfs.support.append option is in your configuration, " +
               "however append is not supported. This configuration option " +
               "is no longer required to enable sync");
    }
<pre name="code" class="java"> LocatedBlock appendFile(String src, String holder, String clientMachine
      ) throws IOException {
    if (!allowBrokenAppend) {
      throw new IOException("Append is not supported. " +
          "Please see the dfs.support.append configuration parameter");
    }
    startFileInternal(src, null, holder, clientMachine, false, true, 
                      false, (short)maxReplication, (long)0);
    getEditLog().logSync();
 
 

看到这里就很明白了吧,dfs.support.append属性已经作废不起作用了,如果想支持追加模式需要以下设置

<property>
         <name>dfs.support.broken.append</name>
         <value>true</value>
 </property>

你可能感兴趣的:(TO,hadoop,hdfs,append,文件追加,S,not)