@Override public ClientService.BlockingInterface getClient(ServerName sn) throws IOException { return serverName.equals(sn) ? this.localHostClient : super.getClient(sn); }
@BeforeClass public static void setUp() throws Exception { UTIL.startMiniCluster(1); try (Table table = UTIL.createTable(TABLE_NAME, CF)) { for (int i = 0; i < COUNT; i++) { table.put(new Put(Bytes.toBytes(i)).addColumn(CF, CQ, Bytes.toBytes(i))); } } HRI = UTIL.getAdmin().getTableRegions(TABLE_NAME).get(0); STUB = ((ConnectionImplementation) UTIL.getConnection()) .getClient(UTIL.getHBaseCluster().getRegionServer(0).getServerName()); }
Mockito.when(c.getClient(Mockito.any())). thenReturn(client);
@BeforeClass public static void setUp() throws Exception { UTIL.startMiniCluster(1); try (Table table = UTIL.createTable(TABLE_NAME, CF)) { for (int i = 0; i < COUNT; i++) { table.put(new Put(Bytes.toBytes(i)).addColumn(CF, CQ, Bytes.toBytes(i))); } } HRI = UTIL.getAdmin().getTableRegions(TABLE_NAME).get(0); STUB = ((ConnectionImplementation) UTIL.getConnection()) .getClient(UTIL.getHBaseCluster().getRegionServer(0).getServerName()); }
@Test(expected = UnknownHostException.class) public void testGetClientBadHostname() throws Exception { // verify that we can get an instance with the cluster hostname ServerName rs = testUtil.getHBaseCluster().getRegionServer(0).getServerName(); try { conn.getClient(rs); } catch (UnknownHostException uhe) { fail("Obtaining client to the cluster regionserver should have succeeded"); } // test that we fail to get a client to an unresolvable hostname, which // means it won't be cached ServerName badHost = ServerName.valueOf("unknownhost.invalid:" + HConstants.DEFAULT_REGIONSERVER_PORT, System.currentTimeMillis()); conn.getAdmin(badHost); fail("Obtaining client to unresolvable hostname should have failed"); } }
@Override public ClientService.BlockingInterface getClient(ServerName sn) throws IOException { return serverName.equals(sn) ? this.localHostClient : super.getClient(sn); }
hci.getClient(sn); // will throw an exception: RegionServerStoppedException
@Override public ClientService.BlockingInterface getClient(ServerName sn) throws IOException { return serverName.equals(sn) ? this.localHostClient : super.getClient(sn); }
@BeforeClass public static void setUp() throws Exception { UTIL.startMiniCluster(1); try (Table table = UTIL.createTable(TABLE_NAME, CF)) { for (int i = 0; i < COUNT; i++) { table.put(new Put(Bytes.toBytes(i)).addColumn(CF, CQ, Bytes.toBytes(i))); } } HRI = UTIL.getAdmin().getTableRegions(TABLE_NAME).get(0); STUB = ((ConnectionImplementation) UTIL.getConnection()) .getClient(UTIL.getHBaseCluster().getRegionServer(0).getServerName()); }
Mockito.when(c.getClient(Mockito.any())). thenReturn(client);
@BeforeClass public static void setUp() throws Exception { UTIL.startMiniCluster(1); try (Table table = UTIL.createTable(TABLE_NAME, CF)) { for (int i = 0; i < COUNT; i++) { table.put(new Put(Bytes.toBytes(i)).addColumn(CF, CQ, Bytes.toBytes(i))); } } HRI = UTIL.getAdmin().getTableRegions(TABLE_NAME).get(0); STUB = ((ConnectionImplementation) UTIL.getConnection()) .getClient(UTIL.getHBaseCluster().getRegionServer(0).getServerName()); }
@Test(expected = UnknownHostException.class) public void testGetClientBadHostname() throws Exception { // verify that we can get an instance with the cluster hostname ServerName rs = testUtil.getHBaseCluster().getRegionServer(0).getServerName(); try { conn.getClient(rs); } catch (UnknownHostException uhe) { fail("Obtaining client to the cluster regionserver should have succeeded"); } // test that we fail to get a client to an unresolvable hostname, which // means it won't be cached ServerName badHost = ServerName.valueOf("unknownhost.invalid:" + HConstants.DEFAULT_REGIONSERVER_PORT, System.currentTimeMillis()); conn.getAdmin(badHost); fail("Obtaining client to unresolvable hostname should have failed"); } }
hci.getClient(sn); // will throw an exception: RegionServerStoppedException