HBASE-1602 HRegionServer won't go down since we added in new LruBlockCache

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@790424 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2009-07-01 23:57:40 +00:00
parent 64eabfece1
commit de1cc3ec7b
5 changed files with 25 additions and 9 deletions

View File

@ -239,6 +239,7 @@ Release 0.20.0 - Unreleased
interface interface
HBASE-1594 Fix scan addcolumns after hbase-1385 commit (broken hudson build) HBASE-1594 Fix scan addcolumns after hbase-1385 commit (broken hudson build)
HBASE-1595 hadoop-default.xml and zoo.cfg in hbase jar 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 IMPROVEMENTS
HBASE-1089 Add count of regions on filesystem to master UI; add percentage HBASE-1089 Add count of regions on filesystem to master UI; add percentage

View File

@ -46,5 +46,10 @@ public interface BlockCache {
* @param blockName Block number to fetch. * @param blockName Block number to fetch.
* @return Block or null if block is not in the cache. * @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();
} }

View File

@ -22,12 +22,12 @@ package org.apache.hadoop.hbase.io.hfile;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.PriorityQueue; 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.atomic.AtomicLong;
import java.util.concurrent.locks.ReentrantLock; 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.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -108,7 +108,7 @@ public class LruBlockCache implements BlockCache, HeapSize {
private final EvictionThread evictionThread; private final EvictionThread evictionThread;
/** Statistics thread schedule pool (for heavy debugging, could remove) */ /** Statistics thread schedule pool (for heavy debugging, could remove) */
private final ScheduledExecutorService scheduleThreadPool = private final ScheduledExecutorService scheduleThreadPool =
Executors.newScheduledThreadPool(1); Executors.newScheduledThreadPool(1);
/** Current size of cache */ /** Current size of cache */
@ -320,7 +320,7 @@ public class LruBlockCache implements BlockCache, HeapSize {
long bytesToFree = size.get() - minSize(); 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"); bytesToFree + " bytes");
if(bytesToFree <= 0) return; if(bytesToFree <= 0) return;
@ -372,7 +372,7 @@ public class LruBlockCache implements BlockCache, HeapSize {
remainingBuckets--; remainingBuckets--;
} }
LOG.info("Block cache LRU eviction completed. " + LOG.debug("Block cache LRU eviction completed. " +
"Freed " + bytesFreed + " bytes"); "Freed " + bytesFreed + " bytes");
} finally { } finally {
@ -659,5 +659,8 @@ public class LruBlockCache implements BlockCache, HeapSize {
private long memorySize() { private long memorySize() {
return (long)Math.floor(this.maxSize * this.memoryFactor * this.minFactor); return (long)Math.floor(this.maxSize * this.memoryFactor * this.minFactor);
} }
public void shutdown() {
this.scheduleThreadPool.shutdown();
}
} }

View File

@ -63,4 +63,8 @@ public class SimpleBlockCache implements BlockCache {
boolean inMemory) { boolean inMemory) {
cache.put(blockName, new Ref(blockName, buf, q)); cache.put(blockName, new Ref(blockName, buf, q));
} }
public void shutdown() {
// noop
}
} }

View File

@ -602,6 +602,9 @@ public class HRegionServer implements HConstants, HRegionInterface,
e.printStackTrace(); 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. // 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 // TODO: Should we check they are alive? If OOME could have exited already