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:41:34 UTC

svn commit: r1181910 - in /hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase: ipc/HRegionInterface.java regionserver/HRegionServer.java

Author: nspiegelberg
Date: Tue Oct 11 17:41:34 2011
New Revision: 1181910

URL: http://svn.apache.org/viewvc?rev=1181910&view=rev
Log:
Check lastFlushTime for a region.

Summary: If snapshot_start_time > lastFlushTime then flush region, else don't.
In case the map task fails, this will prevent a region from being flushed
multiple times.
Test Plan: Tested on my dev cluster.
Reviewed By: nspiegelberg
Reviewers: kannan, nspiegelberg, aaiyer
Commenters: kannan
CC: pritam, madhuvaidya, nspiegelberg, kannan
Differential Revision: 275991

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

Modified: hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java?rev=1181910&r1=1181909&r2=1181910&view=diff
==============================================================================
--- hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java (original)
+++ hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java Tue Oct 11 17:41:34 2011
@@ -79,6 +79,18 @@ public interface HRegionInterface extend
   public void flushRegion(byte[] regionName)
     throws IllegalArgumentException, IOException;
 
+  /**
+   * Flush the given region if lastFlushTime < ifOlderThanTS
+   */
+  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);
+
   public List<String> getStoreFileList(byte[] regionName, byte[] columnFamily)
     throws IllegalArgumentException;
 

Modified: hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1181910&r1=1181909&r2=1181910&view=diff
==============================================================================
--- hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Tue Oct 11 17:41:34 2011
@@ -2314,6 +2314,33 @@ public class HRegionServer implements HR
     }
     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();
+  }
+
   /**
    * @return The HRegionInfos from online regions sorted
    */