繁体   English   中英

我无法写入(放置)到我创建的 Hadoop MiniCluster

[英]I am not able to write (put) to Hadoop MiniCluster i created

    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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM