use of org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.ListRSGroupInfosResponse in project hbase by apache.
the class RSGroupAdminServiceImpl method listRSGroupInfos.
@Override
public void listRSGroupInfos(RpcController controller, ListRSGroupInfosRequest request, RpcCallback<ListRSGroupInfosResponse> done) {
ListRSGroupInfosResponse.Builder builder = ListRSGroupInfosResponse.newBuilder();
LOG.info(master.getClientIdAuditPrefix() + " list rsgroup");
try {
if (master.getMasterCoprocessorHost() != null) {
master.getMasterCoprocessorHost().preListRSGroups();
}
List<RSGroupInfo> rsGroupInfos = rsGroupInfoManager.listRSGroups().stream().map(RSGroupInfo::new).collect(Collectors.toList());
Map<String, RSGroupInfo> name2Info = new HashMap<>();
for (RSGroupInfo rsGroupInfo : rsGroupInfos) {
name2Info.put(rsGroupInfo.getName(), rsGroupInfo);
}
for (TableDescriptor td : master.getTableDescriptors().getAll().values()) {
String groupName = td.getRegionServerGroup().orElse(RSGroupInfo.DEFAULT_GROUP);
RSGroupInfo rsGroupInfo = name2Info.get(groupName);
if (rsGroupInfo != null) {
rsGroupInfo.addTable(td.getTableName());
}
}
for (RSGroupInfo rsGroupInfo : rsGroupInfos) {
// TODO: this can be done at once outside this loop, do not need to scan all every time.
builder.addRSGroupInfo(ProtobufUtil.toProtoGroupInfo(rsGroupInfo));
}
if (master.getMasterCoprocessorHost() != null) {
master.getMasterCoprocessorHost().postListRSGroups();
}
} catch (IOException e) {
CoprocessorRpcUtils.setControllerException(controller, e);
}
done.run(builder.build());
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.ListRSGroupInfosResponse in project hbase by apache.
the class MasterRpcServices method listRSGroupInfos.
@Override
public ListRSGroupInfosResponse listRSGroupInfos(RpcController controller, ListRSGroupInfosRequest request) throws ServiceException {
ListRSGroupInfosResponse.Builder builder = ListRSGroupInfosResponse.newBuilder();
LOG.info(server.getClientIdAuditPrefix() + " list rsgroup");
try {
if (server.getMasterCoprocessorHost() != null) {
server.getMasterCoprocessorHost().preListRSGroups();
}
List<RSGroupInfo> rsGroupInfos = server.getRSGroupInfoManager().listRSGroups().stream().map(RSGroupInfo::new).collect(Collectors.toList());
Map<String, RSGroupInfo> name2Info = new HashMap<>();
List<TableDescriptor> needToFill = new ArrayList<>(server.getTableDescriptors().getAll().values());
for (RSGroupInfo rsGroupInfo : rsGroupInfos) {
name2Info.put(rsGroupInfo.getName(), rsGroupInfo);
for (TableDescriptor td : server.getTableDescriptors().getAll().values()) {
if (rsGroupInfo.containsTable(td.getTableName())) {
needToFill.remove(td);
}
}
}
for (TableDescriptor td : needToFill) {
String groupName = td.getRegionServerGroup().orElse(RSGroupInfo.DEFAULT_GROUP);
RSGroupInfo rsGroupInfo = name2Info.get(groupName);
if (rsGroupInfo != null) {
rsGroupInfo.addTable(td.getTableName());
}
}
for (RSGroupInfo rsGroupInfo : rsGroupInfos) {
// TODO: this can be done at once outside this loop, do not need to scan all every time.
builder.addRSGroupInfo(ProtobufUtil.toProtoGroupInfo(rsGroupInfo));
}
if (server.getMasterCoprocessorHost() != null) {
server.getMasterCoprocessorHost().postListRSGroups();
}
} catch (IOException e) {
throw new ServiceException(e);
}
return builder.build();
}
Aggregations