From b58a646039f2b8830118be3bb6378bf534256291 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Thu, 29 Oct 2009 04:42:15 +0000 Subject: [PATCH] HBASE-1816 Master rewrite; should have removed safe-mode from regionserver-side too -- Needed to remove the wait up in top of flush and compactions threads-- used to wait on safe mode... was stuck there... git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@830844 13f79535-47bb-0310-9956-ffa450edef68 --- .../regionserver/CompactSplitThread.java | 7 --- .../hbase/regionserver/HRegionServer.java | 51 +------------------ .../hbase/regionserver/MemStoreFlusher.java | 13 ++--- .../regionserver/wal/TestLogRolling.java | 11 ++-- 4 files changed, 7 insertions(+), 75 deletions(-) diff --git a/src/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java b/src/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java index 5e0890f1d36..96ec15cd35a 100644 --- a/src/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java +++ b/src/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java @@ -70,13 +70,6 @@ class CompactSplitThread extends Thread implements HConstants { @Override public void run() { - while (!this.server.isStopRequested()) { - try { - Thread.sleep(this.frequency); - } catch (InterruptedException ex) { - continue; - } - } int count = 0; while (!this.server.isStopRequested()) { HRegion r = null; diff --git a/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index 5f74b9c9dde..c5855ce46c4 100644 --- a/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -202,9 +202,6 @@ public class HRegionServer implements HConstants, HRegionInterface, // eclipse warning when accessed by inner classes protected volatile HLog hlog; LogRoller hlogRoller; - - // limit compactions while starting up - CompactionLimitThread compactionLimitThread; // flag set after we're done setting up server threads (used for testing) protected volatile boolean isOnline; @@ -858,48 +855,6 @@ public class HRegionServer implements HConstants, HRegionInterface, return this.fsOk; } - /** - * Thread that gradually ups compaction limit. - */ - private class CompactionLimitThread extends Thread { - protected CompactionLimitThread() {} - - @Override - public void run() { - // Slowly increase per-cycle compaction limit, finally setting it to - // unlimited (-1) - int compactionCheckInterval = - conf.getInt("hbase.regionserver.thread.splitcompactcheckfrequency", - 20 * 1000); - final int limitSteps[] = { - 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - -1 - }; - for (int i = 0; i < limitSteps.length; i++) { - // Just log changes. - if (compactSplitThread.getLimit() != limitSteps[i] && - LOG.isDebugEnabled()) { - LOG.debug("setting compaction limit to " + limitSteps[i]); - } - compactSplitThread.setLimit(limitSteps[i]); - try { - Thread.sleep(compactionCheckInterval); - } catch (InterruptedException ex) { - // unlimit compactions before exiting - compactSplitThread.setLimit(-1); - if (LOG.isDebugEnabled()) { - LOG.debug(this.getName() + " exiting on interrupt"); - } - return; - } - } - LOG.info("compactions no longer limited"); - } - } - /* * Thread to shutdown the region server in an orderly manner. This thread * is registered as a shutdown hook in the HRegionServer constructor and is @@ -1130,10 +1085,6 @@ public class HRegionServer implements HConstants, HRegionInterface, } } - this.compactionLimitThread = new CompactionLimitThread(); - Threads.setDaemonThreadRunning(this.compactionLimitThread, n + - ".compactionLimitThread", handler); - // Start Server. This service is like leases in that it internally runs // a thread. this.server.start(); @@ -2083,7 +2034,7 @@ public class HRegionServer implements HConstants, HRegionInterface, * @return true if a stop has been requested. */ public boolean isStopRequested() { - return stopRequested.get(); + return this.stopRequested.get(); } /** diff --git a/src/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java b/src/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java index 9512981e7cf..23aa3096d20 100644 --- a/src/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java +++ b/src/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java @@ -133,16 +133,9 @@ class MemStoreFlusher extends Thread implements FlushRequester { @Override public void run() { while (!this.server.isStopRequested()) { - try { - Thread.sleep(threadWakeFrequency); - } catch (InterruptedException ex) { - continue; - } - } - while (!server.isStopRequested()) { HRegion r = null; try { - r = flushQueue.poll(threadWakeFrequency, TimeUnit.MILLISECONDS); + r = this.flushQueue.poll(this.threadWakeFrequency, TimeUnit.MILLISECONDS); if (r == null) { continue; } @@ -162,8 +155,8 @@ class MemStoreFlusher extends Thread implements FlushRequester { } } } - regionsInQueue.clear(); - flushQueue.clear(); + this.regionsInQueue.clear(); + this.flushQueue.clear(); LOG.info(getName() + " exiting"); } diff --git a/src/test/org/apache/hadoop/hbase/regionserver/wal/TestLogRolling.java b/src/test/org/apache/hadoop/hbase/regionserver/wal/TestLogRolling.java index e6294d285df..880391a5a63 100644 --- a/src/test/org/apache/hadoop/hbase/regionserver/wal/TestLogRolling.java +++ b/src/test/org/apache/hadoop/hbase/regionserver/wal/TestLogRolling.java @@ -99,7 +99,6 @@ public class TestLogRolling extends HBaseClusterTestCase { private void startAndWriteData() throws Exception { // When the META table can be opened, the region servers are running new HTable(conf, HConstants.META_TABLE_NAME); - this.server = cluster.getRegionThreads().get(0).getRegionServer(); this.log = server.getLog(); @@ -109,15 +108,12 @@ public class TestLogRolling extends HBaseClusterTestCase { HBaseAdmin admin = new HBaseAdmin(conf); admin.createTable(desc); HTable table = new HTable(conf, tableName); - for (int i = 1; i <= 256; i++) { // 256 writes should cause 8 log rolls Put put = new Put(Bytes.toBytes("row" + String.format("%1$04d", i))); put.add(HConstants.CATALOG_FAMILY, null, value); table.put(put); - if (i % 32 == 0) { // After every 32 writes sleep to let the log roller run - try { Thread.sleep(2000); } catch (InterruptedException e) { @@ -126,14 +122,14 @@ public class TestLogRolling extends HBaseClusterTestCase { } } } - + /** * Tests that logs are deleted * * @throws Exception */ public void testLogRolling() throws Exception { - tableName = getName(); + this.tableName = getName(); try { startAndWriteData(); LOG.info("after writing there are " + log.getNumLogFiles() + " log files"); @@ -158,5 +154,4 @@ public class TestLogRolling extends HBaseClusterTestCase { throw e; } } - -} +} \ No newline at end of file