hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nspiegelb...@apache.org
Subject svn commit: r1181436 - /hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java
Date Tue, 11 Oct 2011 02:08:15 GMT
Author: nspiegelberg
Date: Tue Oct 11 02:08:12 2011
New Revision: 1181436

URL: http://svn.apache.org/viewvc?rev=1181436&view=rev
Log:
HBASE-3189: Stagger Major Compactions

Summary:
Adds jitter to major compaction timing so we can reasonably guarantee that all
regions do not hit us with majors at the same time.

Test Plan:
mvn clean install

DiffCamp Revision: 177290
Reviewed By: kannan
CC: nspiegelberg, kannan
Revert Plan:
OK

Modified:
    hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java

Modified: hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java?rev=1181436&r1=1181435&r2=1181436&view=diff
==============================================================================
--- hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java (original)
+++ hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java Tue
Oct 11 02:08:12 2011
@@ -189,13 +189,7 @@ public class Store implements HeapSize {
     this.blockingStoreFileCount =
       conf.getInt("hbase.hstore.blockingStoreFiles", -1);
 
-    this.majorCompactionTime =
-      conf.getLong(HConstants.MAJOR_COMPACTION_PERIOD, 86400000);
-    if (family.getValue(HConstants.MAJOR_COMPACTION_PERIOD) != null) {
-      String strCompactionTime =
-        family.getValue(HConstants.MAJOR_COMPACTION_PERIOD);
-      this.majorCompactionTime = (new Long(strCompactionTime)).longValue();
-    }
+    this.majorCompactionTime = getNextMajorCompactTime();
 
     this.maxFilesToCompact = conf.getInt("hbase.hstore.compaction.max", 10);
     this.minCompactSize = this.region.memstoreFlushSize * 3 / 2; // +50% pad
@@ -830,14 +824,37 @@ public class Store implements HeapSize {
       } else {
         if (LOG.isDebugEnabled()) {
           LOG.debug("Major compaction triggered on store " + this.storeNameStr +
-            "; time since last major compaction " + (now - lowTimestamp) + "ms");
+            "; time since last major compaction " +
+            StringUtils.formatTimeDiff(now, lowTimestamp));
         }
         result = true;
+        this.majorCompactionTime = getNextMajorCompactTime();
       }
     }
     return result;
   }
 
+  long getNextMajorCompactTime() {
+    // default = 24hrs
+    long ret = conf.getLong(HConstants.MAJOR_COMPACTION_PERIOD, 1000*60*60*24);
+    if (family.getValue(HConstants.MAJOR_COMPACTION_PERIOD) != null) {
+      String strCompactionTime =
+        family.getValue(HConstants.MAJOR_COMPACTION_PERIOD);
+      ret = (new Long(strCompactionTime)).longValue();
+    }
+
+    if (ret > 0) {
+      // default = 20% = +/- 4.8 hrs
+      double jitterPct =  conf.getFloat("hbase.hregion.majorcompaction.jitter",
+          0.20F);
+      if (jitterPct > 0) {
+        long jitter = Math.round(ret * jitterPct);
+        ret += jitter - Math.round(2L * jitter * Math.random());
+      }
+    }
+    return ret;
+  }
+
   /**
    * Do a minor/major compaction.  Uses the scan infrastructure to make it easy.
    *



Mime
View raw message