HBASE-8883 TestAdmin.testCloseRegionWhenServerNameIsEmpty failed with ArrayIndexOutOfBoundsException
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1500822 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0f33c00f1f
commit
f47e212e1a
|
@ -44,6 +44,7 @@ import java.util.NavigableSet;
|
|||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -92,6 +93,7 @@ import org.apache.hadoop.hbase.util.FSUtils;
|
|||
import org.apache.hadoop.hbase.util.JVMClusterUtil;
|
||||
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread;
|
||||
import org.apache.hadoop.hbase.util.RegionSplitter;
|
||||
import org.apache.hadoop.hbase.util.RetryCounter;
|
||||
import org.apache.hadoop.hbase.util.Threads;
|
||||
import org.apache.hadoop.hbase.zookeeper.EmptyWatcher;
|
||||
import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
|
||||
|
@ -1634,9 +1636,10 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
|
|||
* @param tableName user table to lookup in .META.
|
||||
* @return region server that holds it, null if the row doesn't exist
|
||||
* @throws IOException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public HRegionServer getRSForFirstRegionInTable(byte[] tableName)
|
||||
throws IOException {
|
||||
throws IOException, InterruptedException {
|
||||
List<byte[]> metaRows = getMetaTableRows(tableName);
|
||||
if (metaRows == null || metaRows.isEmpty()) {
|
||||
return null;
|
||||
|
@ -1645,8 +1648,20 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
|
|||
Bytes.toString(tableName));
|
||||
byte [] firstrow = metaRows.get(0);
|
||||
LOG.debug("FirstRow=" + Bytes.toString(firstrow));
|
||||
int index = getMiniHBaseCluster().getServerWith(firstrow);
|
||||
return getMiniHBaseCluster().getRegionServerThreads().get(index).getRegionServer();
|
||||
long pause = getConfiguration().getLong(HConstants.HBASE_CLIENT_PAUSE,
|
||||
HConstants.DEFAULT_HBASE_CLIENT_PAUSE);
|
||||
int numRetries = getConfiguration().getInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER,
|
||||
HConstants.DEFAULT_HBASE_CLIENT_RETRIES_NUMBER);
|
||||
RetryCounter retrier = new RetryCounter(numRetries, (int)pause, TimeUnit.MICROSECONDS);
|
||||
while(retrier.shouldRetry()) {
|
||||
int index = getMiniHBaseCluster().getServerWith(firstrow);
|
||||
if (index != -1) {
|
||||
return getMiniHBaseCluster().getRegionServerThreads().get(index).getRegionServer();
|
||||
}
|
||||
// Came back -1. Region may not be online yet. Sleep a while.
|
||||
retrier.sleepUntilNextRetry();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1582,7 +1582,7 @@ public class TestAdmin {
|
|||
}
|
||||
|
||||
private HRegionServer startAndWriteData(String tableName, byte[] value)
|
||||
throws IOException {
|
||||
throws IOException, InterruptedException {
|
||||
// When the META table can be opened, the region servers are running
|
||||
new HTable(
|
||||
TEST_UTIL.getConfiguration(), HConstants.META_TABLE_NAME).close();
|
||||
|
|
|
@ -68,7 +68,7 @@ public class TestRegionServerCoprocessorExceptionWithAbort {
|
|||
|
||||
@Test
|
||||
public void testExceptionFromCoprocessorDuringPut()
|
||||
throws IOException {
|
||||
throws IOException, InterruptedException {
|
||||
// When we try to write to TEST_TABLE, the buggy coprocessor will
|
||||
// cause a NullPointerException, which will cause the regionserver (which
|
||||
// hosts the region we attempted to write to) to abort.
|
||||
|
|
|
@ -79,7 +79,7 @@ public class TestRegionServerCoprocessorExceptionWithRemove {
|
|||
|
||||
@Test(timeout=30000)
|
||||
public void testExceptionFromCoprocessorDuringPut()
|
||||
throws IOException {
|
||||
throws IOException, InterruptedException {
|
||||
// Set watches on the zookeeper nodes for all of the regionservers in the
|
||||
// cluster. When we try to write to TEST_TABLE, the buggy coprocessor will
|
||||
// cause a NullPointerException, which will cause the regionserver (which
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.apache.hadoop.hbase.regionserver.wal;
|
||||
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.HConstants;
|
||||
|
||||
/**
|
||||
* An Utility testcase that returns the number of log files that
|
||||
|
|
|
@ -189,7 +189,7 @@ public class TestLogRolling {
|
|||
TEST_UTIL.shutdownMiniCluster();
|
||||
}
|
||||
|
||||
private void startAndWriteData() throws IOException {
|
||||
private void startAndWriteData() throws IOException, InterruptedException {
|
||||
// When the META table can be opened, the region servers are running
|
||||
new HTable(TEST_UTIL.getConfiguration(), HConstants.META_TABLE_NAME);
|
||||
this.server = cluster.getRegionServerThreads().get(0).getRegionServer();
|
||||
|
|
|
@ -427,7 +427,8 @@ public class TestFlushSnapshotFromClient {
|
|||
FSUtils.logFileSystemState(UTIL.getDFSCluster().getFileSystem(), root, LOG);
|
||||
}
|
||||
|
||||
private void waitForTableToBeOnline(final byte[] tableName) throws IOException {
|
||||
private void waitForTableToBeOnline(final byte[] tableName)
|
||||
throws IOException, InterruptedException {
|
||||
HRegionServer rs = UTIL.getRSForFirstRegionInTable(tableName);
|
||||
List<HRegion> onlineRegions = rs.getOnlineRegions(tableName);
|
||||
for (HRegion region : onlineRegions) {
|
||||
|
|
Loading…
Reference in New Issue