您好我正在尝试使用 Java API 从 HDFS 读取文件。
连接到 HDFS 并列出文件工作正常。
但是在尝试读取文件时出现以下异常
函数调用:fs.copyToLocalFile(path, dPath);
java.io.IOException: Could not obtain block: blk_-747325769320762541_16269493 file=/user/s3t.txt
at org.apache.hadoop.hdfs.DFSClient$DFSInputStream.chooseDataNode(DFSClient.java:2266)
at org.apache.hadoop.hdfs.DFSClient$DFSInputStream.blockSeekTo(DFSClient.java:2060)
at org.apache.hadoop.hdfs.DFSClient$DFSInputStream.read(DFSClient.java:2221)
at java.io.DataInputStream.read(Unknown Source)
at org.apache.hadoop.io.IOUtils.copyBytes(IOUtils.java:68)
at org.apache.hadoop.io.IOUtils.copyBytes(IOUtils.java:47)
at org.apache.hadoop.io.IOUtils.copyBytes(IOUtils.java:100)
at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:230)
at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:163)
at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:1222)
at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:1203)
at Access.main(Access.java:59)
注意:我能够使用 fs.createNewFile(myPath); 创建新文件