hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kart...@apache.org
Subject svn commit: r1213487 - in /hbase/trunk/src/main/java/org/apache/hadoop/hbase: ipc/HRegionInterface.java regionserver/HRegion.java regionserver/HRegionServer.java
Date Mon, 12 Dec 2011 22:58:51 GMT
Author: karthik
Date: Mon Dec 12 22:58:51 2011
New Revision: 1213487

URL: http://svn.apache.org/viewvc?rev=1213487&view=rev
Log:
[jira] [HBASE-4661] get list of store files.

Summary:
1. Ported getStoreFileList API to trunk.
2. Also ported flushRegion API to trunk (with option of flushing if
lastFlushTime < TS).

Test Plan: Tested on 89.

Reviewers: Karthik, Kannan, nspiegelberg, JIRA

Reviewed By: Karthik

CC: HBase Diffs Facebook Group, Karthik, Kannan, stack, madhuvaidya

Differential Revision: 729

Modified:
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java?rev=1213487&r1=1213486&r2=1213487&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java Mon Dec 12
22:58:51 2011
@@ -83,6 +83,53 @@ public interface HRegionInterface extend
   throws NotServingRegionException, ConnectException, IOException;
 
   /**
+   * Flush the given region
+   * @param region name
+   */
+  public void flushRegion(byte[] regionName)
+    throws IllegalArgumentException, IOException;
+
+  /**
+   * Flush the given region if lastFlushTime < ifOlderThanTS
+   * @param region name
+   * @param timestamp
+   */
+  public void flushRegion(byte[] regionName, long ifOlderThanTS)
+    throws IllegalArgumentException, IOException;
+
+  /**
+   * Gets last flush time for the given region
+   * @return the last flush time for a region
+   */
+  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;
+
+  /**
    * Return all the data for the row that matches <i>row</i> exactly,
    * or the one that immediately preceeds it.
    *
@@ -423,6 +470,7 @@ public interface HRegionInterface extend
    * @param regionInfo region to flush
    * @throws NotServingRegionException
    * @throws IOException
+   * @deprecated use {@link #flushRegion(byte[])} instead
    */
   void flushRegion(HRegionInfo regionInfo)
   throws NotServingRegionException, IOException;

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1213487&r1=1213486&r2=1213487&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java Mon Dec 12
22:58:51 2011
@@ -2769,6 +2769,31 @@ public class HRegion implements HeapSize
     return this.stores;
   }
 
+  /**
+   * Return list of storeFiles for the set of CFs.
+   * Uses closeLock 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(closeLock) {
+      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/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1213487&r1=1213486&r2=1213487&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Mon
Dec 12 22:58:51 2011
@@ -2127,6 +2127,74 @@ public class HRegionServer implements HR
     return result;
   }
 
+  @Override
+  public List<String> getStoreFileList(byte[] regionName, byte[] columnFamily)
+    throws IllegalArgumentException {
+    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)
+          + " 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");
+    }
+    Set<byte[]> columnFamilies = region.getStores().keySet();
+    int nCF = columnFamilies.size();
+    return region.getStoreFileList(columnFamilies.toArray(new byte[nCF][]));
+  }
+  
+ /**
+  * Flushes the given region
+  */
+  public void flushRegion(byte[] regionName)
+    throws IllegalArgumentException, IOException {
+    HRegion region = getOnlineRegion(regionName);
+    if (region == null) {
+      throw new IllegalArgumentException("No region : " + new String(regionName)
+      + " available");
+    }
+    region.flushcache();
+  }
+
+ /**
+   * Flushes the given region if lastFlushTime < ifOlderThanTS
+   */
+   public void flushRegion(byte[] regionName, long ifOlderThanTS)
+     throws IllegalArgumentException, IOException {
+     HRegion region = getOnlineRegion(regionName);
+     if (region == null) {
+       throw new IllegalArgumentException("No region : " + new String(regionName)
+       + " available");
+     }
+     if (region.getLastFlushTime() < ifOlderThanTS) region.flushcache();
+   }
+
+  /**
+   * Gets last flush time for the given region
+   * @return the last flush time for a region
+   */
+  public long getLastFlushTime(byte[] regionName) {
+    HRegion region = getOnlineRegion(regionName);
+    if (region == null) {
+      throw new IllegalArgumentException("No region : " + new String(regionName)
+      + " available");
+    }
+    return region.getLastFlushTime();
+  }
+ 
   /**
    *
    * @param regionName



Mime
View raw message