码迷,mamicode.com
首页 > 移动开发 > 详细

Hadoop中FileSystem的append方法

时间:2014-07-21 09:13:27      阅读:1094      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   java   color   使用   

  今天在使用Hadoop 1.1.2版本进行FileSystem的append操作时报以下异常:

1  org.apache.hadoop.ipc.RemoteException: java.io.IOException: Append is not supported. Please see the dfs.support.append configuration parameter.

Google了一下,发现Hadoop 1.x版本不支持FileSystem的append操作,官方Hadoop 1.1.2 Release Notes如下:

    • HADOOP-8230. Major improvement reported by eli2 and fixed by eli 
      Enable sync by default and disable append
      Append is not supported in Hadoop 1.x. Please upgrade to 2.x if you need append. If you enabled dfs.support.append for HBase, you‘re OK, as durable sync (why HBase required dfs.support.append) is now enabled by default. If you really need the previous functionality, to turn on the append functionality set the flag "dfs.support.broken.append" to true.

  上面的解释明显的提到如果需要使用append操作,需要升级到hadoop 2.x版本。并且需要在Conf的hdfs.site.xml文件中加入如下配置: 

1  <property>
2     <name>dfs.support.append</name>
3     <value>true</value>
4   </property>

 Hadoop的API中也提供了设置项来支持内容追加,代码如下:

1 Configuration conf = new Configuration();
2 conf.setBoolean("dfs.support.append", true);

  不过,在已有的文件中追加内容是一件需要斟酌的操作,原因如下:

【Raghava的邮件回复:】
In short, appends in HDFS are extremely experimental and dangerous. Most 
would advise you to leave this disabled. Your best option for "append" 
like behavior is to rewrite the file with new content being added at the 
end. Append support was briefly introduced and then removed as a number 
of issues came up. I believe the open (parent) JIRA issue tracking this is:
http://issues.apache.org/jira/browse/HDFS-265

  如果想深究其原因,可以参考网址:http://issues.apache.org/jira/browse/HDFS-265

Hadoop中FileSystem的append方法,布布扣,bubuko.com

Hadoop中FileSystem的append方法

标签:style   blog   http   java   color   使用   

原文地址:http://www.cnblogs.com/flyeast/p/3856356.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!