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;
}
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;
}
Aggregations