Search in sources :

Example 1 with RSGroupInfoManager

use of org.apache.hadoop.hbase.rsgroup.RSGroupInfoManager in project hbase by apache.

the class TestRSGroupBasedLoadBalancer method getTableName.

private TableName getTableName(ServerName sn) throws IOException {
    TableName tableName = null;
    RSGroupInfoManager gm = getMockedGroupInfoManager();
    RSGroupInfo groupOfServer = null;
    for (RSGroupInfo gInfo : gm.listRSGroups()) {
        if (gInfo.containsServer(sn.getAddress())) {
            groupOfServer = gInfo;
            break;
        }
    }
    for (HTableDescriptor desc : tableDescs) {
        if (gm.getRSGroupOfTable(desc.getTableName()).endsWith(groupOfServer.getName())) {
            tableName = desc.getTableName();
        }
    }
    return tableName;
}
Also used : TableName(org.apache.hadoop.hbase.TableName) RSGroupInfo(org.apache.hadoop.hbase.rsgroup.RSGroupInfo) RSGroupInfoManager(org.apache.hadoop.hbase.rsgroup.RSGroupInfoManager) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Example 2 with RSGroupInfoManager

use of org.apache.hadoop.hbase.rsgroup.RSGroupInfoManager in project hbase by apache.

the class TestRSGroupBasedLoadBalancer method getMockedGroupInfoManager.

private static RSGroupInfoManager getMockedGroupInfoManager() throws IOException {
    RSGroupInfoManager gm = Mockito.mock(RSGroupInfoManager.class);
    Mockito.when(gm.getRSGroup(groups[0])).thenReturn(groupMap.get(groups[0]));
    Mockito.when(gm.getRSGroup(groups[1])).thenReturn(groupMap.get(groups[1]));
    Mockito.when(gm.getRSGroup(groups[2])).thenReturn(groupMap.get(groups[2]));
    Mockito.when(gm.getRSGroup(groups[3])).thenReturn(groupMap.get(groups[3]));
    Mockito.when(gm.listRSGroups()).thenReturn(Lists.newLinkedList(groupMap.values()));
    Mockito.when(gm.isOnline()).thenReturn(true);
    Mockito.when(gm.getRSGroupOfTable(Mockito.any(TableName.class))).thenAnswer(new Answer<String>() {

        @Override
        public String answer(InvocationOnMock invocation) throws Throwable {
            return tableMap.get(invocation.getArguments()[0]);
        }
    });
    return gm;
}
Also used : TableName(org.apache.hadoop.hbase.TableName) InvocationOnMock(org.mockito.invocation.InvocationOnMock) RSGroupInfoManager(org.apache.hadoop.hbase.rsgroup.RSGroupInfoManager)

Aggregations

TableName (org.apache.hadoop.hbase.TableName)2 RSGroupInfoManager (org.apache.hadoop.hbase.rsgroup.RSGroupInfoManager)2 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)1 RSGroupInfo (org.apache.hadoop.hbase.rsgroup.RSGroupInfo)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1