Procházet zdrojové kódy

HADOOP-7886 Add toString to FileStatus (SreeHari via tgraves)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1434851 13f79535-47bb-0310-9956-ffa450edef68
Thomas Graves před 12 roky
rodič
revize
84d9fec407

+ 4 - 2
hadoop-common-project/hadoop-common/CHANGES.txt

@@ -12,8 +12,10 @@ Release 0.23.7 - UNRELEASED
 
   BUG FIXES
 
-  HADOOP-8157. Fix race condition in Configuration that could cause spurious
-  ClassNotFoundExceptions after a GC. (todd)
+    HADOOP-8157. Fix race condition in Configuration that could cause spurious
+    ClassNotFoundExceptions after a GC. (todd)
+
+    HADOOP-7886 Add toString to FileStatus (SreeHari via tgraves)
 
 Release 0.23.6 - UNRELEASED
 

+ 19 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java

@@ -331,4 +331,23 @@ public class FileStatus implements Writable, Comparable {
   public int hashCode() {
     return getPath().hashCode();
   }
+  
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder();
+    sb.append(getClass().getSimpleName()); 
+    sb.append("{");
+    sb.append("path=" + path);
+    sb.append("; isDirectory=" + isdir);
+    if(!isDirectory()){
+      sb.append("; length=" + length);
+      sb.append("; replication=" + block_replication);
+      sb.append("; blocksize=" + blocksize);
+    }
+    sb.append("; owner=" + owner);
+    sb.append("; group=" + group);
+    sb.append("; permission=" + permission);
+    sb.append("}");
+    return sb.toString();
+  }
 }