diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java index 8a541e2..7dcfdbb 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java @@ -18,6 +18,7 @@ package org.apache.hadoop.hbase.client; import java.io.IOException; +import java.net.SocketTimeoutException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -88,6 +89,12 @@ public class TestClientNoCluster { } @Test + public void testNoRetryOnSocketTimeoutException() throws IOException { + this.conf.set("hbase.client.connection.impl", SocketTimeoutOnConnection.class.getName()); + MetaScanner.metaScan(this.conf, null); + } + + @Test public void testDoNotRetryMetaScanner() throws IOException { this.conf.set("hbase.client.connection.impl", RegionServerStoppedOnScannerOpenConnection.class.getName()); @@ -197,4 +204,32 @@ public class TestClientNoCluster { return this.stub; } } + + /** + * Override to shutdown going to zookeeper for cluster id and meta location. + */ + static class SocketTimeoutOnConnection + extends HConnectionManager.HConnectionImplementation { + final ClientService.BlockingInterface stub; + + SocketTimeoutOnConnection(Configuration conf, boolean managed) + throws IOException { + super(conf, managed); + // Mock up my stub so open scanner returns a scanner id and then on next, we throw + // exceptions for three times and then after that, we return no more to scan. + this.stub = Mockito.mock(ClientService.BlockingInterface.class); + try { + Mockito.when(stub.scan((RpcController)Mockito.any(), + (ClientProtos.ScanRequest)Mockito.any())). + thenThrow(new ServiceException(new SocketTimeoutException("From Mockito"))); + } catch (ServiceException e) { + throw new IOException(e); + } + } + + @Override + public BlockingInterface getClient(ServerName sn) throws IOException { + return this.stub; + } + } } \ No newline at end of file