Author: stack
Date: Wed May  7 16:33:18 2008
New Revision: 654326

URL: http://svn.apache.org/viewvc?rev=654326&view=rev
Log:
HBASE-620 testmergetool failing in branch and trunk since hbase-618 went in

Modified:
    
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java

Modified: 
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: 
http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=654326&r1=654325&r2=654326&view=diff
==============================================================================
--- 
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java 
(original)
+++ 
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java 
Wed May  7 16:33:18 2008
@@ -165,12 +165,12 @@
     
     // Compact each region so we only have one store file per family
     
-    a.compactStores();
+    a.compactStores(true);
     if (LOG.isDebugEnabled()) {
       LOG.debug("Files for region: " + a.getRegionName());
       listPaths(fs, a.getRegionDir());
     }
-    b.compactStores();
+    b.compactStores(true);
     if (LOG.isDebugEnabled()) {
       LOG.debug("Files for region: " + b.getRegionName());
       listPaths(fs, b.getRegionDir());
@@ -845,6 +845,26 @@
    * @throws IOException
    */
   public Text compactStores() throws IOException {
+    return compactStores(false);
+  }
+
+  /**
+   * Called by compaction thread and after region is opened to compact the
+   * HStores if necessary.
+   *
+   * <p>This operation could block for a long time, so don't call it from a 
+   * time-sensitive thread.
+   *
+   * Note that no locking is necessary at this level because compaction only
+   * conflicts with a region split, and that cannot happen because the region
+   * server does them sequentially and not in parallel.
+   * 
+   * @param force True to force a compaction regardless of thresholds (Needed
+   * by merge).
+   * @return mid key if split is needed
+   * @throws IOException
+   */
+  private Text compactStores(final boolean force) throws IOException {
     Text midKey = null;
     if (this.closed.get()) {
       return midKey;
@@ -864,7 +884,7 @@
       long startTime = System.currentTimeMillis();
       doRegionCompactionPrep();
       for (HStore store: stores.values()) {
-        Text key = store.compact();
+        Text key = store.compact(force);
         if (key != null && midKey == null) {
           midKey = key;
         }
@@ -1062,7 +1082,6 @@
     Cell[] results = get(row, column, Long.MAX_VALUE, 1);
     return (results == null || results.length == 0)? null: results[0];
   }
-  
   /**
    * Fetch multiple versions of a single data item
    * 

Modified: 
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java
URL: 
http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java?rev=654326&r1=654325&r2=654326&view=diff
==============================================================================
--- 
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java 
(original)
+++ 
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java 
Wed May  7 16:33:18 2008
@@ -770,16 +770,18 @@
    * We don't want to hold the structureLock for the whole time, as a 
compact() 
    * can be lengthy and we want to allow cache-flushes during this period.
    * 
+   * @param force True to force a compaction regardless of thresholds (Needed
+   * by merge).
    * @return mid key if a split is needed, null otherwise
    * @throws IOException
    */
-  Text compact() throws IOException {
+  Text compact(final boolean force) throws IOException {
     synchronized (compactLock) {
       long maxId = -1;
       List<HStoreFile> filesToCompact = null;
       synchronized (storefiles) {
         filesToCompact = new ArrayList<HStoreFile>(this.storefiles.values());
-        if (!hasReferences(filesToCompact) &&
+        if (!force && !hasReferences(filesToCompact) &&
              filesToCompact.size() < compactionThreshold) {
           return checkSplit();
         }


Reply via email to