在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>
本文介绍如何在Hadoop 1.2.1版本中启用文件追加功能。通过设置dfs.support.broken.append为true,可以在不升级Hadoop的情况下实现文件追加。文中详细解释了废弃配置项dfs.support.append,并给出了正确的配置方法。
884

被折叠的 条评论
为什么被折叠?



