hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asur...@apache.org
Subject [08/29] hadoop git commit: HDFS-10684. WebHDFS DataNode calls fail without parameter createparent. Contributed by John Zhuge.
Date Sun, 18 Dec 2016 02:16:42 GMT
HDFS-10684. WebHDFS DataNode calls fail without parameter createparent. Contributed by John
Zhuge.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/fbdbbd57
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/fbdbbd57
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/fbdbbd57

Branch: refs/heads/YARN-5085
Commit: fbdbbd57cdc3d8c778fca9266a7cadf298c8ff6c
Parents: e24a923
Author: Andrew Wang <wang@apache.org>
Authored: Tue Dec 13 18:01:31 2016 -0800
Committer: Andrew Wang <wang@apache.org>
Committed: Tue Dec 13 18:01:31 2016 -0800

----------------------------------------------------------------------
 .../hdfs/web/resources/CreateParentParam.java   |  2 +-
 .../hdfs/web/resources/OverwriteParam.java      |  2 +-
 .../hdfs/web/TestWebHdfsFileSystemContract.java | 40 ++++++++++++++++++++
 3 files changed, 42 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/fbdbbd57/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/CreateParentParam.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/CreateParentParam.java
b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/CreateParentParam.java
index eaa5e8d..029efa0 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/CreateParentParam.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/CreateParentParam.java
@@ -39,7 +39,7 @@ public class CreateParentParam extends BooleanParam {
    * @param str a string representation of the parameter value.
    */
   public CreateParentParam(final String str) {
-    this(DOMAIN.parse(str));
+    this(DOMAIN.parse(str == null ? DEFAULT : str));
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hadoop/blob/fbdbbd57/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/OverwriteParam.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/OverwriteParam.java
b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/OverwriteParam.java
index 9610b93..d7f5fb0 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/OverwriteParam.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/OverwriteParam.java
@@ -39,7 +39,7 @@ public class OverwriteParam extends BooleanParam {
    * @param str a string representation of the parameter value.
    */
   public OverwriteParam(final String str) {
-    this(DOMAIN.parse(str));
+    super(DOMAIN, DOMAIN.parse(str == null ? DEFAULT : str));
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hadoop/blob/fbdbbd57/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsFileSystemContract.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsFileSystemContract.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsFileSystemContract.java
index a68b1ac..4854471 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsFileSystemContract.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsFileSystemContract.java
@@ -25,6 +25,7 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.HttpURLConnection;
 import java.net.URL;
+import java.text.MessageFormat;
 import java.util.Arrays;
 import java.util.Map;
 import java.util.Random;
@@ -48,6 +49,7 @@ import org.apache.hadoop.hdfs.web.resources.NamenodeAddressParam;
 import org.apache.hadoop.io.IOUtils;
 import org.apache.hadoop.security.AccessControlException;
 import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.test.GenericTestUtils;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -531,6 +533,44 @@ public class TestWebHdfsFileSystemContract extends FileSystemContractBaseTest
{
     }
   }
 
+  public void testDatanodeCreateMissingParameter() throws IOException {
+    final WebHdfsFileSystem webhdfs = (WebHdfsFileSystem) fs;
+    final Path testDir = new Path(MessageFormat.format("/test/{0}/{1}",
+        TestWebHdfsFileSystemContract.class,
+        GenericTestUtils.getMethodName()));
+    assertTrue(webhdfs.mkdirs(testDir));
+
+    for (String dnCreateParam : new String[]{
+        CreateFlagParam.NAME,
+        CreateParentParam.NAME,
+        OverwriteParam.NAME
+    }) {
+      final HttpOpParam.Op op = PutOpParam.Op.CREATE;
+      final Path newfile = new Path(testDir, "newfile_" + dnCreateParam);
+      final URL url = webhdfs.toUrl(op, newfile);
+      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+      conn.setRequestMethod(op.getType().toString());
+      conn.setDoOutput(false);
+      conn.setInstanceFollowRedirects(false);
+      conn.connect();
+      final String redirect = conn.getHeaderField("Location");
+      conn.disconnect();
+
+      //remove createparent
+      WebHdfsFileSystem.LOG.info("redirect = " + redirect);
+      String re = "&" + dnCreateParam + "=[^&]*";
+      String modified = redirect.replaceAll(re, "");
+      WebHdfsFileSystem.LOG.info("modified = " + modified);
+
+      //connect to datanode
+      conn = (HttpURLConnection)new URL(modified).openConnection();
+      conn.setRequestMethod(op.getType().toString());
+      conn.setDoOutput(op.getDoOutput());
+      conn.connect();
+      assertEquals(HttpServletResponse.SC_CREATED, conn.getResponseCode());
+    }
+  }
+
   @Test
   public void testAccess() throws IOException, InterruptedException {
     Path p1 = new Path("/pathX");


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


Mime
View raw message