Во-первых, у меня был hasoop-2.7.2, построенный с использованием переменных mvn и среды, установленных правильно. Тогда я пытаюсь запустить простой пример на сайте Apache: C API libhdfs example codeHadoop Exception java.lang.NoSuchMethodError при вызове hdfsOpenFile в hdfs C API
#include "hdfs.h"
int main(int argc, char **argv) {
hdfsFS fs = hdfsConnect("default", 0);
const char* writePath = "/tmp/testfile.txt";
hdfsFile writeFile = hdfsOpenFile(fs, writePath, O_WRONLY |O_CREAT, 0, 0, 0);
if(!writeFile) {
fprintf(stderr, "Failed to open %s for writing!\n", writePath);
exit(-1);
}
char* buffer = "Hello, World!";
tSize num_written_bytes = hdfsWrite(fs, writeFile, (void*)buffer, strlen(buffer)+1);
if (hdfsFlush(fs, writeFile)) {
fprintf(stderr, "Failed to 'flush' %s\n", writePath);
exit(-1);
}
hdfsCloseFile(fs, writeFile);
}
Затем я получил сообщение об ошибке, как показано ниже:
$ could not find method create from class org/apache/hadoop/fs/FileSystem with signature (Lorg/apache/hadoop/fs/Path;Lorg/apache/hadoop/fs/permission/FsPermission;ZISJILorg/apache/hadoop/util/Progressable;Z)Lorg/apache/hadoop/fs/FSDataOutputStream;
$ Exception in thread "main" java.lang.NoSuchMethodError: create
$ Call to org.apache.hadoop.conf.FileSystem::create((Lorg/apache/hadoop/fs/Path;Lorg/apache/hadoop/fs/permission/FsPermission;ZISJILorg/apache/hadoop/util/Progressable;Z)Lorg/apache/hadoop/fs/FSDataOutputStream;) failed!
Но я могу найти функцию «создать» в орг .apache.hadoop.fs.FileSystem: org.apache.hadoop.fs.FileSystem function list
У кого-нибудь есть идея, что происходит?