java - 我无法向我创建的 Hadoop MiniCluster 写入(放置)
问题描述
null: [HTTP/1.1 405 HTTP method
PUT is not supported by this
URL]
Server:
[Jetty(6.1.26.cloudera.4)]
Pragma: [no-cache]
Content-Length: [0]
X-FRAME-OPTIONS: [SAMEORIGIN]
Date: [Wed, 13 Oct 2021
17:05:16 GMT]
''' private static void putTest() throws IOException { System.out.println("putTest : Entry");
URL url = new URL("http://localhost:50070/webapps/v1/longdata.txt&op=CREATE");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("PUT");
con.setDoOutput(true);
con.getOutputStream().write("Hey Guys".getBytes(StandardCharsets.UTF_8));
Map<String, List<String>> headers = con.getHeaderFields();
for (String header : headers.keySet())
{
System.out.println(header + ": " + headers.get(header));
}
System.out.println("putTest : Exit");
}
'''
解决方案
您需要两个请求- 一个到 namenode 端口,它在 namenode 上创建文件,然后返回一个 datanode 地址,您将在该地址发送第二个地址以写入内容流。
但是,您使用的是 Java,所以只需hadoop-client
对方法使用依赖项FileSystem.create
,不要使用HttpURLConnection
推荐阅读
- android - Android(Unity)中的深度着色器错误:材质中的伪影和故障
- java - 在 Android 中选择 Spinner 选项时如何显示不同的文本视图
- go - 去编译:从可执行文件中删除个人信息
- node.js - 使用 NPM 安装
- linear-programming - 在 glpk (gusek) 中实现 Open Shop Scheduling 算法
- java - 为什么我的 else 语句在 'while-loop' 中执行,但不在 JAVA 中的'for-loop' 中执行
- c++11 - 不能在自定义角色移动组件中调用“Montage_Play”吗?C++ UE4
- oracle - Jenkins 共享库上的 Oracle ojdbc 驱动程序
- google-apps-script - 如何将一个范围复制到另一张纸的末尾
- mongodb - 尝试将环回 mongodb 连接器与 AWS DocumentDB 连接