use of com.alipay.sofa.jraft.rhea.cmd.store.RangeSplitRequest in project sofa-jraft by sofastack.
the class DefaultRheaKVCliService method rangeSplit.
@Override
public Status rangeSplit(final long regionId, final long newRegionId, final String groupId, final Configuration conf) {
final PeerId leaderId = new PeerId();
final Status st = this.cliService.getLeader(groupId, conf, leaderId);
if (!st.isOk()) {
throw new IllegalStateException(st.getErrorMsg());
}
final RangeSplitRequest request = new RangeSplitRequest();
request.setRegionId(regionId);
request.setNewRegionId(newRegionId);
try {
final BaseResponse<?> response = (BaseResponse<?>) this.rpcClient.invokeSync(leaderId.getEndpoint(), request, this.opts.getTimeoutMs());
if (response.isSuccess()) {
return Status.OK();
}
return new Status(-1, "Fail to range split on region %d, error: %s", regionId, response);
} catch (final Exception e) {
LOG.error("Fail to range split on exception: {}.", StackTraceUtil.stackTrace(e));
return new Status(-1, "fail to range split on region %d", regionId);
}
}
Aggregations