diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcClient.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcClient.java index 6ff45d7..5f587f7 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcClient.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcClient.java @@ -69,7 +69,6 @@ import org.apache.hadoop.hbase.security.AuthMethod; 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; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestDelayedRpc.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestDelayedRpc.java index c3f1665..b3520d2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestDelayedRpc.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestDelayedRpc.java @@ -60,23 +60,23 @@ import com.google.protobuf.ServiceException; @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 results = new ArrayList(); + // 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); }