use of io.dingodb.store.row.cmd.store.GetAndPutRequest in project dingo by dingodb.
the class DefaultDingoRowStore method internalGetAndPut.
private void internalGetAndPut(final byte[] key, final byte[] value, final CompletableFuture<byte[]> future, final int retriesLeft, final Errors lastCause) {
final Region region = this.pdClient.findRegionByKey(key, ErrorsHelper.isInvalidEpoch(lastCause));
final RegionEngine regionEngine = getRegionEngine(region.getId(), true);
final RetryRunner retryRunner = retryCause -> internalGetAndPut(key, value, future, retriesLeft - 1, retryCause);
final FailoverClosure<byte[]> closure = new FailoverClosureImpl<>(future, retriesLeft, retryRunner);
if (regionEngine != null) {
if (ensureOnValidEpoch(region, regionEngine, closure)) {
getRawKVStore(regionEngine).getAndPut(key, value, closure);
}
} else {
final GetAndPutRequest request = new GetAndPutRequest();
request.setKey(key);
request.setValue(value);
request.setRegionId(region.getId());
request.setRegionEpoch(region.getRegionEpoch());
this.dingoRowStoreRpcService.callAsyncWithRpc(request, closure, lastCause);
}
}
Aggregations