hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r1189480 - in /hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs: ./ src/main/java/ src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/ src/main/java/org/apache/hadoop/hdfs/web/ src/test/java/org/apache/hado...
Date Wed, 26 Oct 2011 21:31:05 GMT
Author: szetszwo
Date: Wed Oct 26 21:31:04 2011
New Revision: 1189480

URL: http://svn.apache.org/viewvc?rev=1189480&view=rev
Log:
svn merge -c 1180757 from trunk for HDFS-2404.

Modified:
    hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/   (props changed)
    hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
    hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/   (props
changed)
    hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java
    hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/JsonUtil.java
    hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java
    hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestJsonUtil.java

Propchange: hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Oct 26 21:31:04 2011
@@ -1,4 +1,4 @@
-/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs:1161777,1161781,1162188,1162421,1162491,1162499,1162613,1162928,1162954,1162979,1163050,1163069,1163081,1163490,1163768,1164255,1164301,1164339,1166402,1167383,1167662,1170085,1170379,1170459,1170996,1171136,1171297,1171379,1171611,1172916,1173402,1173468,1175113,1176178,1176550,1176719,1176729,1176733,1177487,1177531,1177859,1177864,1177905,1179169,1179856,1179861
+/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs:1161777,1161781,1162188,1162421,1162491,1162499,1162613,1162928,1162954,1162979,1163050,1163069,1163081,1163490,1163768,1164255,1164301,1164339,1166402,1167383,1167662,1170085,1170379,1170459,1170996,1171136,1171297,1171379,1171611,1172916,1173402,1173468,1175113,1176178,1176550,1176719,1176729,1176733,1177487,1177531,1177859,1177864,1177905,1179169,1179856,1179861,1180757
 /hadoop/core/branches/branch-0.19/hdfs:713112
 /hadoop/hdfs/branches/HDFS-1052:987665-1095512
 /hadoop/hdfs/branches/HDFS-265:796829-820463

Modified: hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1189480&r1=1189479&r2=1189480&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Wed Oct
26 21:31:04 2011
@@ -1095,6 +1095,8 @@ Release 0.23.0 - Unreleased
 
     HDFS-2409. _HOST in dfs.web.authentication.kerberos.principal. (jitendra)
 
+    HDFS-2404. webhdfs liststatus json response is not correct. (suresh)
+
   BREAKDOWN OF HDFS-1073 SUBTASKS
 
     HDFS-1521. Persist transaction ID on disk between NN restarts.

Propchange: hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Oct 26 21:31:04 2011
@@ -1,4 +1,4 @@
-/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java:1161777,1161781,1162188,1162421,1162491,1162499,1162613,1162928,1162954,1162979,1163050,1163069,1163081,1163490,1163768,1164255,1164301,1164339,1166402,1167383,1167662,1170085,1170379,1170459,1170996,1171136,1171297,1171379,1171611,1172916,1173402,1173468,1175113,1176178,1176550,1176719,1176729,1176733,1177487,1177531,1177859,1177864,1177905,1179169,1179856,1179861
+/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java:1161777,1161781,1162188,1162421,1162491,1162499,1162613,1162928,1162954,1162979,1163050,1163069,1163081,1163490,1163768,1164255,1164301,1164339,1166402,1167383,1167662,1170085,1170379,1170459,1170996,1171136,1171297,1171379,1171611,1172916,1173402,1173468,1175113,1176178,1176550,1176719,1176729,1176733,1177487,1177531,1177859,1177864,1177905,1179169,1179856,1179861,1180757
 /hadoop/core/branches/branch-0.19/hdfs/src/java:713112
 /hadoop/core/trunk/src/hdfs:776175-785643,785929-786278
 /hadoop/hdfs/branches/HDFS-1052/src/java:987665-1095512

Modified: hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java?rev=1189480&r1=1189479&r2=1189480&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java
(original)
+++ hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java
Wed Oct 26 21:31:04 2011
@@ -424,7 +424,7 @@ public class NamenodeWebHdfsMethods {
     case GETFILESTATUS:
     {
       final HdfsFileStatus status = np.getFileInfo(fullpath);
-      final String js = JsonUtil.toJsonString(status);
+      final String js = JsonUtil.toJsonString(status, true);
       return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
     }
     case LISTSTATUS:
@@ -480,22 +480,22 @@ 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() + "\":[");
 
         final HdfsFileStatus[] partial = first.getPartialListing();
         if (partial.length > 0) {
-          out.print(JsonUtil.toJsonString(partial[0]));
+          out.print(JsonUtil.toJsonString(partial[0], false));
         }
         for(int i = 1; i < partial.length; i++) {
           out.println(',');
-          out.print(JsonUtil.toJsonString(partial[i]));
+          out.print(JsonUtil.toJsonString(partial[i], false));
         }
 
         for(DirectoryListing curr = first; curr.hasMore(); ) { 
           curr = getDirectoryListing(np, p, curr.getLastName());
           for(HdfsFileStatus s : curr.getPartialListing()) {
             out.println(',');
-            out.print(JsonUtil.toJsonString(s));
+            out.print(JsonUtil.toJsonString(s, false));
           }
         }
         

Modified: hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/JsonUtil.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/JsonUtil.java?rev=1189480&r1=1189479&r2=1189480&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/JsonUtil.java
(original)
+++ hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/JsonUtil.java
Wed Oct 26 21:31:04 2011
@@ -133,37 +133,39 @@ public class JsonUtil {
   }
 
   /** Convert a HdfsFileStatus object to a Json string. */
