Search in sources :

Example 1 with UpdateFavoredNodesRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateFavoredNodesRequest in project hbase by apache.

the class ServerManager method sendFavoredNodes.

public void sendFavoredNodes(final ServerName server, Map<HRegionInfo, List<ServerName>> favoredNodes) throws IOException {
    AdminService.BlockingInterface admin = getRsAdmin(server);
    if (admin == null) {
        LOG.warn("Attempting to send favored nodes update rpc to server " + server.toString() + " failed because no RPC connection found to this server");
    } else {
        List<Pair<HRegionInfo, List<ServerName>>> regionUpdateInfos = new ArrayList<>();
        for (Entry<HRegionInfo, List<ServerName>> entry : favoredNodes.entrySet()) {
            regionUpdateInfos.add(new Pair<>(entry.getKey(), entry.getValue()));
        }
        UpdateFavoredNodesRequest request = RequestConverter.buildUpdateFavoredNodesRequest(regionUpdateInfos);
        try {
            admin.updateFavoredNodes(null, request);
        } catch (ServiceException se) {
            throw ProtobufUtil.getRemoteException(se);
        }
    }
}
Also used : HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) UpdateFavoredNodesRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateFavoredNodesRequest) AdminService(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) ServerName(org.apache.hadoop.hbase.ServerName) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) Pair(org.apache.hadoop.hbase.util.Pair)

Example 2 with UpdateFavoredNodesRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateFavoredNodesRequest in project hbase by apache.

the class RSRpcServices method updateFavoredNodes.

@Override
public UpdateFavoredNodesResponse updateFavoredNodes(RpcController controller, UpdateFavoredNodesRequest request) throws ServiceException {
    rpcPreCheck("updateFavoredNodes");
    List<UpdateFavoredNodesRequest.RegionUpdateInfo> openInfoList = request.getUpdateInfoList();
    UpdateFavoredNodesResponse.Builder respBuilder = UpdateFavoredNodesResponse.newBuilder();
    for (UpdateFavoredNodesRequest.RegionUpdateInfo regionUpdateInfo : openInfoList) {
        RegionInfo hri = ProtobufUtil.toRegionInfo(regionUpdateInfo.getRegion());
        if (regionUpdateInfo.getFavoredNodesCount() > 0) {
            server.updateRegionFavoredNodesMapping(hri.getEncodedName(), regionUpdateInfo.getFavoredNodesList());
        }
    }
    respBuilder.setResponse(openInfoList.size());
    return respBuilder.build();
}
Also used : UpdateFavoredNodesRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateFavoredNodesRequest) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) UpdateFavoredNodesResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateFavoredNodesResponse)

Example 3 with UpdateFavoredNodesRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateFavoredNodesRequest in project hbase by apache.

the class RegionPlacementMaintainer method updateAssignmentPlanToRegionServers.

/**
 * Update the assignment plan to all the region servers
 * @param plan
 * @throws IOException
 */
private void updateAssignmentPlanToRegionServers(FavoredNodesPlan plan) throws IOException {
    LOG.info("Start to update the region servers with the new assignment plan");
    // Get the region to region server map
    Map<ServerName, List<RegionInfo>> currentAssignment = this.getRegionAssignmentSnapshot().getRegionServerToRegionMap();
    // track of the failed and succeeded updates
    int succeededNum = 0;
    Map<ServerName, Exception> failedUpdateMap = new HashMap<>();
    for (Map.Entry<ServerName, List<RegionInfo>> entry : currentAssignment.entrySet()) {
        List<Pair<RegionInfo, List<ServerName>>> regionUpdateInfos = new ArrayList<>();
        try {
            // Keep track of the favored updates for the current region server
            FavoredNodesPlan singleServerPlan = null;
            // Find out all the updates for the current region server
            for (RegionInfo region : entry.getValue()) {
                List<ServerName> favoredServerList = plan.getFavoredNodes(region);
                if (favoredServerList != null && favoredServerList.size() == FavoredNodeAssignmentHelper.FAVORED_NODES_NUM) {
                    // Create the single server plan if necessary
                    if (singleServerPlan == null) {
                        singleServerPlan = new FavoredNodesPlan();
                    }
                    // Update the single server update
                    singleServerPlan.updateFavoredNodesMap(region, favoredServerList);
                    regionUpdateInfos.add(new Pair<>(region, favoredServerList));
                }
            }
            if (singleServerPlan != null) {
                // Update the current region server with its updated favored nodes
                AsyncRegionServerAdmin rsAdmin = getConnection().getRegionServerAdmin(entry.getKey());
                UpdateFavoredNodesRequest request = RequestConverter.buildUpdateFavoredNodesRequest(regionUpdateInfos);
                UpdateFavoredNodesResponse updateFavoredNodesResponse = FutureUtils.get(rsAdmin.updateFavoredNodes(request));
                LOG.info("Region server " + FutureUtils.get(rsAdmin.getServerInfo(RequestConverter.buildGetServerInfoRequest())).getServerInfo() + " has updated " + updateFavoredNodesResponse.getResponse() + " / " + singleServerPlan.size() + " regions with the assignment plan");
                succeededNum++;
            }
        } catch (Exception e) {
            failedUpdateMap.put(entry.getKey(), e);
        }
    }
    // log the succeeded updates
    LOG.info("Updated " + succeededNum + " region servers with " + "the new assignment plan");
    // log the failed updates
    int failedNum = failedUpdateMap.size();
    if (failedNum != 0) {
        LOG.error("Failed to update the following + " + failedNum + " region servers with its corresponding favored nodes");
        for (Map.Entry<ServerName, Exception> entry : failedUpdateMap.entrySet()) {
            LOG.error("Failed to update " + entry.getKey().getAddress() + " because of " + entry.getValue().getMessage());
        }
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) FavoredNodesPlan(org.apache.hadoop.hbase.favored.FavoredNodesPlan) IOException(java.io.IOException) ParseException(org.apache.hbase.thirdparty.org.apache.commons.cli.ParseException) UpdateFavoredNodesResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateFavoredNodesResponse) UpdateFavoredNodesRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateFavoredNodesRequest) AsyncRegionServerAdmin(org.apache.hadoop.hbase.client.AsyncRegionServerAdmin) ServerName(org.apache.hadoop.hbase.ServerName) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) Pair(org.apache.hadoop.hbase.util.Pair)

