HADOOP-2064 TestSplit assertion and NPE failures (Patch build #952 and #953)

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@585293 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2007-10-17 00:09:55 +00:00
parent 04cac52745
commit 0b92e8826a
3 changed files with 30 additions and 13 deletions

View File

@ -12,6 +12,7 @@ Trunk (unreleased changes)
BUG FIXES
HADOOP-2059 In tests, exceptions in min dfs shutdown should not fail test
(e.g. nightly #272)
HADOOP-2064 TestSplit assertion and NPE failures (Patch build #952 and #953)
IMPROVEMENTS
HADOOP-2401 Add convenience put method that takes writable

View File

@ -51,8 +51,8 @@ public class MiniHBaseCluster implements HConstants {
private boolean shutdownDFS;
private Path parentdir;
private MasterThread masterThread = null;
ArrayList<RegionServerThread> regionThreads =
new ArrayList<RegionServerThread>();
List<RegionServerThread> regionThreads =
java.util.Collections.synchronizedList(new ArrayList<RegionServerThread>());
private boolean deleteOnExit = true;
/**
@ -460,7 +460,7 @@ public class MiniHBaseCluster implements HConstants {
}
}
public ArrayList<RegionServerThread> getRegionThreads() {
public List<RegionServerThread> getRegionThreads() {
return this.regionThreads;
}
}

View File

@ -40,10 +40,10 @@ public class MultiRegionTable extends HBaseTestCase {
static final Log LOG = LogFactory.getLog(MultiRegionTable.class.getName());
/**
* Make a multi-region table. Presumption is that table already exists.
* Makes it multi-region by filling with data and provoking splits.
* Asserts parent region is cleaned up after its daughter splits release all
* references.
* Make a multi-region table. Presumption is that table already exists and
* that there is only one regionserver. Makes it multi-region by filling with
* data and provoking splits. Asserts parent region is cleaned up after its
* daughter splits release all references.
* @param conf
* @param cluster
* @param localFs
@ -75,14 +75,28 @@ public class MultiRegionTable extends HBaseTestCase {
int count = count(meta, tableName);
HTable t = new HTable(conf, new Text(tableName));
addContent(new HTableIncommon(t), columnName);
LOG.info("Finished content loading");
// All is running in the one JVM so I should be able to get the single
// region instance and bring on a split.
HRegionInfo hri =
t.getRegionLocation(HConstants.EMPTY_START_ROW).getRegionInfo();
HRegion r = cluster.regionThreads.get(0).getRegionServer().
onlineRegions.get(hri.getRegionName());
// Presumption is that there is only one regionserver.
HRegionInfo hri = null;
HRegion r = null;
for (int i = 0; i < 30; i++) {
hri = t.getRegionLocation(HConstants.EMPTY_START_ROW).getRegionInfo();
LOG.info("Region location: " + hri);
r = cluster.getRegionThreads().get(0).getRegionServer().
onlineRegions.get(hri.getRegionName());
if (r != null) {
break;
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
LOG.warn("Waiting on region to come online", e);
}
}
// Flush will provoke a split next time the split-checker thread runs.
r.flushcache(false);
@ -109,6 +123,7 @@ public class MultiRegionTable extends HBaseTestCase {
Map<Text, byte []> data = getSplitParentInfo(meta, hri);
HRegionInfo parent =
Writables.getHRegionInfoOrNull(data.get(HConstants.COL_REGIONINFO));
LOG.info("Found parent region: " + parent);
assertTrue(parent.isOffline());
assertTrue(parent.isSplit());
HRegionInfo splitA =
@ -227,7 +242,8 @@ public class MultiRegionTable extends HBaseTestCase {
}
// Make sure I get the parent.
if (hri.getRegionName().toString().
equals(parent.getRegionName().toString())) {
equals(parent.getRegionName().toString()) &&
hri.getRegionId() == parent.getRegionId()) {
return curVals;
}
}