use of org.tikv.kvproto.Kvrpcpb.SplitRegionRequest in project client-java by tikv.
the class RegionStoreClient method splitRegion.
/**
* Send SplitRegion request to tikv split a region at splitKey. splitKey must between current
* region's start key and end key.
*
* @param splitKeys is the split points for a specific region.
* @return a split region info.
*/
public List<Metapb.Region> splitRegion(Iterable<ByteString> splitKeys) {
Supplier<SplitRegionRequest> request = () -> SplitRegionRequest.newBuilder().setContext(makeContext(storeType, SlowLogEmptyImpl.INSTANCE)).addAllSplitKeys(splitKeys).setIsRawKv(conf.isRawKVMode()).build();
KVErrorHandler<SplitRegionResponse> handler = new KVErrorHandler<>(regionManager, this, null, resp -> resp.hasRegionError() ? resp.getRegionError() : null, resp -> null, resolveLockResult -> null, 0L, false);
SplitRegionResponse resp = callWithRetry(ConcreteBackOffer.newGetBackOff(pdClient.getClusterId()), TikvGrpc.getSplitRegionMethod(), request, handler);
if (resp == null) {
this.regionManager.onRequestFail(region);
throw new TiClientInternalException("SplitRegion Response failed without a cause");
}
if (resp.hasRegionError()) {
throw new TiClientInternalException(String.format("failed to split region %d because %s", region.getId(), resp.getRegionError().toString()));
}
return resp.getRegionsList();
}
use of org.tikv.kvproto.Kvrpcpb.SplitRegionRequest in project tispark by pingcap.
the class RegionStoreClient method splitRegion.
/**
* Send SplitRegion request to tikv split a region at splitKey. splitKey must between current
* region's start key and end key.
*
* @param splitKeys is the split points for a specific region.
* @return a split region info.
*/
public List<TiRegion> splitRegion(Iterable<ByteString> splitKeys) {
Supplier<SplitRegionRequest> request = () -> SplitRegionRequest.newBuilder().setContext(region.getContext()).addAllSplitKeys(splitKeys).build();
KVErrorHandler<SplitRegionResponse> handler = new KVErrorHandler<>(regionManager, this, null, resp -> resp.hasRegionError() ? resp.getRegionError() : null, resp -> null, resolveLockResult -> null, 0L, false);
SplitRegionResponse resp = callWithRetry(ConcreteBackOffer.newGetBackOff(), TikvGrpc.getSplitRegionMethod(), request, handler);
if (resp == null) {
this.regionManager.onRequestFail(region);
throw new TiClientInternalException("SplitRegion Response failed without a cause");
}
if (resp.hasRegionError()) {
throw new TiClientInternalException(String.format("failed to split region %d because %s", region.getId(), resp.getRegionError().toString()));
}
return resp.getRegionsList().stream().map(region -> new TiRegion(region, null, conf.getIsolationLevel(), conf.getCommandPriority())).collect(Collectors.toList());
}
Aggregations