Search in sources :

Example 1 with ServerInfo

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

the class DistributedHBaseCluster method getServerHoldingRegion.

@Override
public ServerName getServerHoldingRegion(TableName tn, byte[] regionName) throws IOException {
    HRegionLocation regionLoc = null;
    try (RegionLocator locator = connection.getRegionLocator(tn)) {
        regionLoc = locator.getRegionLocation(regionName, true);
    }
    if (regionLoc == null) {
        LOG.warn("Cannot find region server holding region " + Bytes.toString(regionName) + ", start key [" + Bytes.toString(HRegionInfo.getStartKey(regionName)) + "]");
        return null;
    }
    AdminProtos.AdminService.BlockingInterface client = ((ClusterConnection) this.connection).getAdmin(regionLoc.getServerName());
    ServerInfo info = ProtobufUtil.getServerInfo(null, client);
    return ProtobufUtil.toServerName(info.getServerName());
}
Also used : RegionLocator(org.apache.hadoop.hbase.client.RegionLocator) ClusterConnection(org.apache.hadoop.hbase.client.ClusterConnection) ServerInfo(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ServerInfo)

Example 2 with ServerInfo

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

the class ServerManager method isServerReachable.

/**
   * Check if a region server is reachable and has the expected start code
   */
public boolean isServerReachable(ServerName server) {
    if (server == null)
        throw new NullPointerException("Passed server is null");
    RetryCounter retryCounter = pingRetryCounterFactory.create();
    while (retryCounter.shouldRetry()) {
        try {
            HBaseRpcController controller = newRpcController();
            AdminService.BlockingInterface admin = getRsAdmin(server);
            if (admin != null) {
                ServerInfo info = ProtobufUtil.getServerInfo(controller, admin);
                return info != null && info.hasServerName() && server.getStartcode() == info.getServerName().getStartCode();
            }
        } catch (IOException ioe) {
            LOG.debug("Couldn't reach " + server + ", try=" + retryCounter.getAttemptTimes() + " of " + retryCounter.getMaxAttempts(), ioe);
            try {
                retryCounter.sleepUntilNextRetry();
            } catch (InterruptedException ie) {
                Thread.currentThread().interrupt();
            }
        }
    }
    return false;
}
Also used : HBaseRpcController(org.apache.hadoop.hbase.ipc.HBaseRpcController) AdminService(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService) RetryCounter(org.apache.hadoop.hbase.util.RetryCounter) ServerInfo(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ServerInfo) IOException(java.io.IOException)

Aggregations

ServerInfo (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ServerInfo)2 IOException (java.io.IOException)1 ClusterConnection (org.apache.hadoop.hbase.client.ClusterConnection)1 RegionLocator (org.apache.hadoop.hbase.client.RegionLocator)1 HBaseRpcController (org.apache.hadoop.hbase.ipc.HBaseRpcController)1 AdminService (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService)1 RetryCounter (org.apache.hadoop.hbase.util.RetryCounter)1