hdfs

bgibtngc  于 2021-06-04  发布在  Hadoop
关注(0)|答案(1)|浏览(348)

我正在尝试附加到版本0.23.5上的hdfs文件。我已经在hdfs-site.xml中将dfs.support.append属性设置为true。当调用hdfswrite()说不支持append时,出现以下错误。 Exception in thread "main" java.io.IOException: Not supported at org.apache.hadoop.fs.ChecksumFileSystem.append(ChecksumFileSystem.java:345) at org.apache.hadoop.fs.FileSystem.append(FileSystem.java:1046) Call to org.apache.hadoop.conf.FileSystem::append((Lorg/apache/hadoop/fs/Path;)Lorg/apache/hadoop/fs/FSDataOutputStream;) failed! 我查了过去关于hdfs中append的文献。append应该在0.23.5中工作。
我能插入和阅读。问题是当我试图打开一个附加文件并写入文件时。下面是示例代码-

int append(char *filepath, char *data, int size)
{
   hdfsFS fs = hdfsConnect("default", 0);
   int openFlags = O_WRONLY | O_APPEND;
   hdfsFile fdData = hdfsOpenFile(fs, filepath, openFlags, 0, 0, 0);
   if (!fdData) 
     return -1;
   if (hdfsWrite(fs, fdData, data, size) == -1)
     return -1;
   hdfsCloseFile(fs, fdData);

   return 0;
}

我错过什么了吗?
谢谢。

0ejtzxu1

0ejtzxu11#

fsdataoutputstream不支持append方法。以下是相关资料来源:

public FSDataOutputStream append(Path f, int bufferSize, Progressable progress) throws IOException {
    throw new IOException("Not supported");
  }

您会注意到它的超类文件系统注意到append是一个可选方法。

相关问题