From c46dbedaf94cb72e35e9e63d7f99e382ae9f0974 Mon Sep 17 00:00:00 2001 From: Tsz-wo Sze Date: Fri, 14 Oct 2011 00:30:30 +0000 Subject: [PATCH] HDFS-2424. Added a root element "HdfsFileStatuses" for the response of webhdfs listStatus. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1183175 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 5 ++++- .../namenode/web/resources/NamenodeWebHdfsMethods.java | 6 ++++-- .../java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 616b225e6c0..8d094920147 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -117,9 +117,12 @@ Trunk (unreleased changes) webhdfs responses. (szetszwo) HDFS-2428. Convert com.sun.jersey.api.ParamException$QueryParamException - to IllegalArgumentException and response it http BAD_REQUEST in webhdfs. + to IllegalArgumentException and response it as http BAD_REQUEST in webhdfs. (szetszwo) + HDFS-2424. Added a root element "HdfsFileStatuses" for the response + of webhdfs listStatus. (szetszwo) + Release 0.23.0 - Unreleased INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java index e370df49ce6..2e4d2854a3a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java @@ -490,7 +490,8 @@ public class NamenodeWebHdfsMethods { @Override public void write(final OutputStream outstream) throws IOException { final PrintStream out = new PrintStream(outstream); - out.println("{\"" + HdfsFileStatus.class.getSimpleName() + "\":["); + out.println("{\"" + HdfsFileStatus.class.getSimpleName() + "es\":{\"" + + HdfsFileStatus.class.getSimpleName() + "\":["); final HdfsFileStatus[] partial = first.getPartialListing(); if (partial.length > 0) { @@ -509,7 +510,8 @@ public class NamenodeWebHdfsMethods { } } - out.println("]}"); + out.println(); + out.println("]}}"); } }; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java index 1cd20f1468f..a039a97fb82 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java @@ -404,8 +404,8 @@ public class WebHdfsFileSystem extends HftpFileSystem { final HttpOpParam.Op op = GetOpParam.Op.LISTSTATUS; final Map json = run(op, f); - final Object[] array = (Object[])json.get( - HdfsFileStatus.class.getSimpleName()); + final Map rootmap = (Map)json.get(HdfsFileStatus.class.getSimpleName() + "es"); + final Object[] array = (Object[])rootmap.get(HdfsFileStatus.class.getSimpleName()); //convert FileStatus final FileStatus[] statuses = new FileStatus[array.length];