我正在尝试从在我的桌面 Eclipse 中运行的 Java 程序连接到远程 HDFS。我可以连接。但是在尝试读取数据时出现此异常:
引起:org.apache.hadoop.ipc.RpcException: RPC 响应超过最大数据
有人可以帮忙吗?
我有一个非常基本的代码来读取测试数据。错误来自 hdfs.open();
FileSystem hdfs =null;
String uriPath = "hdfs://" + Constants.HOST + ":" + Constants.PORT+ "/test/hello_world.txt";
String hadoopBase ="hdfs://" + Constants.HOST + ":" + Constants.PORT;
Configuration conf = new Configuration();
conf.set("fs.default.name", hadoopBase);
URI uri;
InputStream inputStream = null;
try {
uri = new URI(uriPath);
hdfs = FileSystem.get(uri, conf);
Path path = new Path(uri);
inputStream = hdfs.open(path);
IOUtils.copyBytes(inputStream, System.out, 4096, false);
} catch (URISyntaxException e) {
// TODO Auto-generated catch block …Run Code Online (Sandbox Code Playgroud)