Example 4 with UpdateFavoredNodesRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateFavoredNodesRequest in project hbase by apache.

the class RequestConverter method buildUpdateFavoredNodesRequest.

/**
  * Create a protocol buffer UpdateFavoredNodesRequest to update a list of favorednode mappings
  * @param updateRegionInfos
  * @return a protocol buffer UpdateFavoredNodesRequest
  */
public static UpdateFavoredNodesRequest buildUpdateFavoredNodesRequest(final List<Pair<HRegionInfo, List<ServerName>>> updateRegionInfos) {
    UpdateFavoredNodesRequest.Builder ubuilder = UpdateFavoredNodesRequest.newBuilder();
    if (updateRegionInfos != null && !updateRegionInfos.isEmpty()) {
        RegionUpdateInfo.Builder builder = RegionUpdateInfo.newBuilder();
        for (Pair<HRegionInfo, List<ServerName>> pair : updateRegionInfos) {
            builder.setRegion(HRegionInfo.convert(pair.getFirst()));
            for (ServerName server : pair.getSecond()) {
                builder.addFavoredNodes(ProtobufUtil.toServerName(server));
            }
            ubuilder.addUpdateInfo(builder.build());
            builder.clear();
        }
    }
    return ubuilder.build();
}
Also used : UpdateFavoredNodesRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateFavoredNodesRequest) HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) RegionUpdateInfo(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateFavoredNodesRequest.RegionUpdateInfo) ServerName(org.apache.hadoop.hbase.ServerName) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with UpdateFavoredNodesRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateFavoredNodesRequest in project hbase by apache.

the class RequestConverter method buildUpdateFavoredNodesRequest.

/**
 * Create a protocol buffer UpdateFavoredNodesRequest to update a list of favorednode mappings
 * @param updateRegionInfos a list of favored node mappings
 * @return a protocol buffer UpdateFavoredNodesRequest
 */
public static UpdateFavoredNodesRequest buildUpdateFavoredNodesRequest(final List<Pair<RegionInfo, List<ServerName>>> updateRegionInfos) {
    UpdateFavoredNodesRequest.Builder ubuilder = UpdateFavoredNodesRequest.newBuilder();
    if (updateRegionInfos != null && !updateRegionInfos.isEmpty()) {
        RegionUpdateInfo.Builder builder = RegionUpdateInfo.newBuilder();
        for (Pair<RegionInfo, List<ServerName>> pair : updateRegionInfos) {
            builder.setRegion(ProtobufUtil.toRegionInfo(pair.getFirst()));
            for (ServerName server : pair.getSecond()) {
                builder.addFavoredNodes(ProtobufUtil.toServerName(server));
            }
            ubuilder.addUpdateInfo(builder.build());
            builder.clear();
        }
    }
    return ubuilder.build();
}
Also used : UpdateFavoredNodesRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateFavoredNodesRequest) RegionUpdateInfo(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateFavoredNodesRequest.RegionUpdateInfo) ServerName(org.apache.hadoop.hbase.ServerName) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

UpdateFavoredNodesRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateFavoredNodesRequest)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ServerName (org.apache.hadoop.hbase.ServerName)4 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)3 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)2 RegionUpdateInfo (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateFavoredNodesRequest.RegionUpdateInfo)2 UpdateFavoredNodesResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateFavoredNodesResponse)2 Pair (org.apache.hadoop.hbase.util.Pair)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 AsyncRegionServerAdmin (org.apache.hadoop.hbase.client.AsyncRegionServerAdmin)1 FavoredNodesPlan (org.apache.hadoop.hbase.favored.FavoredNodesPlan)1 ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)1 AdminService (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService)1 ParseException (org.apache.hbase.thirdparty.org.apache.commons.cli.ParseException)1