From 84b7463032cb8d24e546df9182659d6eda4585df Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Mon, 5 Jan 2009 22:32:37 +0000 Subject: [PATCH] HBASE-1083 Will keep scheduling major compactions if last time one ran, we didn't. git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@731748 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 2 ++ .../regionserver/CompactSplitThread.java | 3 +- .../hadoop/hbase/regionserver/HStore.java | 28 +++++++++++-------- src/webapps/master/WEB-INF/web.xml | 16 +++++------ 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index bb3d8b109a4..2178e6eefe3 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -128,6 +128,8 @@ Release 0.19.0 - Unreleased HBASE-1097 SequenceFile.Reader keeps around buffer whose size is that of largest item read -> results in lots of dead heap HBASE-1107 NPE in HStoreScanner.updateReaders + HBASE-1083 Will keep scheduling major compactions if last time one ran, we + didn't. IMPROVEMENTS HBASE-901 Add a limit to key length, check key and value length on client side diff --git a/src/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java b/src/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java index d02c545f031..32e5cdf911d 100644 --- a/src/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java +++ b/src/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java @@ -143,7 +143,8 @@ class CompactSplitThread extends Thread implements HConstants { return; } LOG.debug("Compaction requested for region " + - Bytes.toString(r.getRegionName()) + + Bytes.toString(r.getRegionName()) + "/" + + r.getRegionInfo().getEncodedName() + (why != null && !why.isEmpty()? " because: " + why: "")); synchronized (regionsInQueue) { if (!regionsInQueue.contains(r)) { diff --git a/src/java/org/apache/hadoop/hbase/regionserver/HStore.java b/src/java/org/apache/hadoop/hbase/regionserver/HStore.java index 4bd400d8cb9..55096780036 100644 --- a/src/java/org/apache/hadoop/hbase/regionserver/HStore.java +++ b/src/java/org/apache/hadoop/hbase/regionserver/HStore.java @@ -786,7 +786,7 @@ public class HStore implements HConstants { if (stats == null || stats.length == 0) { return 0l; } - long lowTimestamp = Long.MAX_VALUE; + long lowTimestamp = Long.MAX_VALUE; for (int i = 0; i < stats.length; i++) { long timestamp = stats[i].getModificationTime(); if (timestamp < lowTimestamp){ @@ -966,7 +966,12 @@ public class HStore implements HConstants { * @return True if we should run a major compaction. */ boolean isMajorCompaction() throws IOException { - return isMajorCompaction(null); + List filesToCompact = null; + synchronized (storefiles) { + // filesToCompact are sorted oldest to newest. + filesToCompact = new ArrayList(this.storefiles.values()); + } + return isMajorCompaction(filesToCompact); } /* @@ -977,25 +982,24 @@ public class HStore implements HConstants { throws IOException { boolean result = false; Path mapdir = HStoreFile.getMapDir(this.basedir, this.info.getEncodedName(), - this.family.getName()); + this.family.getName()); long lowTimestamp = getLowestTimestamp(fs, mapdir); - if (lowTimestamp < (System.currentTimeMillis() - this.majorCompactionTime) && - lowTimestamp > 0l) { + long now = System.currentTimeMillis(); + if (lowTimestamp > 0l && lowTimestamp < (now - this.majorCompactionTime)) { // Major compaction time has elapsed. - long elapsedTime = System.currentTimeMillis() - lowTimestamp; + long elapsedTime = now - lowTimestamp; if (filesToCompact != null && filesToCompact.size() == 1 && filesToCompact.get(0).isMajorCompaction() && (this.ttl == HConstants.FOREVER || elapsedTime < this.ttl)) { if (LOG.isDebugEnabled()) { - LOG.debug("Skipping major compaction because only one (major) " + - "compacted file only and elapsedTime " + elapsedTime + - " is < ttl=" + this.ttl); + LOG.debug("Skipping major compaction of " + this.storeNameStr + + " because one (major) compacted file only and elapsedTime " + + elapsedTime + "ms is < ttl=" + this.ttl); } } else { if (LOG.isDebugEnabled()) { - LOG.debug("Major compaction triggered on store: " + - this.storeNameStr + ". Time since last major compaction: " + - ((System.currentTimeMillis() - lowTimestamp)/1000) + " seconds"); + LOG.debug("Major compaction triggered on store " + this.storeNameStr + + "; time since last major compaction " + (now - lowTimestamp) + "ms"); } result = true; } diff --git a/src/webapps/master/WEB-INF/web.xml b/src/webapps/master/WEB-INF/web.xml index 2c7766d2c19..a10ee291e94 100644 --- a/src/webapps/master/WEB-INF/web.xml +++ b/src/webapps/master/WEB-INF/web.xml @@ -10,8 +10,8 @@ Automatically created by Tomcat JspC. - org.apache.hadoop.hbase.generated.master.master_jsp - org.apache.hadoop.hbase.generated.master.master_jsp + org.apache.hadoop.hbase.generated.master.table_jsp + org.apache.hadoop.hbase.generated.master.table_jsp @@ -20,13 +20,13 @@ Automatically created by Tomcat JspC. - org.apache.hadoop.hbase.generated.master.table_jsp - org.apache.hadoop.hbase.generated.master.table_jsp + org.apache.hadoop.hbase.generated.master.master_jsp + org.apache.hadoop.hbase.generated.master.master_jsp - org.apache.hadoop.hbase.generated.master.master_jsp - /master.jsp + org.apache.hadoop.hbase.generated.master.table_jsp + /table.jsp @@ -35,8 +35,8 @@ Automatically created by Tomcat JspC. - org.apache.hadoop.hbase.generated.master.table_jsp - /table.jsp + org.apache.hadoop.hbase.generated.master.master_jsp + /master.jsp