hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nspiegelb...@apache.org
Subject svn commit: r1203024 - in /hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase: ipc/HRegionInterface.java regionserver/HRegion.java regionserver/HRegionServer.java
Date Thu, 17 Nov 2011 02:25:12 GMT
Author: nspiegelberg
Date: Thu Nov 17 02:25:11 2011
New Revision: 1203024

URL: http://svn.apache.org/viewvc?rev=1203024&view=rev
Log:
API to return a list of all store files for a particular region.

Summary: Adding an API to return a list of all store files (across all CFs).

Test Plan: Tested on dev cluster.

Reviewers: aaiyer, kranganathan, kannan

Reviewed By: kranganathan

CC: pritam, kannan, kranganathan, madhuvaidya

Differential Revision: 340687

Task ID: 754462

Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java?rev=1203024&r1=1203023&r2=1203024&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java
Thu Nov 17 02:25:11 2011
@@ -92,10 +92,33 @@ public interface HRegionInterface extend
    */
   public long getLastFlushTime(byte[] regionName);
 
+  /**
+   * Get a list of store files for a particular CF in a particular region
+   * @param region name
+   * @param CF name
+   * @return the list of store files
+   */
   public List<String> getStoreFileList(byte[] regionName, byte[] columnFamily)
     throws IllegalArgumentException;
 
   /**
+   * Get a list of store files for a set of CFs in a particular region
+   * @param region name
+   * @param CF names
+   * @return the list of store files
+   */
+  public List<String> getStoreFileList(byte[] regionName, byte[][] columnFamilies)
+    throws IllegalArgumentException;
+
+  /**
+   * Get a list of store files for all CFs in a particular region
+   * @param region name
+   * @return the list of store files
+   */
+  public List<String> getStoreFileList(byte[] regionName)
+    throws IllegalArgumentException;
+
+  /**
   * @param rollCurrentHLog if true, the current HLog is rolled and will be
   * included in the list returned
   * @return list of HLog files

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1203024&r1=1203023&r2=1203024&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
Thu Nov 17 02:25:11 2011
@@ -2463,6 +2463,31 @@ public class HRegion implements HeapSize
     return this.stores;
   }
 
+  /**
+   * Return list of storeFiles for the set of CFs.
+   * Uses splitLock to prevent the race condition where a region closes
+   * in between the for loop - closing the stores one by one, some stores
+   * will return 0 files.
+   * @return List of storeFiles.
+   */
+  public List<String> getStoreFileList(final byte [][] columns)
+    throws IllegalArgumentException {
+    List<String> storeFileNames = new ArrayList<String>();
+    synchronized(splitLock) {
+      for(byte[] column : columns) {
+        Store store = this.stores.get(column);
+        if (store == null) {
+          throw new IllegalArgumentException("No column family : " +
+              new String(column) + " available");
+        }
+        List<StoreFile> storeFiles = store.getStorefiles();
+        for (StoreFile storeFile: storeFiles) {
+          storeFileNames.add(storeFile.getPath().toString());
+        }
+      }
+    }
+    return storeFileNames;
+  }
   //////////////////////////////////////////////////////////////////////////////
   // Support code
   //////////////////////////////////////////////////////////////////////////////

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1203024&r1=1203023&r2=1203024&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Thu Nov 17 02:25:11 2011
@@ -2432,22 +2432,30 @@ public class HRegionServer implements HR
   @Override
   public List<String> getStoreFileList(byte[] regionName, byte[] columnFamily)
     throws IllegalArgumentException {
-	  HRegion region = getOnlineRegion(regionName);
+    return getStoreFileList(regionName, new byte[][]{columnFamily});
+  }
+
+  @Override
+  public List<String> getStoreFileList(byte[] regionName, byte[][] columnFamilies)
+    throws IllegalArgumentException {
+    HRegion region = getOnlineRegion(regionName);
     if (region == null) {
-      throw new IllegalArgumentException("No region : " + new String(regionName)
+      throw new IllegalArgumentException("No region: " + new String(regionName)
+          + " available");
+    }
+    return region.getStoreFileList(columnFamilies);
+  }
+
+  public List<String> getStoreFileList(byte[] regionName)
+    throws IllegalArgumentException {
+    HRegion region = getOnlineRegion(regionName);
+    if (region == null) {
+      throw new IllegalArgumentException("No region: " + new String(regionName)
           + " available");
     }
-    Store store = region.getStore(columnFamily);
-    if (store == null) {
-      throw new IllegalArgumentException("No column family : " +
-          new String(columnFamily) + " available");
-    }
-	  List<StoreFile> storeFiles = region.getStore(columnFamily).getStorefiles();
-	  List<String> storeFileNames = new ArrayList<String>(storeFiles.size());
-	  for (StoreFile storeFile: storeFiles) {
-		  storeFileNames.add(storeFile.getPath().toString());
-	  }
-	  return storeFileNames;
+    Set<byte[]> columnFamilies = region.getStores().keySet();
+    int nCF = columnFamilies.size();
+    return region.getStoreFileList(columnFamilies.toArray(new byte[nCF][]));
   }
 
   /**



Mime
View raw message