From 549a152a38391aed20a9442d6f72b095cf19eef3 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Wed, 17 Jul 2013 05:36:42 +0000 Subject: [PATCH] HBASE-8957 TestDrainingServer. testDrainingServerWithAbort fails git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1504005 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop/hbase/zookeeper/ZKAssign.java | 7 ++--- .../hbase/master/AssignmentManager.java | 2 +- .../hbase/regionserver/HRegionServer.java | 22 ++++++--------- .../hadoop/hbase/HBaseTestingUtility.java | 2 +- .../hadoop/hbase/TestDrainingServer.java | 27 +++++++++++-------- 5 files changed, 28 insertions(+), 32 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAssign.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAssign.java index 9cc20189909..ab73c951297 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAssign.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAssign.java @@ -783,8 +783,7 @@ public class ZKAssign { throws KeeperException { String encoded = region.getEncodedName(); if(LOG.isDebugEnabled()) { - LOG.debug(zkw.prefix("Attempting to transition node " + - HRegionInfo.prettyPrint(encoded) + + LOG.debug(zkw.prefix("Transitioning " + HRegionInfo.prettyPrint(encoded) + " from " + beginState.toString() + " to " + endState.toString())); } @@ -995,9 +994,7 @@ public class ZKAssign { List znodes = ZKUtil.listChildrenAndWatchForNewChildren(zkw, zkw.assignmentZNode); if (znodes != null && !znodes.isEmpty()) { - for (String znode : znodes) { - LOG.debug("ZK RIT -> " + znode); - } + LOG.debug("Waiting on RIT: " + znodes); } Thread.sleep(100); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java index 6e5cc90c2f3..51c0709a437 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java @@ -1851,7 +1851,7 @@ public class AssignmentManager extends ZooKeeperListener { LOG.debug("Server stopped/aborted; skipping assign of " + region); return; } - LOG.info("Assigning region " + region.getRegionNameAsString() + + LOG.info("Assigning " + region.getRegionNameAsString() + " to " + plan.getDestination().toString()); // Transition RegionState to PENDING_OPEN currentState = regionStates.updateRegionState(region, diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index d9f65ddbea9..074cd0e0173 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -1431,17 +1431,12 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa } private HLog getMetaWAL() throws IOException { - if (this.hlogForMeta == null) { - final String logName - = HLogUtil.getHLogDirectoryName(this.serverNameFromMasterPOV.toString()); - - Path logdir = new Path(rootDir, logName); - if (LOG.isDebugEnabled()) LOG.debug("logdir=" + logdir); - - this.hlogForMeta = HLogFactory.createMetaHLog(this.fs.getBackingFs(), - rootDir, logName, this.conf, getMetaWALActionListeners(), - this.serverNameFromMasterPOV.toString()); - } + if (this.hlogForMeta != null) return this.hlogForMeta; + final String logName = HLogUtil.getHLogDirectoryName(this.serverNameFromMasterPOV.toString()); + Path logdir = new Path(rootDir, logName); + if (LOG.isDebugEnabled()) LOG.debug("logdir=" + logdir); + this.hlogForMeta = HLogFactory.createMetaHLog(this.fs.getBackingFs(), rootDir, logName, + this.conf, getMetaWALActionListeners(), this.serverNameFromMasterPOV.toString()); return this.hlogForMeta; } @@ -1483,7 +1478,7 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa MetaLogRoller tmpLogRoller = new MetaLogRoller(this, this); String n = Thread.currentThread().getName(); Threads.setDaemonThreadRunning(tmpLogRoller.getThread(), - n + "MetaLogRoller", uncaughtExceptionHandler); + n + "-MetaLogRoller", uncaughtExceptionHandler); this.metaHLogRoller = tmpLogRoller; tmpLogRoller = null; listeners.add(this.metaHLogRoller); @@ -1665,8 +1660,7 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa //currently, we don't care about the region as much as we care about the //table.. (hence checking the tablename below) //_ROOT_ and .META. regions have separate WAL. - if (regionInfo != null && - regionInfo.isMetaTable()) { + if (regionInfo != null && regionInfo.isMetaTable()) { return getMetaWAL(); } return this.hlog; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java index 1d5d1df1857..ee531693b00 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java @@ -559,7 +559,7 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { if (readOnProp != null){ return Boolean.parseBoolean(readOnProp); } else { - return conf.getBoolean(propName, true); + return conf.getBoolean(propName, false); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java index ce7c9d0efcb..f214460e11a 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java @@ -35,6 +35,7 @@ import org.apache.hadoop.hbase.regionserver.HRegion; import org.apache.hadoop.hbase.regionserver.HRegionServer; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.JVMClusterUtil; +import org.apache.hadoop.hbase.util.Threads; import org.apache.hadoop.hbase.zookeeper.ZKAssign; import org.apache.hadoop.hbase.zookeeper.ZKUtil; import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher; @@ -184,11 +185,8 @@ public class TestDrainingServer { final long regionCount = TEST_UTIL.getMiniHBaseCluster().countServedRegions(); // Let's get a copy of the regions today. - Collection regions = new ArrayList(); - for (int i = 0; i < NB_SLAVES; i++) { - HRegionServer hrs = TEST_UTIL.getMiniHBaseCluster().getRegionServer(i); - regions.addAll( hrs.getCopyOfOnlineRegionsSortedBySize().values() ); - } + Collection regions = getRegions(); + LOG.info("All regions: " + regions); // Choose the draining server HRegionServer drainingServer = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0); @@ -229,8 +227,7 @@ public class TestDrainingServer { Collection regionsAfter = drainingServer.getCopyOfOnlineRegionsSortedBySize().values(); - LOG.info("Regions of drained server are: " + regionsAfter); - + LOG.info("Regions of drained server: " + regionsAfter + ", all regions: " + getRegions()); Assert.assertEquals("Test conditions are not met: regions were" + " created/deleted during the test. ", regionCount, TEST_UTIL.getMiniHBaseCluster().countServedRegions()); @@ -260,9 +257,17 @@ public class TestDrainingServer { } } + private Collection getRegions() { + Collection regions = new ArrayList(); + for (int i = 0; i < NB_SLAVES; i++) { + HRegionServer hrs = TEST_UTIL.getMiniHBaseCluster().getRegionServer(i); + regions.addAll( hrs.getCopyOfOnlineRegionsSortedBySize().values() ); + } + return regions; + } + private static void waitForAllRegionsOnline() throws Exception { // Wait for regions to come back on line again. - boolean done = false; while (!done) { Thread.sleep(1); @@ -284,6 +289,8 @@ public class TestDrainingServer { if (!rs.getRegionServer().getRegionsInTransitionInRS().isEmpty()) { done = false; } + // Sleep some else we spam the log w/ notice that servers are not yet alive. + Threads.sleep(10); } } } @@ -292,6 +299,4 @@ public class TestDrainingServer { return TEST_UTIL.getMiniHBaseCluster().countServedRegions() == (COUNT_OF_REGIONS + 1 /*catalog regions*/); } - -} - +} \ No newline at end of file