-  public static String toJsonString(final HdfsFileStatus status) {
+  public static String toJsonString(final HdfsFileStatus status,
+      boolean includeType) {
     if (status == null) {
       return null;
-    } else {
-      final Map<String, Object> m = new TreeMap<String, Object>();
-      m.put("localName", status.getLocalName());
-      m.put("isDir", status.isDir());
-      m.put("isSymlink", status.isSymlink());
-      if (status.isSymlink()) {
-        m.put("symlink", status.getSymlink());
-      }
-
-      m.put("len", status.getLen());
-      m.put("owner", status.getOwner());
-      m.put("group", status.getGroup());
-      m.put("permission", toString(status.getPermission()));
-      m.put("accessTime", status.getAccessTime());
-      m.put("modificationTime", status.getModificationTime());
-      m.put("blockSize", status.getBlockSize());
-      m.put("replication", status.getReplication());
-      return toJsonString(HdfsFileStatus.class, m);
     }
+    final Map<String, Object> m = new TreeMap<String, Object>();
+    m.put("localName", status.getLocalName());
+    m.put("isDir", status.isDir());
+    m.put("isSymlink", status.isSymlink());
+    if (status.isSymlink()) {
+      m.put("symlink", status.getSymlink());
+    }
+
+    m.put("len", status.getLen());
+    m.put("owner", status.getOwner());
+    m.put("group", status.getGroup());
+    m.put("permission", toString(status.getPermission()));
+    m.put("accessTime", status.getAccessTime());
+    m.put("modificationTime", status.getModificationTime());
+    m.put("blockSize", status.getBlockSize());
+    m.put("replication", status.getReplication());
+    return includeType ? toJsonString(HdfsFileStatus.class, m) : 
+      JSON.toString(m);
   }
 
   /** Convert a Json map to a HdfsFileStatus object. */
-  public static HdfsFileStatus toFileStatus(final Map<?, ?> json) {
+  public static HdfsFileStatus toFileStatus(final Map<?, ?> json, boolean includesType)
{
     if (json == null) {
       return null;
     }
 
-    final Map<?, ?> m = (Map<?, ?>)json.get(HdfsFileStatus.class.getSimpleName());
+    final Map<?, ?> m = includesType ? 
+        (Map<?, ?>)json.get(HdfsFileStatus.class.getSimpleName()) : json;
     final String localName = (String) m.get("localName");
     final boolean isDir = (Boolean) m.get("isDir");
     final boolean isSymlink = (Boolean) m.get("isSymlink");
@@ -287,7 +289,7 @@ public class JsonUtil {
       return array;
     }
   }
-
+  
   /** Convert a LocatedBlock to a Json map. */
   private static Map<String, Object> toJsonMap(final LocatedBlock locatedblock
       ) throws IOException {

Modified: hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java?rev=1189480&r1=1189479&r2=1189480&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java
(original)
+++ hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java
Wed Oct 26 21:31:04 2011
@@ -253,7 +253,7 @@ public class WebHdfsFileSystem extends H
   private HdfsFileStatus getHdfsFileStatus(Path f) throws IOException {
     final HttpOpParam.Op op = GetOpParam.Op.GETFILESTATUS;
     final Map<String, Object> json = run(op, f);
-    final HdfsFileStatus status = JsonUtil.toFileStatus(json);
+    final HdfsFileStatus status = JsonUtil.toFileStatus(json, true);
     if (status == null) {
       throw new FileNotFoundException("File does not exist: " + f);
     }
@@ -405,14 +405,14 @@ public class WebHdfsFileSystem extends H
     final HttpOpParam.Op op = GetOpParam.Op.LISTSTATUS;
     final Map<?, ?> json  = run(op, f);
     final Object[] array = (Object[])json.get(
-        HdfsFileStatus[].class.getSimpleName());
+        HdfsFileStatus.class.getSimpleName());
 
     //convert FileStatus
     final FileStatus[] statuses = new FileStatus[array.length];
     for(int i = 0; i < array.length; i++) {
       @SuppressWarnings("unchecked")
       final Map<String, Object> m = (Map<String, Object>)array[i];
-      statuses[i] = makeQualified(JsonUtil.toFileStatus(m), f);
+      statuses[i] = makeQualified(JsonUtil.toFileStatus(m, false), f);
     }
     return statuses;
   }
@@ -472,4 +472,4 @@ public class WebHdfsFileSystem extends H
     final Map<String, Object> m = run(op, p);
     return JsonUtil.toMD5MD5CRC32FileChecksum(m);
   }
-}
\ No newline at end of file
+}

Modified: hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestJsonUtil.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestJsonUtil.java?rev=1189480&r1=1189479&r2=1189480&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestJsonUtil.java
(original)
+++ hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestJsonUtil.java
Wed Oct 26 21:31:04 2011
@@ -46,9 +46,9 @@ public class TestJsonUtil {
     final FileStatus fstatus = toFileStatus(status, parent);
     System.out.println("status  = " + status);
     System.out.println("fstatus = " + fstatus);
-    final String json = JsonUtil.toJsonString(status);
+    final String json = JsonUtil.toJsonString(status, true);
     System.out.println("json    = " + json.replace(",", ",\n  "));
-    final HdfsFileStatus s2 = JsonUtil.toFileStatus((Map<?, ?>)JSON.parse(json));
+    final HdfsFileStatus s2 = JsonUtil.toFileStatus((Map<?, ?>)JSON.parse(json), true);
     final FileStatus fs2 = toFileStatus(s2, parent);
     System.out.println("s2      = " + s2);
     System.out.println("fs2     = " + fs2);



Mime
View raw message