From ef30d39681eac91102419570c2f617f746bc3ec6 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Thu, 16 Jul 2009 23:24:21 +0000 Subject: [PATCH] HBASE-1583 Start/Stop of large cluster untenable git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@794905 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 1 + .../regionserver/CompactSplitThread.java | 11 +++++----- .../hadoop/hbase/regionserver/HRegion.java | 21 ++++++++++++++++++- .../hbase/regionserver/HRegionServer.java | 8 ++++--- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 48918d30524..0791e71fbea 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -272,6 +272,7 @@ Release 0.20.0 - Unreleased time we cycle the hstore.getStorefilesCount() > this.blockingStoreFilesNumber loop HBASE-1058 Disable 1058 on catalog tables + HBASE-1583 Start/Stop of large cluster untenable IMPROVEMENTS HBASE-1089 Add count of regions on filesystem to master UI; add percentage diff --git a/src/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java b/src/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java index 8f0f0e8d62e..b637f02569a 100644 --- a/src/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java +++ b/src/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java @@ -26,17 +26,16 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantLock; -import org.apache.hadoop.util.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.hbase.HBaseConfiguration; +import org.apache.hadoop.hbase.HConstants; +import org.apache.hadoop.hbase.HRegionInfo; +import org.apache.hadoop.hbase.RemoteExceptionHandler; import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.Put; -import org.apache.hadoop.hbase.HBaseConfiguration; -import org.apache.hadoop.hbase.RemoteExceptionHandler; -import org.apache.hadoop.hbase.HRegionInfo; -import org.apache.hadoop.hbase.HConstants; -import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Writables; +import org.apache.hadoop.util.StringUtils; /** * Compact region on request and then run split if appropriate diff --git a/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java index 811386126fd..21f6606a632 100644 --- a/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java +++ b/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java @@ -343,6 +343,20 @@ public class HRegion implements HConstants, HeapSize { // , Writable{ " available; sequence id is " + this.minSequenceId); } + /** + * @return True if this region has references. + */ + boolean hasReferences() { + for (Map.Entry e: this.stores.entrySet()) { + for (Map.Entry ee: + e.getValue().getStorefiles().entrySet()) { + // Found a reference, return. + if (ee.getValue().isReference()) return true; + } + } + return false; + } + /* * Write out an info file under the region directory. Useful recovering * mangled regions. @@ -747,6 +761,10 @@ public class HRegion implements HConstants, HeapSize { // , Writable{ */ byte [] compactStores(final boolean majorCompaction) throws IOException { + if (this.closing.get() || this.closed.get()) { + LOG.debug("Skipping compaction on " + this + " because closing/closed"); + return null; + } splitsAndClosesLock.readLock().lock(); try { byte [] splitRow = null; @@ -1487,12 +1505,13 @@ public class HRegion implements HConstants, HeapSize { // , Writable{ private boolean isFlushSize(final long size) { return size > this.memstoreFlushSize; } - + // Do any reconstruction needed from the log protected void doReconstructionLog(Path oldLogFile, long minSeqId, long maxSeqId, Progressable reporter) throws UnsupportedEncodingException, IOException { // Nothing to do (Replaying is done in HStores) + // Used by subclasses; e.g. THBase. } protected Store instantiateHStore(Path baseDir, diff --git a/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index 80c7204e9e6..48e83bec732 100644 --- a/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -1553,9 +1553,11 @@ public class HRegionServer implements HConstants, HRegionInterface, if (region == null) { try { region = instantiateRegion(regionInfo); - // Startup a compaction early if one is needed. - this.compactSplitThread. - compactionRequested(region, "Region open check"); + // Startup a compaction early if one is needed, if region has references. + if (region.hasReferences()) { + this.compactSplitThread.compactionRequested(region, + "Region has references on open"); + } } catch (Throwable e) { Throwable t = cleanup(e, "Error opening " + regionInfo.getRegionNameAsString());