Search in sources :

Example 1 with ReportRegionStateTransitionResponse

use of org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionResponse in project hbase by apache.

the class AssignmentManager method reportRegionStateTransition.

public ReportRegionStateTransitionResponse reportRegionStateTransition(final ReportRegionStateTransitionRequest req) throws PleaseHoldException {
    ReportRegionStateTransitionResponse.Builder builder = ReportRegionStateTransitionResponse.newBuilder();
    ServerName serverName = ProtobufUtil.toServerName(req.getServer());
    ServerStateNode serverNode = regionStates.getOrCreateServer(serverName);
    // here we have to acquire a read lock instead of a simple exclusive lock. This is because that
    // we should not block other reportRegionStateTransition call from the same region server. This
    // is not only about performance, but also to prevent dead lock. Think of the meta region is
    // also on the same region server and you hold the lock which blocks the
    // reportRegionStateTransition for meta, and since meta is not online, you will block inside the
    // lock protection to wait for meta online...
    serverNode.readLock().lock();
    try {
        // above in submitServerCrash method and HBASE-21508 for more details.
        if (serverNode.isInState(ServerState.ONLINE)) {
            try {
                reportRegionStateTransition(builder, serverName, req.getTransitionList());
            } catch (PleaseHoldException e) {
                LOG.trace("Failed transition ", e);
                throw e;
            } catch (UnsupportedOperationException | IOException e) {
                // TODO: at the moment we have a single error message and the RS will abort
                // if the master says that one of the region transitions failed.
                LOG.warn("Failed transition", e);
                builder.setErrorMessage("Failed transition " + e.getMessage());
            }
        } else {
            LOG.warn("The region server {} is already dead, skip reportRegionStateTransition call", serverName);
            builder.setErrorMessage("You are dead");
        }
    } finally {
        serverNode.readLock().unlock();
    }
    return builder.build();
}
Also used : PleaseHoldException(org.apache.hadoop.hbase.PleaseHoldException) ServerName(org.apache.hadoop.hbase.ServerName) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) IOException(java.io.IOException) ReportRegionStateTransitionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionResponse)

Example 2 with ReportRegionStateTransitionResponse

use of org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionResponse in project hbase by apache.

the class MasterRpcServices method reportRegionStateTransition.

@Override
public ReportRegionStateTransitionResponse reportRegionStateTransition(RpcController c, ReportRegionStateTransitionRequest req) throws ServiceException {
    try {
        master.checkServiceStarted();
        RegionStateTransition rt = req.getTransition(0);
        RegionStates regionStates = master.getAssignmentManager().getRegionStates();
        for (RegionInfo ri : rt.getRegionInfoList()) {
            TableName tableName = ProtobufUtil.toTableName(ri.getTableName());
            if (!(TableName.META_TABLE_NAME.equals(tableName) && regionStates.getRegionState(HRegionInfo.FIRST_META_REGIONINFO) != null) && !master.getAssignmentManager().isFailoverCleanupDone()) {
                // failover cleanup. So no need this check for it
                throw new PleaseHoldException("Master is rebuilding user regions");
            }
        }
        ServerName sn = ProtobufUtil.toServerName(req.getServer());
        String error = master.getAssignmentManager().onRegionTransition(sn, rt);
        ReportRegionStateTransitionResponse.Builder rrtr = ReportRegionStateTransitionResponse.newBuilder();
        if (error != null) {
            rrtr.setErrorMessage(error);
        }
        return rrtr.build();
    } catch (IOException ioe) {
        throw new ServiceException(ioe);
    }
}
Also used : TableName(org.apache.hadoop.hbase.TableName) PleaseHoldException(org.apache.hadoop.hbase.PleaseHoldException) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) ServerName(org.apache.hadoop.hbase.ServerName) RegionInfo(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionInfo) HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) RegionStateTransition(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition) ReportRegionStateTransitionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionResponse)

Example 3 with ReportRegionStateTransitionResponse

use of org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionResponse in project hbase by apache.

the class HRegionServer method reportRegionStateTransition.

@Override
public boolean reportRegionStateTransition(final RegionStateTransitionContext context) {
    if (TEST_SKIP_REPORTING_TRANSITION) {
        return skipReportingTransition(context);
    }
    final ReportRegionStateTransitionRequest request = createReportRegionStateTransitionRequest(context);
    int tries = 0;
    long pauseTime = this.retryPauseTime;
    // HRegionServer does down.
    while (this.asyncClusterConnection != null && !this.asyncClusterConnection.isClosed()) {
        RegionServerStatusService.BlockingInterface rss = rssStub;
        try {
            if (rss == null) {
                createRegionServerStatusStub();
                continue;
            }
            ReportRegionStateTransitionResponse response = rss.reportRegionStateTransition(null, request);
            if (response.hasErrorMessage()) {
                LOG.info("TRANSITION FAILED " + request + ": " + response.getErrorMessage());
                break;
            }
            // know if were successful after an attempt showed in logs as failed.
            if (tries > 0 || LOG.isTraceEnabled()) {
                LOG.info("TRANSITION REPORTED " + request);
            }
            // NOTE: Return mid-method!!!
            return true;
        } catch (ServiceException se) {
            IOException ioe = ProtobufUtil.getRemoteException(se);
            boolean pause = ioe instanceof ServerNotRunningYetException || ioe instanceof PleaseHoldException || ioe instanceof CallQueueTooBigException;
            if (pause) {
                // Do backoff else we flood the Master with requests.
                pauseTime = ConnectionUtils.getPauseTime(this.retryPauseTime, tries);
            } else {
                // Reset.
                pauseTime = this.retryPauseTime;
            }
            LOG.info("Failed report transition " + TextFormat.shortDebugString(request) + "; retry (#" + tries + ")" + (pause ? " after " + pauseTime + "ms delay (Master is coming online...)." : " immediately."), ioe);
            if (pause) {
                Threads.sleep(pauseTime);
            }
            tries++;
            if (rssStub == rss) {
                rssStub = null;
            }
        }
    }
    return false;
}
Also used : ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) PleaseHoldException(org.apache.hadoop.hbase.PleaseHoldException) CallQueueTooBigException(org.apache.hadoop.hbase.CallQueueTooBigException) ReportRegionStateTransitionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionRequest) RegionServerStatusService(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerStatusService) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) ReportRegionStateTransitionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionResponse) ServerNotRunningYetException(org.apache.hadoop.hbase.ipc.ServerNotRunningYetException)

Aggregations

IOException (java.io.IOException)3 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)3 PleaseHoldException (org.apache.hadoop.hbase.PleaseHoldException)3 ReportRegionStateTransitionResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionResponse)3 ServerName (org.apache.hadoop.hbase.ServerName)2 CallQueueTooBigException (org.apache.hadoop.hbase.CallQueueTooBigException)1 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)1 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)1 TableName (org.apache.hadoop.hbase.TableName)1 ServerNotRunningYetException (org.apache.hadoop.hbase.ipc.ServerNotRunningYetException)1 ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)1 RegionInfo (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionInfo)1 RegionServerStatusService (org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerStatusService)1 RegionStateTransition (org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition)1 ReportRegionStateTransitionRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionRequest)1 ServiceException (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException)1