HBASE-4518 TestServerCustomProtocol fails intermittently

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1196952 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Helmling 2011-11-03 05:57:36 +00:00
parent 09225cf9b6
commit a9992a53c4
2 changed files with 18 additions and 13 deletions

View File

@ -458,6 +458,7 @@ Release 0.92.0 - Unreleased
HBASE-4479 TestMasterFailover failure in Hbase-0.92#17(Ram)
HBASE-4651 ConcurrentModificationException might be thrown in
TestHCM.testConnectionUniqueness (Jinchao)
HBASE-4518 TestServerCustomProtocol fails intermittently
IMPROVEMENTS
HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack)

View File

@ -25,6 +25,8 @@ import java.io.IOException;
import java.util.List;
import java.util.Map;
import org.apache.hadoop.hbase.Coprocessor;
import org.apache.hadoop.hbase.CoprocessorEnvironment;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
@ -35,6 +37,7 @@ import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Row;
import org.apache.hadoop.hbase.client.coprocessor.Batch;
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
import org.apache.hadoop.hbase.ipc.CoprocessorProtocol;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.JVMClusterUtil;
@ -47,7 +50,7 @@ import com.google.common.collect.Lists;
public class TestServerCustomProtocol {
/* Test protocol */
private static interface PingProtocol extends CoprocessorProtocol {
public static interface PingProtocol extends CoprocessorProtocol {
public String ping();
public int getPingCount();
public int incrementCount(int diff);
@ -55,7 +58,7 @@ public class TestServerCustomProtocol {
}
/* Test protocol implementation */
private static class PingHandler implements PingProtocol, VersionedProtocol {
public static class PingHandler implements Coprocessor, PingProtocol, VersionedProtocol {
static int VERSION = 1;
private int counter = 0;
@ -90,6 +93,14 @@ public class TestServerCustomProtocol {
public long getProtocolVersion(String s, long l) throws IOException {
return VERSION;
}
@Override
public void start(CoprocessorEnvironment env) throws IOException {
}
@Override
public void stop(CoprocessorEnvironment env) throws IOException {
}
}
private static final byte[] TEST_TABLE = Bytes.toBytes("test");
@ -107,23 +118,16 @@ public class TestServerCustomProtocol {
@BeforeClass
public static void setupBeforeClass() throws Exception {
util.startMiniCluster(2);
util.getConfiguration().set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
PingHandler.class.getName());
util.startMiniCluster(1);
cluster = util.getMiniHBaseCluster();
HTable table = util.createTable(TEST_TABLE, TEST_FAMILY);
util.createMultiRegions(util.getConfiguration(), table, TEST_FAMILY,
new byte[][]{ HConstants.EMPTY_BYTE_ARRAY,
ROW_B, ROW_C});
// TODO: use a test coprocessor for registration (once merged with CP code)
// sleep here is an ugly hack to allow region transitions to finish
Thread.sleep(5000);
for (JVMClusterUtil.RegionServerThread t :
cluster.getRegionServerThreads()) {
for (HRegionInfo r : t.getRegionServer().getOnlineRegions()) {
t.getRegionServer().getOnlineRegion(r.getRegionName())
.registerProtocol(PingProtocol.class, new PingHandler());
}
}
Put puta = new Put( ROW_A );
puta.add(TEST_FAMILY, Bytes.toBytes("col1"), Bytes.toBytes(1));
table.put(puta);