From be58711e9117a5adf469d2e4434b9371cbd340bc Mon Sep 17 00:00:00 2001 From: John Zhuge Date: Wed, 22 Mar 2017 22:30:46 -0700 Subject: [PATCH] HDFS-11561. HttpFS doc errors. Contributed by Yuanbo Liu. (cherry picked from commit ed2d03f2a5318a88d0eced8476127f303eb1d1d9) Conflicts: hadoop-hdfs-project/hadoop-hdfs-httpfs/src/site/markdown/index.md --- .../src/site/markdown/index.md | 6 +++--- .../fs/http/server/TestHttpFSServer.java | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/site/markdown/index.md b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/site/markdown/index.md index 8d6625fcab1..f2a5daf79eb 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/site/markdown/index.md +++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/site/markdown/index.md @@ -36,11 +36,11 @@ HttpFS itself is Java web-application and it runs using a preconfigured Tomcat b HttpFS HTTP web-service API calls are HTTP REST calls that map to a HDFS file system operation. For example, using the `curl` Unix command: -* `$ curl http://httpfs-host:14000/webhdfs/v1/user/foo/README.txt` returns the contents of the HDFS `/user/foo/README.txt` file. +* `$ curl 'http://httpfs-host:14000/webhdfs/v1/user/foo/README.txt?op=OPEN&user.name=foo'` returns the contents of the HDFS `/user/foo/README.txt` file. -* `$ curl http://httpfs-host:14000/webhdfs/v1/user/foo?op=list` returns the contents of the HDFS `/user/foo` directory in JSON format. +* `$ curl 'http://httpfs-host:14000/webhdfs/v1/user/foo?op=LISTSTATUS&user.name=foo'` returns the contents of the HDFS `/user/foo` directory in JSON format. -* `$ curl -X POST http://httpfs-host:14000/webhdfs/v1/user/foo/bar?op=mkdirs` creates the HDFS `/user/foo.bar` directory. +* `$ curl -X POST 'http://httpfs-host:14000/webhdfs/v1/user/foo/bar?op=MKDIRS&user.name=foo'` creates the HDFS `/user/foo/bar` directory. User and Developer Documentation -------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServer.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServer.java index c6a7a9d457c..a475cab6b69 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServer.java +++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServer.java @@ -224,6 +224,24 @@ public void testHdfsAccess() throws Exception { reader.close(); } + @Test + @TestDir + @TestJetty + @TestHdfs + public void testMkdirs() throws Exception { + createHttpFSServer(false); + + String user = HadoopUsersConfTestHelper.getHadoopUsers()[0]; + URL url = new URL(TestJettyHelper.getJettyURL(), MessageFormat.format( + "/webhdfs/v1/tmp/sub-tmp?user.name={0}&op=MKDIRS", user)); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("PUT"); + conn.connect(); + Assert.assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_OK); + + getStatus("/tmp/sub-tmp", "LISTSTATUS"); + } + @Test @TestDir @TestJetty