use of io.dingodb.store.row.client.failover.FailoverClosure in project dingo by dingodb.
the class MetadataRpcClient method internalGetClusterInfo.
private void internalGetClusterInfo(final long clusterId, final CompletableFuture<Cluster> future, final int retriesLeft, final Errors lastCause) {
final RetryRunner retryRunner = retryCause -> internalGetClusterInfo(clusterId, future, retriesLeft - 1, retryCause);
final FailoverClosure<Cluster> closure = new FailoverClosureImpl<>(future, retriesLeft, retryRunner);
final GetClusterInfoRequest request = new GetClusterInfoRequest();
request.setClusterId(clusterId);
this.pdRpcService.callPdServerWithRpc(request, closure, lastCause);
}
use of io.dingodb.store.row.client.failover.FailoverClosure in project dingo by dingodb.
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 io.dingodb.store.row.client.failover.FailoverClosure in project dingo by dingodb.
the class MetadataRpcClient method internalCreateRegionId.
private void internalCreateRegionId(final long clusterId, final Endpoint endpoint, final CompletableFuture<Long> future, final int retriesLeft, final Errors lastCause) {
final RetryRunner retryRunner = retryCause -> internalCreateRegionId(clusterId, endpoint, future, retriesLeft - 1, retryCause);
final FailoverClosure<Long> closure = new FailoverClosureImpl<>(future, retriesLeft, retryRunner);
final CreateRegionIdRequest request = new CreateRegionIdRequest();
request.setClusterId(clusterId);
request.setEndpoint(endpoint);
this.pdRpcService.callPdServerWithRpc(request, closure, lastCause);
}
use of io.dingodb.store.row.client.failover.FailoverClosure in project dingo by dingodb.
the class DefaultDingoRowStore 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.dingoRowStoreRpcService.callAsyncWithRpc(request, closure, lastCause, requireLeader);
}
}
use of io.dingodb.store.row.client.failover.FailoverClosure in project dingo by dingodb.
the class DefaultDingoRowStore method internalRegionScan.
private void internalRegionScan(final Region region, final byte[] subStartKey, final byte[] subEndKey, final boolean reverse, final boolean readOnlySafe, final boolean returnValue, final CompletableFuture<List<KVEntry>> future, final int retriesLeft, final Errors lastCause, final boolean requireLeader) {
final RegionEngine regionEngine = getRegionEngine(region.getId(), requireLeader);
// require leader on retry
final RetryRunner retryRunner = retryCause -> internalRegionScan(region, subStartKey, subEndKey, reverse, readOnlySafe, returnValue, future, retriesLeft - 1, retryCause, true);
final FailoverClosure<List<KVEntry>> closure = new FailoverClosureImpl<>(future, false, retriesLeft, retryRunner);
if (regionEngine != null) {
if (ensureOnValidEpoch(region, regionEngine, closure)) {
final RawKVStore rawKVStore = getRawKVStore(regionEngine);
if (reverse) {
if (this.kvDispatcher == null) {
rawKVStore.reverseScan(subStartKey, subEndKey, readOnlySafe, returnValue, closure);
} else {
this.kvDispatcher.execute(() -> rawKVStore.reverseScan(subStartKey, subEndKey, readOnlySafe, returnValue, closure));
}
} else {
if (this.kvDispatcher == null) {
rawKVStore.scan(subStartKey, subEndKey, readOnlySafe, returnValue, closure);
} else {
this.kvDispatcher.execute(() -> rawKVStore.scan(subStartKey, subEndKey, readOnlySafe, returnValue, closure));
}
}
}
} else {
final ScanRequest request = new ScanRequest();
request.setStartKey(subStartKey);
request.setEndKey(subEndKey);
request.setReadOnlySafe(readOnlySafe);
request.setReturnValue(returnValue);
request.setRegionId(region.getId());
request.setRegionEpoch(region.getRegionEpoch());
request.setReverse(reverse);
this.dingoRowStoreRpcService.callAsyncWithRpc(request, closure, lastCause, requireLeader);
}
}
Aggregations