我正在尝试使用Java客户端在Hadoop中创建一个文件(只是一个测试用例)。抛出以下例外:
Exception in thread "main" java.io.IOException: Mkdirs failed to create /app2/speed (exists=false, cwd=file:/home/cpu-local/NetBeansProjects/hdoops)
at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:450)
at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:435)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:909)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:890)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:787)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:776)
at com.abc.hadoop.Test.main(Test.java:35)
答案 0 :(得分:0)
通过Java客户端创建FileSystem失败,您只需要设置适合hadoop配置的java客户端(在文件配置中)。
Configuration hadoopConfig = new Configuration();
hadoopConfig.set("fs.defaultFS", "hdfs://localhost:9000/");
hadoopConfig.set("fs.hdfs.impl", org.apache.hadoop.hdfs.DistributedFileSystem.class.getName());
hadoopConfig.set("fs.file.impl", org.apache.hadoop.fs.LocalFileSystem.class.getName());