use of io.dingodb.store.row.client.failover.RetryRunner in project dingo by dingodb.
the class DefaultDingoRowStore method internalExecute.
private void internalExecute(final String regionId, final NodeExecutor executor, final CompletableFuture<Boolean> future, final int retriesLeft, final Errors lastCause) {
final Region region = this.pdClient.getRegionById(regionId);
final RegionEngine regionEngine = getRegionEngine(region.getId(), true);
final RetryRunner retryRunner = retryCause -> internalExecute(regionId, executor, future, retriesLeft - 1, retryCause);
final FailoverClosure<Boolean> closure = new FailoverClosureImpl<>(future, retriesLeft, retryRunner);
if (regionEngine != null) {
if (ensureOnValidEpoch(region, regionEngine, closure)) {
getRawKVStore(regionEngine).execute(executor, true, closure);
}
} else {
final NodeExecuteRequest request = new NodeExecuteRequest();
request.setNodeExecutor(executor);
request.setRegionId(region.getId());
request.setRegionEpoch(region.getRegionEpoch());
this.dingoRowStoreRpcService.callAsyncWithRpc(request, closure, lastCause);
}
}
use of io.dingodb.store.row.client.failover.RetryRunner in project dingo by dingodb.
the class DefaultDingoRowStore method internalReleaseLockWith.
private void internalReleaseLockWith(final byte[] key, final DistributedLock.Acquirer acquirer, final CompletableFuture<DistributedLock.Owner> 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 -> internalReleaseLockWith(key, acquirer, future, retriesLeft - 1, retryCause);
final FailoverClosure<DistributedLock.Owner> closure = new FailoverClosureImpl<>(future, retriesLeft, retryRunner);
if (regionEngine != null) {
if (ensureOnValidEpoch(region, regionEngine, closure)) {
getRawKVStore(regionEngine).releaseLockWith(key, acquirer, closure);
}
} else {
final KeyUnlockRequest request = new KeyUnlockRequest();
request.setKey(key);
request.setAcquirer(acquirer);
request.setRegionId(region.getId());
request.setRegionEpoch(region.getRegionEpoch());
this.dingoRowStoreRpcService.callAsyncWithRpc(request, closure, lastCause);
}
}
use of io.dingodb.store.row.client.failover.RetryRunner in project dingo by dingodb.
the class DefaultDingoRowStore method internalGetSequence.
private void internalGetSequence(final byte[] seqKey, final int step, final CompletableFuture<Sequence> future, final int retriesLeft, final Errors lastCause) {
final Region region = this.pdClient.findRegionByKey(seqKey, ErrorsHelper.isInvalidEpoch(lastCause));
final RegionEngine regionEngine = getRegionEngine(region.getId(), true);
final RetryRunner retryRunner = retryCause -> internalGetSequence(seqKey, step, future, retriesLeft - 1, retryCause);
final FailoverClosure<Sequence> closure = new FailoverClosureImpl<>(future, retriesLeft, retryRunner);
if (regionEngine != null) {
if (ensureOnValidEpoch(region, regionEngine, closure)) {
getRawKVStore(regionEngine).getSequence(seqKey, step, closure);
}
} else {
final GetSequenceRequest request = new GetSequenceRequest();
request.setSeqKey(seqKey);
request.setStep(step);
request.setRegionId(region.getId());
request.setRegionEpoch(region.getRegionEpoch());
this.dingoRowStoreRpcService.callAsyncWithRpc(request, closure, lastCause);
}
}
use of io.dingodb.store.row.client.failover.RetryRunner in project dingo by dingodb.
the class DefaultDingoRowStore method internalResetSequence.
private void internalResetSequence(final byte[] seqKey, final CompletableFuture<Boolean> future, final int retriesLeft, final Errors lastCause) {
final Region region = this.pdClient.findRegionByKey(seqKey, ErrorsHelper.isInvalidEpoch(lastCause));
final RegionEngine regionEngine = getRegionEngine(region.getId(), true);
final RetryRunner retryRunner = retryCause -> internalResetSequence(seqKey, future, retriesLeft - 1, retryCause);
final FailoverClosure<Boolean> closure = new FailoverClosureImpl<>(future, retriesLeft, retryRunner);
if (regionEngine != null) {
if (ensureOnValidEpoch(region, regionEngine, closure)) {
getRawKVStore(regionEngine).resetSequence(seqKey, closure);
}
} else {
final ResetSequenceRequest request = new ResetSequenceRequest();
request.setSeqKey(seqKey);
request.setRegionId(region.getId());
request.setRegionEpoch(region.getRegionEpoch());
this.dingoRowStoreRpcService.callAsyncWithRpc(request, closure, lastCause);
}
}
use of io.dingodb.store.row.client.failover.RetryRunner in project dingo by dingodb.
the class DefaultDingoRowStore method internalRegionCompareAndPutAll.
private void internalRegionCompareAndPutAll(final Region region, final List<CASEntry> subEntries, final CompletableFuture<Boolean> future, final int retriesLeft, final Errors lastCause) {
final RegionEngine regionEngine = getRegionEngine(region.getId(), true);
final RetryRunner retryRunner = retryCause -> internalRegionCompareAndPutAll(region, subEntries, future, retriesLeft - 1, retryCause);
final FailoverClosure<Boolean> closure = new FailoverClosureImpl<>(future, false, retriesLeft, retryRunner);
if (regionEngine != null) {
if (ensureOnValidEpoch(region, regionEngine, closure)) {
final RawKVStore rawKVStore = getRawKVStore(regionEngine);
if (this.kvDispatcher == null) {
rawKVStore.compareAndPutAll(subEntries, closure);
} else {
this.kvDispatcher.execute(() -> rawKVStore.compareAndPutAll(subEntries, closure));
}
}
} else {
final CASAllRequest request = new CASAllRequest();
request.setCasEntries(subEntries);
request.setRegionId(region.getId());
request.setRegionEpoch(region.getRegionEpoch());
this.dingoRowStoreRpcService.callAsyncWithRpc(request, closure, lastCause);
}
}
Aggregations