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;
}
Aggregations