You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ns...@apache.org on 2011/10/11 19:42:26 UTC

svn commit: r1181926 - /hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java

Author: nspiegelberg
Date: Tue Oct 11 17:42:26 2011
New Revision: 1181926

URL: http://svn.apache.org/viewvc?rev=1181926&view=rev
Log:
Add more sanity check when scanning hdfs

Summary:
We need to ignore files if their paths are not like
table_name/region_name/column_family_name  when scanning hdfs

Add more sanity check to avoid NULL Point Exceptions

Test Plan: running unit tests
Reviewed By: mbautin
Reviewers: mbautin, kranganathan, nspiegelberg
CC: hbase@lists, , mbautin, liyintang
Differential Revision: 299671

Modified:
    hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java

Modified: hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java?rev=1181926&r1=1181925&r2=1181926&view=diff
==============================================================================
--- hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java (original)
+++ hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java Tue Oct 11 17:42:26 2011
@@ -723,35 +723,48 @@ public class FSUtils {
     LOG.debug("Query Path: " + queryPath + " ; # list of files: " +
         statusList.length);
 
+		if (statusList == null) {
+			return regionToBestLocalityRSMapping;
+		}
     for (FileStatus regionStatus : statusList) {
       if(!regionStatus.isDir()) {
         continue;
       }
 
-      // get the region name; it may get some noise data
+			// get the region name; it may get some noise data
       Path regionPath = regionStatus.getPath();
       String regionName = regionPath.getName();
       if (!regionName.toLowerCase().matches("[0-9a-f]+")) {
         continue;
       }
-      //get table name
-      String tableName = regionPath.getParent().getName();
+      // ignore the empty directory
+      FileStatus[] cfList = fs.listStatus(regionPath);
+      if (cfList == null) {
+				continue;
+			}
 
+			//get table name
+      String tableName = regionPath.getParent().getName();
       int totalBlkCount = 0;
       blockCountMap.clear();
 
       // for each cf, get all the blocks information
-      FileStatus[] cfList = fs.listStatus(regionPath);
-      for (FileStatus cfStatus : cfList) {
+			for (FileStatus cfStatus : cfList) {
         if (!cfStatus.isDir()) {
           // skip because this is not a CF directory
           continue;
         }
         FileStatus[] storeFileLists = fs.listStatus(cfStatus.getPath());
+				if (storeFileLists == null) {
+					continue;
+				}
         for (FileStatus storeFile : storeFileLists) {
           BlockLocation[] blkLocations =
             fs.getFileBlockLocations(storeFile, 0, storeFile.getLen());
-          totalBlkCount += blkLocations.length;
+					if (blkLocations == null) {
+						continue;
+					}
+					totalBlkCount += blkLocations.length;
           for(BlockLocation blk: blkLocations) {
             for (String host: blk.getHosts()) {
               AtomicInteger count = blockCountMap.get(host);