hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1196952 - in /hbase/trunk: CHANGES.txt src/test/java/org/apache/hadoop/hbase/regionserver/TestServerCustomProtocol.java
Date Thu, 03 Nov 2011 05:57:37 GMT
Author: garyh
Date: Thu Nov  3 05:57:36 2011
New Revision: 1196952

URL: http://svn.apache.org/viewvc?rev=1196952&view=rev
Log:
HBASE-4518  TestServerCustomProtocol fails intermittently

Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerCustomProtocol.java

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1196952&r1=1196951&r2=1196952&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Thu Nov  3 05:57:36 2011
@@ -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)  

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerCustomProtocol.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerCustomProtocol.java?rev=1196952&r1=1196951&r2=1196952&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerCustomProtocol.java
(original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerCustomProtocol.java
Thu Nov  3 05:57:36 2011
@@ -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.HT
 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);



Mime
View raw message