@Test public void testRpcTimeout() throws IOException { Configuration c = new Configuration(TEST_UTIL.getConfiguration()); try (Table table = TEST_UTIL.getConnection().getTableBuilder(tableName, null) .setRpcTimeout(SleepCoprocessor.SLEEP_TIME / 2) .setReadRpcTimeout(SleepCoprocessor.SLEEP_TIME / 2) .setWriteRpcTimeout(SleepCoprocessor.SLEEP_TIME / 2) .setOperationTimeout(SleepCoprocessor.SLEEP_TIME * 100).build()) { execute(table); fail("Get should not have succeeded"); } catch (RetriesExhaustedException e) { LOG.info("We received an exception, as expected ", e); } // Again, with configuration based override c.setInt(HConstants.HBASE_RPC_TIMEOUT_KEY, SleepCoprocessor.SLEEP_TIME / 2); c.setInt(HConstants.HBASE_RPC_READ_TIMEOUT_KEY, SleepCoprocessor.SLEEP_TIME / 2); c.setInt(HConstants.HBASE_RPC_WRITE_TIMEOUT_KEY, SleepCoprocessor.SLEEP_TIME / 2); c.setInt(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT, SleepCoprocessor.SLEEP_TIME * 100); try (Connection conn = ConnectionFactory.createConnection(c)) { try (Table table = conn.getTable(tableName)) { execute(table); fail("Get should not have succeeded"); } catch (RetriesExhaustedException e) { LOG.info("We received an exception, as expected ", e); } } } }
try (Table table = UTIL.getConnection().getTableBuilder(NAME, null).setWriteRpcTimeout(1000) .setOperationTimeout(2000).build()) { table.put(
try (Table table = UTIL.getConnection().getTableBuilder(NAME, null).setWriteRpcTimeout(1000) .setOperationTimeout(2000).build()) { table.put(
TableBuilder builder = TEST_UTIL.getConnection().getTableBuilder(tableName, null).setRpcTimeout(Integer.MAX_VALUE) .setReadRpcTimeout(Integer.MAX_VALUE).setWriteRpcTimeout(Integer.MAX_VALUE);
@Test public void testDropTimeoutRequest() throws Exception { // Simulate the situation that the server is slow and client retries for several times because // of timeout. When a request can be handled after waiting in the queue, we will drop it if // it has been considered as timeout at client. If we don't drop it, the server will waste time // on handling timeout requests and finally all requests timeout and client throws exception. TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(TableName.valueOf(name.getMethodName())); builder.setCoprocessor(SleepLongerAtFirstCoprocessor.class.getName()); ColumnFamilyDescriptor cfd = ColumnFamilyDescriptorBuilder.newBuilder(FAM_NAM).build(); builder.setColumnFamily(cfd); TableDescriptor td = builder.build(); try (Admin admin = TEST_UTIL.getConnection().getAdmin()) { admin.createTable(td); } TableBuilder tb = TEST_UTIL.getConnection().getTableBuilder(td.getTableName(), null); tb.setReadRpcTimeout(SleepLongerAtFirstCoprocessor.SLEEP_TIME * 2); tb.setWriteRpcTimeout(SleepLongerAtFirstCoprocessor.SLEEP_TIME * 2); try (Table table = tb.build()) { table.get(new Get(FAM_NAM)); } } }
@Test public void testRpcTimeout() throws IOException { Configuration c = new Configuration(TEST_UTIL.getConfiguration()); try (Table table = TEST_UTIL.getConnection().getTableBuilder(tableName, null) .setRpcTimeout(SleepCoprocessor.SLEEP_TIME / 2) .setReadRpcTimeout(SleepCoprocessor.SLEEP_TIME / 2) .setWriteRpcTimeout(SleepCoprocessor.SLEEP_TIME / 2) .setOperationTimeout(SleepCoprocessor.SLEEP_TIME * 100).build()) { execute(table); fail("Get should not have succeeded"); } catch (RetriesExhaustedException e) { LOG.info("We received an exception, as expected ", e); } // Again, with configuration based override c.setInt(HConstants.HBASE_RPC_TIMEOUT_KEY, SleepCoprocessor.SLEEP_TIME / 2); c.setInt(HConstants.HBASE_RPC_READ_TIMEOUT_KEY, SleepCoprocessor.SLEEP_TIME / 2); c.setInt(HConstants.HBASE_RPC_WRITE_TIMEOUT_KEY, SleepCoprocessor.SLEEP_TIME / 2); c.setInt(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT, SleepCoprocessor.SLEEP_TIME * 100); try (Connection conn = ConnectionFactory.createConnection(c)) { try (Table table = conn.getTable(tableName)) { execute(table); fail("Get should not have succeeded"); } catch (RetriesExhaustedException e) { LOG.info("We received an exception, as expected ", e); } } } }
TableBuilder builder = TEST_UTIL.getConnection().getTableBuilder(tableName, null).setRpcTimeout(Integer.MAX_VALUE) .setReadRpcTimeout(Integer.MAX_VALUE).setWriteRpcTimeout(Integer.MAX_VALUE);
@Test public void testDropTimeoutRequest() throws Exception { // Simulate the situation that the server is slow and client retries for several times because // of timeout. When a request can be handled after waiting in the queue, we will drop it if // it has been considered as timeout at client. If we don't drop it, the server will waste time // on handling timeout requests and finally all requests timeout and client throws exception. TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(TableName.valueOf(name.getMethodName())); builder.setCoprocessor(SleepLongerAtFirstCoprocessor.class.getName()); ColumnFamilyDescriptor cfd = ColumnFamilyDescriptorBuilder.newBuilder(FAM_NAM).build(); builder.setColumnFamily(cfd); TableDescriptor td = builder.build(); try (Admin admin = TEST_UTIL.getConnection().getAdmin()) { admin.createTable(td); } TableBuilder tb = TEST_UTIL.getConnection().getTableBuilder(td.getTableName(), null); tb.setReadRpcTimeout(SleepLongerAtFirstCoprocessor.SLEEP_TIME * 2); tb.setWriteRpcTimeout(SleepLongerAtFirstCoprocessor.SLEEP_TIME * 2); try (Table table = tb.build()) { table.get(new Get(FAM_NAM)); } } }