You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2013/05/20 22:49:59 UTC

svn commit: r1484590 - in /hbase/branches/0.95: hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcClient.java hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestDelayedRpc.java

Author: stack
Date: Mon May 20 20:49:59 2013
New Revision: 1484590

URL: http://svn.apache.org/r1484590
Log:
HBASE-8579 TestDelayedRpc falis from time to time

Modified:
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcClient.java
    hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestDelayedRpc.java

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcClient.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcClient.java?rev=1484590&r1=1484589&r2=1484590&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcClient.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcClient.java Mon May 20 20:49:59 2013
@@ -69,7 +69,6 @@ import org.apache.hadoop.hbase.security.
 import org.apache.hadoop.hbase.security.HBaseSaslRpcClient;
 import org.apache.hadoop.hbase.security.SecurityInfo;
 import org.apache.hadoop.hbase.security.User;
-import org.apache.hadoop.hbase.security.token.AuthenticationTokenIdentifier;
 import org.apache.hadoop.hbase.security.token.AuthenticationTokenSelector;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.hadoop.hbase.util.Pair;

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestDelayedRpc.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestDelayedRpc.java?rev=1484590&r1=1484589&r2=1484590&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestDelayedRpc.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestDelayedRpc.java Mon May 20 20:49:59 2013
@@ -60,23 +60,23 @@ import com.google.protobuf.ServiceExcept
 @Category(MediumTests.class) // Fails sometimes with small tests
 public class TestDelayedRpc {
   private static final Log LOG = LogFactory.getLog(TestDelayedRpc.class);
-
   public static RpcServerInterface rpcServer;
-
   public static final int UNDELAYED = 0;
   public static final int DELAYED = 1;
+  private static final int RPC_CLIENT_TIMEOUT = 30000;
 
-  @Test
+  @Test (timeout=60000)
   public void testDelayedRpcImmediateReturnValue() throws Exception {
     testDelayedRpc(false);
   }
 
-  @Test
+  @Test (timeout=60000)
   public void testDelayedRpcDelayedReturnValue() throws Exception {
     testDelayedRpc(true);
   }
 
   private void testDelayedRpc(boolean delayReturnValue) throws Exception {
+    LOG.info("Running testDelayedRpc delayReturnValue=" + delayReturnValue);
     Configuration conf = HBaseConfiguration.create();
     InetSocketAddress isa = new InetSocketAddress("localhost", 0);
     TestDelayedImplementation instance = new TestDelayedImplementation(delayReturnValue);
@@ -91,11 +91,13 @@ public class TestDelayedRpc {
       BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(
           new ServerName(rpcServer.getListenerAddress().getHostName(),
               rpcServer.getListenerAddress().getPort(), System.currentTimeMillis()),
-          User.getCurrent(), 1000);
+          User.getCurrent(), RPC_CLIENT_TIMEOUT);
       TestDelayedRpcProtos.TestDelayedService.BlockingInterface stub =
         TestDelayedRpcProtos.TestDelayedService.newBlockingStub(channel);
       List<Integer> results = new ArrayList<Integer>();
+      // Setting true sets 'delayed' on the client.
       TestThread th1 = new TestThread(stub, true, results);
+      // Setting 'false' means we will return UNDELAYED as response immediately.
       TestThread th2 = new TestThread(stub, false, results);
       TestThread th3 = new TestThread(stub, false, results);
       th1.start();
@@ -108,6 +110,7 @@ public class TestDelayedRpc {
       th2.join();
       th3.join();
 
+      // We should get the two undelayed responses first.
       assertEquals(UNDELAYED, results.get(0).intValue());
       assertEquals(UNDELAYED, results.get(1).intValue());
       assertEquals(results.get(2).intValue(), delayReturnValue ? DELAYED :  0xDEADBEEF);
@@ -142,7 +145,7 @@ public class TestDelayedRpc {
    * Tests that we see a WARN message in the logs.
    * @throws Exception
    */
-  @Test
+  @Test (timeout=60000)
   public void testTooManyDelayedRpcs() throws Exception {
     Configuration conf = HBaseConfiguration.create();
     final int MAX_DELAYED_RPC = 10;
@@ -167,7 +170,7 @@ public class TestDelayedRpc {
       BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(
           new ServerName(rpcServer.getListenerAddress().getHostName(),
               rpcServer.getListenerAddress().getPort(), System.currentTimeMillis()),
-          User.getCurrent(), 1000);
+          User.getCurrent(), RPC_CLIENT_TIMEOUT);
       TestDelayedRpcProtos.TestDelayedService.BlockingInterface stub =
         TestDelayedRpcProtos.TestDelayedService.newBlockingStub(channel);
       Thread threads[] = new Thread[MAX_DELAYED_RPC + 1];
@@ -258,8 +261,8 @@ public class TestDelayedRpc {
     public void run() {
       Integer result;
       try {
-        result = new Integer(stub.test(null, TestArg.newBuilder().setDelay(delay).
-          build()).getResponse());
+        result = new Integer(stub.test(null, TestArg.newBuilder().setDelay(delay).build()).
+          getResponse());
       } catch (ServiceException e) {
         throw new RuntimeException(e);
       }