try (Table table = builder.setOperationTimeout(120 * 1000).build()) { execute(table); try (Table table = builder.setOperationTimeout(30 * 1000).build()) { SleepAndFailFirstTime.ct.set(0); execute(table);
try (Table table = conn.getTableBuilder(tableName, null).setOperationTimeout(8000).build()) { try (Table table = conn.getTableBuilder(tableName, null).setOperationTimeout(6000).build()) {
@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); } } } }
.setOperationTimeout(2000).build()) { table.put( new Put(Bytes.toBytes("key")).addColumn(CF, Bytes.toBytes("cq"), Bytes.toBytes("val")));
.setOperationTimeout(2000).build()) { table.put( new Put(Bytes.toBytes("key")).addColumn(CF, Bytes.toBytes("cq"), Bytes.toBytes("val")));
@Test public void test() throws InterruptedException, IOException { HMaster master = UTIL.getMiniHBaseCluster().stopMaster(0).getMaster(); // Shutdown master before shutting down rs UTIL.waitFor(30000, () -> !master.isAlive()); RegionServerThread thread = null; for (RegionServerThread t : UTIL.getMiniHBaseCluster().getRegionServerThreads()) { if (!t.getRegionServer().getRegions(TABLE_NAME).isEmpty()) { thread = t; break; } } // shutdown rs thread.getRegionServer().abort("For testing"); thread.join(); // restart master UTIL.getMiniHBaseCluster().startMaster(); // make sure that we can schedule a SCP for the crashed server which WAL is disabled and bring // the region online. try (Table table = UTIL.getConnection().getTableBuilder(TABLE_NAME, null).setOperationTimeout(30000).build()) { table.put(new Put(Bytes.toBytes(1)).addColumn(CF, CQ, Bytes.toBytes(1))); assertEquals(1, Bytes.toInt(table.get(new Get(Bytes.toBytes(1))).getValue(CF, CQ))); } } }
try (Table table = conn.getTableBuilder(tableName, null).setOperationTimeout(8000).build()) { try (Table table = conn.getTableBuilder(tableName, null).setOperationTimeout(6000).build()) {
try (Table table = builder.setOperationTimeout(120 * 1000).build()) { execute(table); try (Table table = builder.setOperationTimeout(30 * 1000).build()) { SleepAndFailFirstTime.ct.set(0); execute(table);
@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); } } } }
@Test public void test() throws InterruptedException, IOException { HMaster master = UTIL.getMiniHBaseCluster().stopMaster(0).getMaster(); // Shutdown master before shutting down rs UTIL.waitFor(30000, () -> !master.isAlive()); RegionServerThread thread = null; for (RegionServerThread t : UTIL.getMiniHBaseCluster().getRegionServerThreads()) { if (!t.getRegionServer().getRegions(TABLE_NAME).isEmpty()) { thread = t; break; } } // shutdown rs thread.getRegionServer().abort("For testing"); thread.join(); // restart master UTIL.getMiniHBaseCluster().startMaster(); // make sure that we can schedule a SCP for the crashed server which WAL is disabled and bring // the region online. try (Table table = UTIL.getConnection().getTableBuilder(TABLE_NAME, null).setOperationTimeout(30000).build()) { table.put(new Put(Bytes.toBytes(1)).addColumn(CF, CQ, Bytes.toBytes(1))); assertEquals(1, Bytes.toInt(table.get(new Get(Bytes.toBytes(1))).getValue(CF, CQ))); } } }