Search in sources :

Example 1 with RangeSplitRequest

use of io.dingodb.store.row.cmd.store.RangeSplitRequest in project dingo by dingodb.

the class DefaultDingoRowStoreCliService method rangeSplit.

@Override
public Status rangeSplit(final String regionId, final String 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);
    }
}
Also used : Status(io.dingodb.raft.Status) BaseResponse(io.dingodb.store.row.cmd.store.BaseResponse) RangeSplitRequest(io.dingodb.store.row.cmd.store.RangeSplitRequest) PeerId(io.dingodb.raft.entity.PeerId)

Aggregations

Status (io.dingodb.raft.Status)1 PeerId (io.dingodb.raft.entity.PeerId)1 BaseResponse (io.dingodb.store.row.cmd.store.BaseResponse)1 RangeSplitRequest (io.dingodb.store.row.cmd.store.RangeSplitRequest)1