use of com.alipay.sofa.jraft.rhea.cmd.store.GetRequest in project sofa-jraft by sofastack.
the class DefaultRheaKVStore method internalGet.
private void internalGet(final byte[] key, final boolean readOnlySafe, final CompletableFuture<byte[]> future, final int retriesLeft, final Errors lastCause, final boolean requireLeader) {
final Region region = this.pdClient.findRegionByKey(key, ErrorsHelper.isInvalidEpoch(lastCause));
final RegionEngine regionEngine = getRegionEngine(region.getId(), requireLeader);
// require leader on retry
final RetryRunner retryRunner = retryCause -> internalGet(key, readOnlySafe, future, retriesLeft - 1, retryCause, true);
final FailoverClosure<byte[]> closure = new FailoverClosureImpl<>(future, retriesLeft, retryRunner);
if (regionEngine != null) {
if (ensureOnValidEpoch(region, regionEngine, closure)) {
getRawKVStore(regionEngine).get(key, readOnlySafe, closure);
}
} else {
final GetRequest request = new GetRequest();
request.setKey(key);
request.setReadOnlySafe(readOnlySafe);
request.setRegionId(region.getId());
request.setRegionEpoch(region.getRegionEpoch());
this.rheaKVRpcService.callAsyncWithRpc(request, closure, lastCause, requireLeader);
}
}
Aggregations