use of com.alipay.sofa.jraft.rhea.client.failover.impl.FailoverClosureImpl in project sofa-jraft by sofastack.
the class MetadataRpcClient method internalGetOrCreateStoreId.
private void internalGetOrCreateStoreId(final long clusterId, final Endpoint endpoint, final CompletableFuture<Long> future, final int retriesLeft, final Errors lastCause) {
final RetryRunner retryRunner = retryCause -> internalGetOrCreateStoreId(clusterId, endpoint, future, retriesLeft - 1, retryCause);
final FailoverClosure<Long> closure = new FailoverClosureImpl<>(future, retriesLeft, retryRunner);
final GetStoreIdRequest request = new GetStoreIdRequest();
request.setClusterId(clusterId);
request.setEndpoint(endpoint);
this.pdRpcService.callPdServerWithRpc(request, closure, lastCause);
}
use of com.alipay.sofa.jraft.rhea.client.failover.impl.FailoverClosureImpl in project sofa-jraft by sofastack.
the class MetadataRpcClient method internalUpdateStoreInfo.
private void internalUpdateStoreInfo(final long clusterId, final Store store, final CompletableFuture<Store> future, final int retriesLeft, final Errors lastCause) {
final RetryRunner retryRunner = retryCause -> internalUpdateStoreInfo(clusterId, store, future, retriesLeft - 1, retryCause);
final FailoverClosure<Store> closure = new FailoverClosureImpl<>(future, retriesLeft, retryRunner);
final SetStoreInfoRequest request = new SetStoreInfoRequest();
request.setClusterId(clusterId);
request.setStore(store);
this.pdRpcService.callPdServerWithRpc(request, closure, lastCause);
}
use of com.alipay.sofa.jraft.rhea.client.failover.impl.FailoverClosureImpl in project sofa-jraft by sofastack.
the class MetadataRpcClient method internalGetStoreInfo.
private void internalGetStoreInfo(final long clusterId, final Endpoint selfEndpoint, final CompletableFuture<Store> future, final int retriesLeft, final Errors lastCause) {
final RetryRunner retryRunner = retryCause -> internalGetStoreInfo(clusterId, selfEndpoint, future, retriesLeft - 1, retryCause);
final FailoverClosure<Store> closure = new FailoverClosureImpl<>(future, retriesLeft, retryRunner);
final GetStoreInfoRequest request = new GetStoreInfoRequest();
request.setClusterId(clusterId);
request.setEndpoint(selfEndpoint);
this.pdRpcService.callPdServerWithRpc(request, closure, lastCause);
}
use of com.alipay.sofa.jraft.rhea.client.failover.impl.FailoverClosureImpl in project sofa-jraft by sofastack.
the class DefaultRheaKVStore method internalTryLockWith.
private void internalTryLockWith(final byte[] key, final boolean keepLease, 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 -> internalTryLockWith(key, keepLease, 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).tryLockWith(key, region.getStartKey(), keepLease, acquirer, closure);
}
} else {
final KeyLockRequest request = new KeyLockRequest();
request.setKey(key);
request.setKeepLease(keepLease);
request.setAcquirer(acquirer);
request.setRegionId(region.getId());
request.setRegionEpoch(region.getRegionEpoch());
this.rheaKVRpcService.callAsyncWithRpc(request, closure, lastCause);
}
}
use of com.alipay.sofa.jraft.rhea.client.failover.impl.FailoverClosureImpl in project sofa-jraft by sofastack.
the class DefaultRheaKVStore method internalCompareAndPut.
private void internalCompareAndPut(final byte[] key, final byte[] expect, final byte[] update, final CompletableFuture<Boolean> 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 -> internalCompareAndPut(key, expect, update, future, retriesLeft - 1, retryCause);
final FailoverClosure<Boolean> closure = new FailoverClosureImpl<>(future, retriesLeft, retryRunner);
if (regionEngine != null) {
if (ensureOnValidEpoch(region, regionEngine, closure)) {
getRawKVStore(regionEngine).compareAndPut(key, expect, update, closure);
}
} else {
final CompareAndPutRequest request = new CompareAndPutRequest();
request.setKey(key);
request.setExpect(expect);
request.setUpdate(update);
request.setRegionId(region.getId());
request.setRegionEpoch(region.getRegionEpoch());
this.rheaKVRpcService.callAsyncWithRpc(request, closure, lastCause);
}
}
Aggregations