Author: hairong
Date: Thu Dec 9 23:55:56 2010
New Revision: 1044176
URL: http://svn.apache.org/viewvc?rev=1044176&view=rev
Log:
MAPREDUCE-2215. A more elegant FileSystem#listCorruptFileBlocks API (RAID changes). Contributed
by Patrick Kling.
Modified:
hadoop/mapreduce/trunk/CHANGES.txt
hadoop/mapreduce/trunk/src/contrib/raid/src/java/org/apache/hadoop/hdfs/RaidDFSUtil.java
Modified: hadoop/mapreduce/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/CHANGES.txt?rev=1044176&r1=1044175&r2=1044176&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/CHANGES.txt (original)
+++ hadoop/mapreduce/trunk/CHANGES.txt Thu Dec 9 23:55:56 2010
@@ -12,6 +12,9 @@ Trunk (unreleased changes)
MAPREDUCE-2156. Raid-aware FSCK. (Patrick Kling via dhruba)
+ MAPREDUCE-2215. A more elegant FileSystem#listCorruptFileBlocks API
+ (RAID changes) (Patrick Kling via hairong)
+
OPTIMIZATIONS
BUG FIXES
Modified: hadoop/mapreduce/trunk/src/contrib/raid/src/java/org/apache/hadoop/hdfs/RaidDFSUtil.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/contrib/raid/src/java/org/apache/hadoop/hdfs/RaidDFSUtil.java?rev=1044176&r1=1044175&r2=1044176&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/contrib/raid/src/java/org/apache/hadoop/hdfs/RaidDFSUtil.java
(original)
+++ hadoop/mapreduce/trunk/src/contrib/raid/src/java/org/apache/hadoop/hdfs/RaidDFSUtil.java
Thu Dec 9 23:55:56 2010
@@ -30,7 +30,8 @@ import java.util.HashSet;
import java.util.Set;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.CorruptFileBlocks;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.RemoteIterator;
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
import org.apache.hadoop.hdfs.tools.DFSck;
@@ -68,15 +69,9 @@ public abstract class RaidDFSUtil {
public static String[] getCorruptFiles(DistributedFileSystem dfs)
throws IOException {
Set<String> corruptFiles = new HashSet<String>();
-
- String cookie = null;
- for (CorruptFileBlocks fbs = dfs.listCorruptFileBlocks("/", cookie);
- fbs.getFiles().length > 0;
- fbs = dfs.listCorruptFileBlocks("/", cookie)) {
- for (String path : fbs.getFiles()) {
- corruptFiles.add(path);
- }
- cookie = fbs.getCookie();
+ RemoteIterator<Path> cfb = dfs.listCorruptFileBlocks(new Path("/"));
+ while (cfb.hasNext()) {
+ corruptFiles.add(cfb.next().toUri().getPath());
}
return corruptFiles.toArray(new String[corruptFiles.size()]);
|