use of org.apache.hadoop.hbase.regionserver.RSRpcServices in project hbase by apache.
the class TestShortCircuitConnection method testShortCircuitConnection.
@Test
@SuppressWarnings("deprecation")
public void testShortCircuitConnection() throws IOException, InterruptedException {
final TableName tableName = TableName.valueOf(name.getMethodName());
HTableDescriptor htd = UTIL.createTableDescriptor(tableName);
HColumnDescriptor hcd = new HColumnDescriptor(Bytes.toBytes("cf"));
htd.addFamily(hcd);
UTIL.createTable(htd, null);
HRegionServer regionServer = UTIL.getRSForFirstRegionInTable(tableName);
ClusterConnection connection = regionServer.getClusterConnection();
Table tableIf = connection.getTable(tableName);
assertTrue(tableIf instanceof HTable);
HTable table = (HTable) tableIf;
assertTrue(table.getConnection() == connection);
AdminService.BlockingInterface admin = connection.getAdmin(regionServer.getServerName());
ClientService.BlockingInterface client = connection.getClient(regionServer.getServerName());
assertTrue(admin instanceof RSRpcServices);
assertTrue(client instanceof RSRpcServices);
ServerName anotherSn = ServerName.valueOf(regionServer.getServerName().getHostAndPort(), EnvironmentEdgeManager.currentTime());
admin = connection.getAdmin(anotherSn);
client = connection.getClient(anotherSn);
assertFalse(admin instanceof RSRpcServices);
assertFalse(client instanceof RSRpcServices);
assertTrue(connection.getAdmin().getConnection() == connection);
}
Aggregations