Search in sources :

Example 1 with ReportRegionStateTransitionRequest

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

the class HRegionServer method reportRegionStateTransition.

@Override
public boolean reportRegionStateTransition(final RegionStateTransitionContext context) {
    TransitionCode code = context.getCode();
    long openSeqNum = context.getOpenSeqNum();
    long masterSystemTime = context.getMasterSystemTime();
    HRegionInfo[] hris = context.getHris();
    if (TEST_SKIP_REPORTING_TRANSITION) {
        // to handle the region transition report at all.
        if (code == TransitionCode.OPENED) {
            Preconditions.checkArgument(hris != null && hris.length == 1);
            if (hris[0].isMetaRegion()) {
                try {
                    MetaTableLocator.setMetaLocation(getZooKeeper(), serverName, hris[0].getReplicaId(), State.OPEN);
                } catch (KeeperException e) {
                    LOG.info("Failed to update meta location", e);
                    return false;
                }
            } else {
                try {
                    MetaTableAccessor.updateRegionLocation(clusterConnection, hris[0], serverName, openSeqNum, masterSystemTime);
                } catch (IOException e) {
                    LOG.info("Failed to update meta", e);
                    return false;
                }
            }
        }
        return true;
    }
    ReportRegionStateTransitionRequest.Builder builder = ReportRegionStateTransitionRequest.newBuilder();
    builder.setServer(ProtobufUtil.toServerName(serverName));
    RegionStateTransition.Builder transition = builder.addTransitionBuilder();
    transition.setTransitionCode(code);
    if (code == TransitionCode.OPENED && openSeqNum >= 0) {
        transition.setOpenSeqNum(openSeqNum);
    }
    for (HRegionInfo hri : hris) {
        transition.addRegionInfo(HRegionInfo.convert(hri));
    }
    ReportRegionStateTransitionRequest request = builder.build();
    while (keepLooping()) {
        RegionServerStatusService.BlockingInterface rss = rssStub;
        try {
            if (rss == null) {
                createRegionServerStatusStub();
                continue;
            }
            ReportRegionStateTransitionResponse response = rss.reportRegionStateTransition(null, request);
            if (response.hasErrorMessage()) {
                LOG.info("Failed to transition " + hris[0] + " to " + code + ": " + response.getErrorMessage());
                return false;
            }
            return true;
        } catch (ServiceException se) {
            IOException ioe = ProtobufUtil.getRemoteException(se);
            LOG.info("Failed to report region transition, will retry", ioe);
            if (rssStub == rss) {
                rssStub = null;
            }
        }
    }
    return false;
}
Also used : InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) RegionStateTransition(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition) ReportRegionStateTransitionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionResponse) HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) TransitionCode(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) ReportRegionStateTransitionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionRequest) RegionServerStatusService(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerStatusService) KeeperException(org.apache.zookeeper.KeeperException)

Aggregations

IOException (java.io.IOException)1 InterruptedIOException (java.io.InterruptedIOException)1 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)1 ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)1 RegionServerStatusService (org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerStatusService)1 RegionStateTransition (org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition)1 TransitionCode (org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode)1 ReportRegionStateTransitionRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionRequest)1 ReportRegionStateTransitionResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionResponse)1 KeeperException (org.apache.zookeeper.KeeperException)1