Search in sources :

Example 1 with RSRpcServices

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);
}
Also used : AdminService(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) ClientService(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientService) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) TableName(org.apache.hadoop.hbase.TableName) ServerName(org.apache.hadoop.hbase.ServerName) RSRpcServices(org.apache.hadoop.hbase.regionserver.RSRpcServices) Test(org.junit.Test)

Aggregations

HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)1 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)1 ServerName (org.apache.hadoop.hbase.ServerName)1 TableName (org.apache.hadoop.hbase.TableName)1 HRegionServer (org.apache.hadoop.hbase.regionserver.HRegionServer)1 RSRpcServices (org.apache.hadoop.hbase.regionserver.RSRpcServices)1 AdminService (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService)1 ClientService (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientService)1 Test (org.junit.Test)1