diff --git a/CHANGES.txt b/CHANGES.txt index 48454ba8fa2..225d9536e80 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -239,6 +239,7 @@ Release 0.20.0 - Unreleased interface HBASE-1594 Fix scan addcolumns after hbase-1385 commit (broken hudson build) HBASE-1595 hadoop-default.xml and zoo.cfg in hbase jar + HBASE-1602 HRegionServer won't go down since we added in new LruBlockCache IMPROVEMENTS HBASE-1089 Add count of regions on filesystem to master UI; add percentage diff --git a/src/java/org/apache/hadoop/hbase/io/hfile/BlockCache.java b/src/java/org/apache/hadoop/hbase/io/hfile/BlockCache.java index 93be27a462f..18392cba87d 100644 --- a/src/java/org/apache/hadoop/hbase/io/hfile/BlockCache.java +++ b/src/java/org/apache/hadoop/hbase/io/hfile/BlockCache.java @@ -46,5 +46,10 @@ public interface BlockCache { * @param blockName Block number to fetch. * @return Block or null if block is not in the cache. */ - public ByteBuffer getBlock(String blockName); + public ByteBuffer getBlock(String blockName); + + /** + * Shutdown the cache. + */ + public void shutdown(); } \ No newline at end of file diff --git a/src/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java b/src/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java index 88f5a049919..511ce4b84d4 100644 --- a/src/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java +++ b/src/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java @@ -22,12 +22,12 @@ package org.apache.hadoop.hbase.io.hfile; import java.lang.ref.WeakReference; import java.nio.ByteBuffer; import java.util.PriorityQueue; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.locks.ReentrantLock; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -108,7 +108,7 @@ public class LruBlockCache implements BlockCache, HeapSize { private final EvictionThread evictionThread; /** Statistics thread schedule pool (for heavy debugging, could remove) */ - private final ScheduledExecutorService scheduleThreadPool = + private final ScheduledExecutorService scheduleThreadPool = Executors.newScheduledThreadPool(1); /** Current size of cache */ @@ -320,7 +320,7 @@ public class LruBlockCache implements BlockCache, HeapSize { long bytesToFree = size.get() - minSize(); - LOG.info("Block cache LRU eviction started. Attempting to free " + + LOG.debug("Block cache LRU eviction started. Attempting to free " + bytesToFree + " bytes"); if(bytesToFree <= 0) return; @@ -372,7 +372,7 @@ public class LruBlockCache implements BlockCache, HeapSize { remainingBuckets--; } - LOG.info("Block cache LRU eviction completed. " + + LOG.debug("Block cache LRU eviction completed. " + "Freed " + bytesFreed + " bytes"); } finally { @@ -659,5 +659,8 @@ public class LruBlockCache implements BlockCache, HeapSize { private long memorySize() { return (long)Math.floor(this.maxSize * this.memoryFactor * this.minFactor); } - + + public void shutdown() { + this.scheduleThreadPool.shutdown(); + } } diff --git a/src/java/org/apache/hadoop/hbase/io/hfile/SimpleBlockCache.java b/src/java/org/apache/hadoop/hbase/io/hfile/SimpleBlockCache.java index c904c164abe..a2ba94a71b8 100644 --- a/src/java/org/apache/hadoop/hbase/io/hfile/SimpleBlockCache.java +++ b/src/java/org/apache/hadoop/hbase/io/hfile/SimpleBlockCache.java @@ -63,4 +63,8 @@ public class SimpleBlockCache implements BlockCache { boolean inMemory) { cache.put(blockName, new Ref(blockName, buf, q)); } + + public void shutdown() { + // noop + } } diff --git a/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index 3d1103da2ba..eebd82ab779 100644 --- a/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -602,6 +602,9 @@ public class HRegionServer implements HConstants, HRegionInterface, e.printStackTrace(); } } + // Send cache a shutdown. + LruBlockCache c = (LruBlockCache)StoreFile.getBlockCache(this.conf); + if (c != null) c.shutdown(); // Send interrupts to wake up threads if sleeping so they notice shutdown. // TODO: Should we check they are alive? If OOME could have exited already