You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ta...@apache.org on 2020/01/10 00:54:25 UTC

[hadoop] branch trunk updated: HDFS-15102. HttpFS: put requests are not supported for path "/". Contributed by hemanthboyina.

This is an automated email from the ASF dual-hosted git repository.

tasanuma pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 782c055  HDFS-15102. HttpFS: put requests are not supported for path "/". Contributed by hemanthboyina.
782c055 is described below

commit 782c0556fb413d54c9d028ddc11d67cdc32585ff
Author: Takanobu Asanuma <ta...@apache.org>
AuthorDate: Fri Jan 10 09:52:13 2020 +0900

    HDFS-15102. HttpFS: put requests are not supported for path "/". Contributed by hemanthboyina.
---
 .../apache/hadoop/fs/http/server/HttpFSServer.java | 23 ++++++++++++++++++++++
 .../hadoop/fs/http/server/TestHttpFSServer.java    |  7 +++++++
 2 files changed, 30 insertions(+)

diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java
index 4ad1c15..faa47c5 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java
@@ -642,6 +642,29 @@ public class HttpFSServer {
     return uriBuilder.build(null);
   }
 
+  /**
+   * Special binding for '/' as it is not handled by the wildcard binding.
+   * @param is the inputstream for the request payload.
+   * @param uriInfo the of the request.
+   * @param op the HttpFS operation of the request.
+   * @param params the HttpFS parameters of the request.
+   *
+   * @return the request response.
+   *
+   * @throws IOException thrown if an IO error occurred. Thrown exceptions are
+   *           handled by {@link HttpFSExceptionProvider}.
+   * @throws FileSystemAccessException thrown if a FileSystemAccess related
+   *           error occurred. Thrown exceptions are handled by
+   *           {@link HttpFSExceptionProvider}.
+   */
+  @PUT
+  @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8 })
+  public Response putRoot(InputStream is, @Context UriInfo uriInfo,
+      @QueryParam(OperationParam.NAME) OperationParam op,
+      @Context Parameters params, @Context HttpServletRequest request)
+      throws IOException, FileSystemAccessException {
+    return put(is, uriInfo, "/", op, params, request);
+  }
 
   /**
    * Binding to handle PUT requests.
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 bcc8e9a..88364d2 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
@@ -1783,5 +1783,12 @@ public class TestHttpFSServer extends HFSTestCase {
     // response should be null
     dfsDirLst = dfs.getErasureCodingPolicy(path1);
     Assert.assertNull(dfsDirLst);
+
+    // test put opeartion with path as "/"
+    final String dir1 = "/";
+    HttpURLConnection conn3 =
+        putCmdWithReturn(dir1, "SETECPOLICY", "ecpolicy=" + ecPolicyName);
+    // Should return HTTP_OK
+    Assert.assertEquals(HttpURLConnection.HTTP_OK, conn3.getResponseCode());
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org