From 161b986528dfd5d4838762198302bfed39d44415 Mon Sep 17 00:00:00 2001 From: Tsz-wo Sze Date: Fri, 13 Jan 2012 04:46:47 +0000 Subject: [PATCH] svn merge -c 1215366 from trunk for HDFS-2687. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23-PB@1230900 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 ++ .../hadoop/hdfs/protocolPB/PBHelper.java | 33 +++++++------------ 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 3494779c522..39bc7d62d48 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -93,6 +93,9 @@ Release 0.23-PB - Unreleased HDFS-2694. Removal of Avro broke non-PB NN services. (atm) + HDFS-2687. Tests failing with ClassCastException post protobuf RPC + changes. (suresh) + Release 0.23.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/PBHelper.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/PBHelper.java index 9fc6b7e5903..c45e4cb1410 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/PBHelper.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/PBHelper.java @@ -988,25 +988,15 @@ public class PBHelper { public static HdfsFileStatus convert(HdfsFileStatusProto fs) { if (fs == null) return null; - if (fs.hasLocations()) { - return new HdfsLocatedFileStatus( - fs.getLength(), fs.getFileType().equals(FileType.IS_DIR), - fs.getBlockReplication(), fs.getBlocksize(), - fs.getModificationTime(), fs.getAccessTime(), - PBHelper.convert(fs.getPermission()), fs.getOwner(), fs.getGroup(), - fs.getFileType().equals(FileType.IS_SYMLINK) ? - fs.getSymlink().toByteArray() : null, - fs.getPath().toByteArray(), - PBHelper.convert(fs.hasLocations() ? fs.getLocations() : null)); - } - return new HdfsFileStatus( - fs.getLength(), fs.getFileType().equals(FileType.IS_DIR), - fs.getBlockReplication(), fs.getBlocksize(), - fs.getModificationTime(), fs.getAccessTime(), - PBHelper.convert(fs.getPermission()), fs.getOwner(), fs.getGroup(), - fs.getFileType().equals(FileType.IS_SYMLINK) ? - fs.getSymlink().toByteArray() : null, - fs.getPath().toByteArray()); + return new HdfsLocatedFileStatus( + fs.getLength(), fs.getFileType().equals(FileType.IS_DIR), + fs.getBlockReplication(), fs.getBlocksize(), + fs.getModificationTime(), fs.getAccessTime(), + PBHelper.convert(fs.getPermission()), fs.getOwner(), fs.getGroup(), + fs.getFileType().equals(FileType.IS_SYMLINK) ? + fs.getSymlink().toByteArray() : null, + fs.getPath().toByteArray(), + fs.hasLocations() ? PBHelper.convert(fs.getLocations()) : null); } public static HdfsFileStatusProto convert(HdfsFileStatus fs) { @@ -1068,7 +1058,7 @@ public class PBHelper { return null; List partList = dl.getPartialListingList(); return new DirectoryListing( - partList.isEmpty() ? new HdfsFileStatus[0] + partList.isEmpty() ? new HdfsLocatedFileStatus[0] : PBHelper.convert( partList.toArray(new HdfsFileStatusProto[partList.size()])), dl.getRemainingEntries()); @@ -1214,7 +1204,8 @@ public class PBHelper { public static CorruptFileBlocks convert(CorruptFileBlocksProto c) { if (c == null) return null; - return new CorruptFileBlocks((String[]) c.getFilesList().toArray(), + List fileList = c.getFilesList(); + return new CorruptFileBlocks(fileList.toArray(new String[fileList.size()]), c.getCookie()); }