diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 10f5f7e21f..6eec661d15 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -72,6 +72,8 @@ Trunk (unreleased changes) HADOOP-7876. Provided access to encoded key in DelegationKey for use in protobuf based RPCs. (suresh) + HADOOP-7886. Add toString to FileStatus. (SreeHari via jghoman) + BUGS HADOOP-7606. Upgrade Jackson to version 1.7.1 to match the version required diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java index b37fd93add..f4492e2f23 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java @@ -331,4 +331,23 @@ public boolean equals(Object o) { 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(); + } }