From c8f2cbc38df18a9ea83ff158835ecfb942fffedd Mon Sep 17 00:00:00 2001 From: Jonathan Hsieh Date: Wed, 29 Aug 2012 22:57:10 +0000 Subject: [PATCH] HBASE-6686 HFile Quarantine fails with missing dirs in hadoop 2.0 git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1378762 13f79535-47bb-0310-9956-ffa450edef68 --- .../util/hbck/HFileCorruptionChecker.java | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/hbck/HFileCorruptionChecker.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/hbck/HFileCorruptionChecker.java index 95c921c12da..2d68727112c 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/hbck/HFileCorruptionChecker.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/hbck/HFileCorruptionChecker.java @@ -152,9 +152,19 @@ public class HFileCorruptionChecker { * @throws IOException */ protected void checkColFamDir(Path cfDir) throws IOException { - FileStatus[] hfs = fs.listStatus(cfDir, new HFileFilter(fs)); // use same filter as scanner. + FileStatus[] hfs = null; + try { + hfs = fs.listStatus(cfDir, new HFileFilter(fs)); // use same filter as scanner. + } catch (FileNotFoundException fnfe) { + // Hadoop 0.23+ listStatus semantics throws an exception if the path does not exist. + LOG.warn("Colfam Directory " + cfDir + + " does not exist. Likely due to concurrent split/compaction. Skipping."); + missing.add(cfDir); + return; + } + + // Hadoop 1.0 listStatus does not throw an exception if the path does not exist. if (hfs.length == 0 && !fs.exists(cfDir)) { - // interestingly, listStatus does not throw an exception if the path does not exist. LOG.warn("Colfam Directory " + cfDir + " does not exist. Likely due to concurrent split/compaction. Skipping."); missing.add(cfDir); @@ -174,9 +184,19 @@ public class HFileCorruptionChecker { * @throws IOException */ protected void checkRegionDir(Path regionDir) throws IOException { - FileStatus[] cfs = fs.listStatus(regionDir, new FamilyDirFilter(fs)); + FileStatus[] cfs = null; + try { + cfs = fs.listStatus(regionDir, new FamilyDirFilter(fs)); + } catch (FileNotFoundException fnfe) { + // Hadoop 0.23+ listStatus semantics throws an exception if the path does not exist. + LOG.warn("Region Directory " + regionDir + + " does not exist. Likely due to concurrent split/compaction. Skipping."); + missing.add(regionDir); + return; + } + + // Hadoop 1.0 listStatus does not throw an exception if the path does not exist. if (cfs.length == 0 && !fs.exists(regionDir)) { - // interestingly, listStatus does not throw an exception if the path does not exist. LOG.warn("Region Directory " + regionDir + " does not exist. Likely due to concurrent split/compaction. Skipping."); missing.add(regionDir);