Search in sources :

Example 1 with ListRSGroupInfosResponse

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());
}
Also used : ListRSGroupInfosResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.ListRSGroupInfosResponse) HashMap(java.util.HashMap) IOException(java.io.IOException) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor)

Example 2 with ListRSGroupInfosResponse

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();
}
Also used : ListRSGroupInfosResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.ListRSGroupInfosResponse) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) RSGroupInfo(org.apache.hadoop.hbase.rsgroup.RSGroupInfo) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ByteString(org.apache.hbase.thirdparty.com.google.protobuf.ByteString) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor)

Aggregations

IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)2 ListRSGroupInfosResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.ListRSGroupInfosResponse)2 ArrayList (java.util.ArrayList)1 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)1 RSGroupInfo (org.apache.hadoop.hbase.rsgroup.RSGroupInfo)1 ByteString (org.apache.hbase.thirdparty.com.google.protobuf.ByteString)1 ServiceException (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException)1