Search in sources :

Example 6 with Errors

use of io.dingodb.store.row.errors.Errors 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);
    }
}
Also used : Constants(io.dingodb.store.row.util.Constants) CASAllRequest(io.dingodb.store.row.cmd.store.CASAllRequest) LoggerFactory(org.slf4j.LoggerFactory) RouteTable(io.dingodb.raft.RouteTable) ListRetryCallable(io.dingodb.store.row.client.failover.ListRetryCallable) DeleteRangeRequest(io.dingodb.store.row.cmd.store.DeleteRangeRequest) Strings(io.dingodb.store.row.util.Strings) DistributedLock(io.dingodb.store.row.util.concurrent.DistributedLock) PlacementDriverClient(io.dingodb.store.row.client.pd.PlacementDriverClient) BoolFailoverFuture(io.dingodb.store.row.client.failover.impl.BoolFailoverFuture) Map(java.util.Map) RegionEngine(io.dingodb.store.row.RegionEngine) BatchPutRequest(io.dingodb.store.row.cmd.store.BatchPutRequest) ThreadFactory(java.util.concurrent.ThreadFactory) JRaftHelper(io.dingodb.store.row.JRaftHelper) ResetSequenceRequest(io.dingodb.store.row.cmd.store.ResetSequenceRequest) NodeExecutor(io.dingodb.store.row.storage.NodeExecutor) GetRequest(io.dingodb.store.row.cmd.store.GetRequest) Errors(io.dingodb.store.row.errors.Errors) FailoverClosure(io.dingodb.store.row.client.failover.FailoverClosure) FakePlacementDriverClient(io.dingodb.store.row.client.pd.FakePlacementDriverClient) StoreEngineOptions(io.dingodb.store.row.options.StoreEngineOptions) Status(io.dingodb.raft.Status) PutRequest(io.dingodb.store.row.cmd.store.PutRequest) Lists(io.dingodb.store.row.util.Lists) Utils(io.dingodb.raft.util.Utils) MergeRequest(io.dingodb.store.row.cmd.store.MergeRequest) MultiGetRequest(io.dingodb.store.row.cmd.store.MultiGetRequest) StackTraceUtil(io.dingodb.store.row.util.StackTraceUtil) StateListener(io.dingodb.store.row.StateListener) StoreEngine(io.dingodb.store.row.StoreEngine) PlacementDriverOptions(io.dingodb.store.row.options.PlacementDriverOptions) List(java.util.List) DescriberManager(io.dingodb.store.row.DescriberManager) RpcOptions(io.dingodb.store.row.options.RpcOptions) PutIfAbsentRequest(io.dingodb.store.row.cmd.store.PutIfAbsentRequest) KVMetrics(io.dingodb.store.row.metrics.KVMetrics) KVEntry(io.dingodb.store.row.storage.KVEntry) ZipStrategyManager(io.dingodb.store.row.storage.zip.ZipStrategyManager) WaitStrategyType(io.dingodb.store.row.util.concurrent.disruptor.WaitStrategyType) Endpoint(io.dingodb.raft.util.Endpoint) Histogram(com.codahale.metrics.Histogram) KeyLockRequest(io.dingodb.store.row.cmd.store.KeyLockRequest) KeyUnlockRequest(io.dingodb.store.row.cmd.store.KeyUnlockRequest) KVStoreClosure(io.dingodb.store.row.storage.KVStoreClosure) Requires(io.dingodb.raft.util.Requires) KVMetricNames(io.dingodb.store.row.metrics.KVMetricNames) DingoRowStoreOptions(io.dingodb.store.row.options.DingoRowStoreOptions) BatchDeleteRequest(io.dingodb.store.row.cmd.store.BatchDeleteRequest) FollowerStateListener(io.dingodb.store.row.FollowerStateListener) MapFailoverFuture(io.dingodb.store.row.client.failover.impl.MapFailoverFuture) CompletableFuture(java.util.concurrent.CompletableFuture) LogExceptionHandler(io.dingodb.raft.util.LogExceptionHandler) ApiExceptionHelper(io.dingodb.store.row.errors.ApiExceptionHelper) CompareAndPutRequest(io.dingodb.store.row.cmd.store.CompareAndPutRequest) GetSequenceRequest(io.dingodb.store.row.cmd.store.GetSequenceRequest) AffinityNamedThreadFactory(io.dingodb.store.row.util.concurrent.AffinityNamedThreadFactory) RetryRunner(io.dingodb.store.row.client.failover.RetryRunner) FailoverClosureImpl(io.dingodb.store.row.client.failover.impl.FailoverClosureImpl) Sequence(io.dingodb.store.row.storage.Sequence) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Dispatcher(io.dingodb.store.row.util.concurrent.disruptor.Dispatcher) RemotePlacementDriverClient(io.dingodb.store.row.client.pd.RemotePlacementDriverClient) DeleteRequest(io.dingodb.store.row.cmd.store.DeleteRequest) BatchingOptions(io.dingodb.store.row.options.BatchingOptions) EventHandler(com.lmax.disruptor.EventHandler) ContainsKeyRequest(io.dingodb.store.row.cmd.store.ContainsKeyRequest) KVIterator(io.dingodb.store.row.storage.KVIterator) ByteArray(io.dingodb.store.row.util.ByteArray) NodeExecuteRequest(io.dingodb.store.row.cmd.store.NodeExecuteRequest) RetryCallable(io.dingodb.store.row.client.failover.RetryCallable) Logger(org.slf4j.Logger) NamedThreadFactory(io.dingodb.raft.util.NamedThreadFactory) GetAndPutRequest(io.dingodb.store.row.cmd.store.GetAndPutRequest) DingoRowStoreRuntimeException(io.dingodb.store.row.errors.DingoRowStoreRuntimeException) RingBuffer(com.lmax.disruptor.RingBuffer) Region(io.dingodb.store.row.metadata.Region) ErrorsHelper(io.dingodb.store.row.errors.ErrorsHelper) ScanRequest(io.dingodb.store.row.cmd.store.ScanRequest) TaskDispatcher(io.dingodb.store.row.util.concurrent.disruptor.TaskDispatcher) TimeUnit(java.util.concurrent.TimeUnit) RawKVStore(io.dingodb.store.row.storage.RawKVStore) StateListenerContainer(io.dingodb.store.row.StateListenerContainer) LeaderStateListener(io.dingodb.store.row.LeaderStateListener) ListFailoverFuture(io.dingodb.store.row.client.failover.impl.ListFailoverFuture) PeerId(io.dingodb.raft.entity.PeerId) BytesUtil(io.dingodb.raft.util.BytesUtil) EventFactory(com.lmax.disruptor.EventFactory) Collections(java.util.Collections) Disruptor(com.lmax.disruptor.dsl.Disruptor) ExtSerializerSupports(io.dingodb.store.row.rpc.ExtSerializerSupports) CASEntry(io.dingodb.store.row.storage.CASEntry) FailoverClosureImpl(io.dingodb.store.row.client.failover.impl.FailoverClosureImpl) RawKVStore(io.dingodb.store.row.storage.RawKVStore) CASAllRequest(io.dingodb.store.row.cmd.store.CASAllRequest) RegionEngine(io.dingodb.store.row.RegionEngine) RetryRunner(io.dingodb.store.row.client.failover.RetryRunner)

Example 7 with Errors

use of io.dingodb.store.row.errors.Errors in project dingo by dingodb.

the class DefaultDingoRowStore method internalPut.

private void internalPut(final byte[] key, final byte[] value, 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 -> internalPut(key, value, future, retriesLeft - 1, retryCause);
    final FailoverClosure<Boolean> closure = new FailoverClosureImpl<>(future, retriesLeft, retryRunner);
    if (regionEngine != null) {
        if (ensureOnValidEpoch(region, regionEngine, closure)) {
            getRawKVStore(regionEngine).put(key, value, closure);
        }
    } else {
        final PutRequest request = new PutRequest();
        request.setKey(key);
        request.setValue(value);
        request.setRegionId(region.getId());
        request.setRegionEpoch(region.getRegionEpoch());
        this.dingoRowStoreRpcService.callAsyncWithRpc(request, closure, lastCause);
    }
}
Also used : Constants(io.dingodb.store.row.util.Constants) CASAllRequest(io.dingodb.store.row.cmd.store.CASAllRequest) LoggerFactory(org.slf4j.LoggerFactory) RouteTable(io.dingodb.raft.RouteTable) ListRetryCallable(io.dingodb.store.row.client.failover.ListRetryCallable) DeleteRangeRequest(io.dingodb.store.row.cmd.store.DeleteRangeRequest) Strings(io.dingodb.store.row.util.Strings) DistributedLock(io.dingodb.store.row.util.concurrent.DistributedLock) PlacementDriverClient(io.dingodb.store.row.client.pd.PlacementDriverClient) BoolFailoverFuture(io.dingodb.store.row.client.failover.impl.BoolFailoverFuture) Map(java.util.Map) RegionEngine(io.dingodb.store.row.RegionEngine) BatchPutRequest(io.dingodb.store.row.cmd.store.BatchPutRequest) ThreadFactory(java.util.concurrent.ThreadFactory) JRaftHelper(io.dingodb.store.row.JRaftHelper) ResetSequenceRequest(io.dingodb.store.row.cmd.store.ResetSequenceRequest) NodeExecutor(io.dingodb.store.row.storage.NodeExecutor) GetRequest(io.dingodb.store.row.cmd.store.GetRequest) Errors(io.dingodb.store.row.errors.Errors) FailoverClosure(io.dingodb.store.row.client.failover.FailoverClosure) FakePlacementDriverClient(io.dingodb.store.row.client.pd.FakePlacementDriverClient) StoreEngineOptions(io.dingodb.store.row.options.StoreEngineOptions) Status(io.dingodb.raft.Status) PutRequest(io.dingodb.store.row.cmd.store.PutRequest) Lists(io.dingodb.store.row.util.Lists) Utils(io.dingodb.raft.util.Utils) MergeRequest(io.dingodb.store.row.cmd.store.MergeRequest) MultiGetRequest(io.dingodb.store.row.cmd.store.MultiGetRequest) StackTraceUtil(io.dingodb.store.row.util.StackTraceUtil) StateListener(io.dingodb.store.row.StateListener) StoreEngine(io.dingodb.store.row.StoreEngine) PlacementDriverOptions(io.dingodb.store.row.options.PlacementDriverOptions) List(java.util.List) DescriberManager(io.dingodb.store.row.DescriberManager) RpcOptions(io.dingodb.store.row.options.RpcOptions) PutIfAbsentRequest(io.dingodb.store.row.cmd.store.PutIfAbsentRequest) KVMetrics(io.dingodb.store.row.metrics.KVMetrics) KVEntry(io.dingodb.store.row.storage.KVEntry) ZipStrategyManager(io.dingodb.store.row.storage.zip.ZipStrategyManager) WaitStrategyType(io.dingodb.store.row.util.concurrent.disruptor.WaitStrategyType) Endpoint(io.dingodb.raft.util.Endpoint) Histogram(com.codahale.metrics.Histogram) KeyLockRequest(io.dingodb.store.row.cmd.store.KeyLockRequest) KeyUnlockRequest(io.dingodb.store.row.cmd.store.KeyUnlockRequest) KVStoreClosure(io.dingodb.store.row.storage.KVStoreClosure) Requires(io.dingodb.raft.util.Requires) KVMetricNames(io.dingodb.store.row.metrics.KVMetricNames) DingoRowStoreOptions(io.dingodb.store.row.options.DingoRowStoreOptions) BatchDeleteRequest(io.dingodb.store.row.cmd.store.BatchDeleteRequest) FollowerStateListener(io.dingodb.store.row.FollowerStateListener) MapFailoverFuture(io.dingodb.store.row.client.failover.impl.MapFailoverFuture) CompletableFuture(java.util.concurrent.CompletableFuture) LogExceptionHandler(io.dingodb.raft.util.LogExceptionHandler) ApiExceptionHelper(io.dingodb.store.row.errors.ApiExceptionHelper) CompareAndPutRequest(io.dingodb.store.row.cmd.store.CompareAndPutRequest) GetSequenceRequest(io.dingodb.store.row.cmd.store.GetSequenceRequest) AffinityNamedThreadFactory(io.dingodb.store.row.util.concurrent.AffinityNamedThreadFactory) RetryRunner(io.dingodb.store.row.client.failover.RetryRunner) FailoverClosureImpl(io.dingodb.store.row.client.failover.impl.FailoverClosureImpl) Sequence(io.dingodb.store.row.storage.Sequence) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Dispatcher(io.dingodb.store.row.util.concurrent.disruptor.Dispatcher) RemotePlacementDriverClient(io.dingodb.store.row.client.pd.RemotePlacementDriverClient) DeleteRequest(io.dingodb.store.row.cmd.store.DeleteRequest) BatchingOptions(io.dingodb.store.row.options.BatchingOptions) EventHandler(com.lmax.disruptor.EventHandler) ContainsKeyRequest(io.dingodb.store.row.cmd.store.ContainsKeyRequest) KVIterator(io.dingodb.store.row.storage.KVIterator) ByteArray(io.dingodb.store.row.util.ByteArray) NodeExecuteRequest(io.dingodb.store.row.cmd.store.NodeExecuteRequest) RetryCallable(io.dingodb.store.row.client.failover.RetryCallable) Logger(org.slf4j.Logger) NamedThreadFactory(io.dingodb.raft.util.NamedThreadFactory) GetAndPutRequest(io.dingodb.store.row.cmd.store.GetAndPutRequest) DingoRowStoreRuntimeException(io.dingodb.store.row.errors.DingoRowStoreRuntimeException) RingBuffer(com.lmax.disruptor.RingBuffer) Region(io.dingodb.store.row.metadata.Region) ErrorsHelper(io.dingodb.store.row.errors.ErrorsHelper) ScanRequest(io.dingodb.store.row.cmd.store.ScanRequest) TaskDispatcher(io.dingodb.store.row.util.concurrent.disruptor.TaskDispatcher) TimeUnit(java.util.concurrent.TimeUnit) RawKVStore(io.dingodb.store.row.storage.RawKVStore) StateListenerContainer(io.dingodb.store.row.StateListenerContainer) LeaderStateListener(io.dingodb.store.row.LeaderStateListener) ListFailoverFuture(io.dingodb.store.row.client.failover.impl.ListFailoverFuture) PeerId(io.dingodb.raft.entity.PeerId) BytesUtil(io.dingodb.raft.util.BytesUtil) EventFactory(com.lmax.disruptor.EventFactory) Collections(java.util.Collections) Disruptor(com.lmax.disruptor.dsl.Disruptor) ExtSerializerSupports(io.dingodb.store.row.rpc.ExtSerializerSupports) CASEntry(io.dingodb.store.row.storage.CASEntry) FailoverClosureImpl(io.dingodb.store.row.client.failover.impl.FailoverClosureImpl) Region(io.dingodb.store.row.metadata.Region) BatchPutRequest(io.dingodb.store.row.cmd.store.BatchPutRequest) PutRequest(io.dingodb.store.row.cmd.store.PutRequest) CompareAndPutRequest(io.dingodb.store.row.cmd.store.CompareAndPutRequest) GetAndPutRequest(io.dingodb.store.row.cmd.store.GetAndPutRequest) RegionEngine(io.dingodb.store.row.RegionEngine) RetryRunner(io.dingodb.store.row.client.failover.RetryRunner)

Example 8 with Errors

use of io.dingodb.store.row.errors.Errors in project dingo by dingodb.

the class DefaultDingoRowStore method internalContainsKey.

private void internalContainsKey(final byte[] key, 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 -> internalContainsKey(key, future, retriesLeft - 1, retryCause);
    final FailoverClosure<Boolean> closure = new FailoverClosureImpl<>(future, retriesLeft, retryRunner);
    if (regionEngine != null) {
        if (ensureOnValidEpoch(region, regionEngine, closure)) {
            getRawKVStore(regionEngine).containsKey(key, closure);
        }
    } else {
        final ContainsKeyRequest request = new ContainsKeyRequest();
        request.setKey(key);
        request.setRegionId(region.getId());
        request.setRegionEpoch(region.getRegionEpoch());
        this.dingoRowStoreRpcService.callAsyncWithRpc(request, closure, lastCause);
    }
}
Also used : Constants(io.dingodb.store.row.util.Constants) CASAllRequest(io.dingodb.store.row.cmd.store.CASAllRequest) LoggerFactory(org.slf4j.LoggerFactory) RouteTable(io.dingodb.raft.RouteTable) ListRetryCallable(io.dingodb.store.row.client.failover.ListRetryCallable) DeleteRangeRequest(io.dingodb.store.row.cmd.store.DeleteRangeRequest) Strings(io.dingodb.store.row.util.Strings) DistributedLock(io.dingodb.store.row.util.concurrent.DistributedLock) PlacementDriverClient(io.dingodb.store.row.client.pd.PlacementDriverClient) BoolFailoverFuture(io.dingodb.store.row.client.failover.impl.BoolFailoverFuture) Map(java.util.Map) RegionEngine(io.dingodb.store.row.RegionEngine) BatchPutRequest(io.dingodb.store.row.cmd.store.BatchPutRequest) ThreadFactory(java.util.concurrent.ThreadFactory) JRaftHelper(io.dingodb.store.row.JRaftHelper) ResetSequenceRequest(io.dingodb.store.row.cmd.store.ResetSequenceRequest) NodeExecutor(io.dingodb.store.row.storage.NodeExecutor) GetRequest(io.dingodb.store.row.cmd.store.GetRequest) Errors(io.dingodb.store.row.errors.Errors) FailoverClosure(io.dingodb.store.row.client.failover.FailoverClosure) FakePlacementDriverClient(io.dingodb.store.row.client.pd.FakePlacementDriverClient) StoreEngineOptions(io.dingodb.store.row.options.StoreEngineOptions) Status(io.dingodb.raft.Status) PutRequest(io.dingodb.store.row.cmd.store.PutRequest) Lists(io.dingodb.store.row.util.Lists) Utils(io.dingodb.raft.util.Utils) MergeRequest(io.dingodb.store.row.cmd.store.MergeRequest) MultiGetRequest(io.dingodb.store.row.cmd.store.MultiGetRequest) StackTraceUtil(io.dingodb.store.row.util.StackTraceUtil) StateListener(io.dingodb.store.row.StateListener) StoreEngine(io.dingodb.store.row.StoreEngine) PlacementDriverOptions(io.dingodb.store.row.options.PlacementDriverOptions) List(java.util.List) DescriberManager(io.dingodb.store.row.DescriberManager) RpcOptions(io.dingodb.store.row.options.RpcOptions) PutIfAbsentRequest(io.dingodb.store.row.cmd.store.PutIfAbsentRequest) KVMetrics(io.dingodb.store.row.metrics.KVMetrics) KVEntry(io.dingodb.store.row.storage.KVEntry) ZipStrategyManager(io.dingodb.store.row.storage.zip.ZipStrategyManager) WaitStrategyType(io.dingodb.store.row.util.concurrent.disruptor.WaitStrategyType) Endpoint(io.dingodb.raft.util.Endpoint) Histogram(com.codahale.metrics.Histogram) KeyLockRequest(io.dingodb.store.row.cmd.store.KeyLockRequest) KeyUnlockRequest(io.dingodb.store.row.cmd.store.KeyUnlockRequest) KVStoreClosure(io.dingodb.store.row.storage.KVStoreClosure) Requires(io.dingodb.raft.util.Requires) KVMetricNames(io.dingodb.store.row.metrics.KVMetricNames) DingoRowStoreOptions(io.dingodb.store.row.options.DingoRowStoreOptions) BatchDeleteRequest(io.dingodb.store.row.cmd.store.BatchDeleteRequest) FollowerStateListener(io.dingodb.store.row.FollowerStateListener) MapFailoverFuture(io.dingodb.store.row.client.failover.impl.MapFailoverFuture) CompletableFuture(java.util.concurrent.CompletableFuture) LogExceptionHandler(io.dingodb.raft.util.LogExceptionHandler) ApiExceptionHelper(io.dingodb.store.row.errors.ApiExceptionHelper) CompareAndPutRequest(io.dingodb.store.row.cmd.store.CompareAndPutRequest) GetSequenceRequest(io.dingodb.store.row.cmd.store.GetSequenceRequest) AffinityNamedThreadFactory(io.dingodb.store.row.util.concurrent.AffinityNamedThreadFactory) RetryRunner(io.dingodb.store.row.client.failover.RetryRunner) FailoverClosureImpl(io.dingodb.store.row.client.failover.impl.FailoverClosureImpl) Sequence(io.dingodb.store.row.storage.Sequence) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Dispatcher(io.dingodb.store.row.util.concurrent.disruptor.Dispatcher) RemotePlacementDriverClient(io.dingodb.store.row.client.pd.RemotePlacementDriverClient) DeleteRequest(io.dingodb.store.row.cmd.store.DeleteRequest) BatchingOptions(io.dingodb.store.row.options.BatchingOptions) EventHandler(com.lmax.disruptor.EventHandler) ContainsKeyRequest(io.dingodb.store.row.cmd.store.ContainsKeyRequest) KVIterator(io.dingodb.store.row.storage.KVIterator) ByteArray(io.dingodb.store.row.util.ByteArray) NodeExecuteRequest(io.dingodb.store.row.cmd.store.NodeExecuteRequest) RetryCallable(io.dingodb.store.row.client.failover.RetryCallable) Logger(org.slf4j.Logger) NamedThreadFactory(io.dingodb.raft.util.NamedThreadFactory) GetAndPutRequest(io.dingodb.store.row.cmd.store.GetAndPutRequest) DingoRowStoreRuntimeException(io.dingodb.store.row.errors.DingoRowStoreRuntimeException) RingBuffer(com.lmax.disruptor.RingBuffer) Region(io.dingodb.store.row.metadata.Region) ErrorsHelper(io.dingodb.store.row.errors.ErrorsHelper) ScanRequest(io.dingodb.store.row.cmd.store.ScanRequest) TaskDispatcher(io.dingodb.store.row.util.concurrent.disruptor.TaskDispatcher) TimeUnit(java.util.concurrent.TimeUnit) RawKVStore(io.dingodb.store.row.storage.RawKVStore) StateListenerContainer(io.dingodb.store.row.StateListenerContainer) LeaderStateListener(io.dingodb.store.row.LeaderStateListener) ListFailoverFuture(io.dingodb.store.row.client.failover.impl.ListFailoverFuture) PeerId(io.dingodb.raft.entity.PeerId) BytesUtil(io.dingodb.raft.util.BytesUtil) EventFactory(com.lmax.disruptor.EventFactory) Collections(java.util.Collections) Disruptor(com.lmax.disruptor.dsl.Disruptor) ExtSerializerSupports(io.dingodb.store.row.rpc.ExtSerializerSupports) CASEntry(io.dingodb.store.row.storage.CASEntry) FailoverClosureImpl(io.dingodb.store.row.client.failover.impl.FailoverClosureImpl) Region(io.dingodb.store.row.metadata.Region) RegionEngine(io.dingodb.store.row.RegionEngine) RetryRunner(io.dingodb.store.row.client.failover.RetryRunner) ContainsKeyRequest(io.dingodb.store.row.cmd.store.ContainsKeyRequest)

Example 9 with Errors

use of io.dingodb.store.row.errors.Errors in project dingo by dingodb.

the class DefaultDingoRowStore method internalScan.

private FutureGroup<List<KVEntry>> internalScan(final byte[] startKey, final byte[] endKey, final boolean readOnlySafe, final boolean returnValue, final int retriesLeft, final Throwable lastCause) {
    Requires.requireNonNull(startKey, "startKey");
    final List<Region> regionList = this.pdClient.findRegionsByKeyRange(startKey, endKey, ApiExceptionHelper.isInvalidEpoch(lastCause));
    final List<CompletableFuture<List<KVEntry>>> futures = Lists.newArrayListWithCapacity(regionList.size());
    final Errors lastError = lastCause == null ? null : Errors.forException(lastCause);
    for (final Region region : regionList) {
        final byte[] regionStartKey = region.getStartKey();
        final byte[] regionEndKey = region.getEndKey();
        final byte[] subStartKey = regionStartKey == null ? startKey : BytesUtil.max(regionStartKey, startKey);
        final byte[] subEndKey = regionEndKey == null ? endKey : (endKey == null ? regionEndKey : BytesUtil.min(regionEndKey, endKey));
        final ListRetryCallable<KVEntry> retryCallable = retryCause -> internalScan(subStartKey, subEndKey, readOnlySafe, returnValue, retriesLeft - 1, retryCause);
        final ListFailoverFuture<KVEntry> future = new ListFailoverFuture<>(retriesLeft, retryCallable);
        internalRegionScan(region, subStartKey, subEndKey, false, readOnlySafe, returnValue, future, retriesLeft, lastError, this.onlyLeaderRead);
        futures.add(future);
    }
    return new FutureGroup<>(futures);
}
Also used : Constants(io.dingodb.store.row.util.Constants) CASAllRequest(io.dingodb.store.row.cmd.store.CASAllRequest) LoggerFactory(org.slf4j.LoggerFactory) RouteTable(io.dingodb.raft.RouteTable) ListRetryCallable(io.dingodb.store.row.client.failover.ListRetryCallable) DeleteRangeRequest(io.dingodb.store.row.cmd.store.DeleteRangeRequest) Strings(io.dingodb.store.row.util.Strings) DistributedLock(io.dingodb.store.row.util.concurrent.DistributedLock) PlacementDriverClient(io.dingodb.store.row.client.pd.PlacementDriverClient) BoolFailoverFuture(io.dingodb.store.row.client.failover.impl.BoolFailoverFuture) Map(java.util.Map) RegionEngine(io.dingodb.store.row.RegionEngine) BatchPutRequest(io.dingodb.store.row.cmd.store.BatchPutRequest) ThreadFactory(java.util.concurrent.ThreadFactory) JRaftHelper(io.dingodb.store.row.JRaftHelper) ResetSequenceRequest(io.dingodb.store.row.cmd.store.ResetSequenceRequest) NodeExecutor(io.dingodb.store.row.storage.NodeExecutor) GetRequest(io.dingodb.store.row.cmd.store.GetRequest) Errors(io.dingodb.store.row.errors.Errors) FailoverClosure(io.dingodb.store.row.client.failover.FailoverClosure) FakePlacementDriverClient(io.dingodb.store.row.client.pd.FakePlacementDriverClient) StoreEngineOptions(io.dingodb.store.row.options.StoreEngineOptions) Status(io.dingodb.raft.Status) PutRequest(io.dingodb.store.row.cmd.store.PutRequest) Lists(io.dingodb.store.row.util.Lists) Utils(io.dingodb.raft.util.Utils) MergeRequest(io.dingodb.store.row.cmd.store.MergeRequest) MultiGetRequest(io.dingodb.store.row.cmd.store.MultiGetRequest) StackTraceUtil(io.dingodb.store.row.util.StackTraceUtil) StateListener(io.dingodb.store.row.StateListener) StoreEngine(io.dingodb.store.row.StoreEngine) PlacementDriverOptions(io.dingodb.store.row.options.PlacementDriverOptions) List(java.util.List) DescriberManager(io.dingodb.store.row.DescriberManager) RpcOptions(io.dingodb.store.row.options.RpcOptions) PutIfAbsentRequest(io.dingodb.store.row.cmd.store.PutIfAbsentRequest) KVMetrics(io.dingodb.store.row.metrics.KVMetrics) KVEntry(io.dingodb.store.row.storage.KVEntry) ZipStrategyManager(io.dingodb.store.row.storage.zip.ZipStrategyManager) WaitStrategyType(io.dingodb.store.row.util.concurrent.disruptor.WaitStrategyType) Endpoint(io.dingodb.raft.util.Endpoint) Histogram(com.codahale.metrics.Histogram) KeyLockRequest(io.dingodb.store.row.cmd.store.KeyLockRequest) KeyUnlockRequest(io.dingodb.store.row.cmd.store.KeyUnlockRequest) KVStoreClosure(io.dingodb.store.row.storage.KVStoreClosure) Requires(io.dingodb.raft.util.Requires) KVMetricNames(io.dingodb.store.row.metrics.KVMetricNames) DingoRowStoreOptions(io.dingodb.store.row.options.DingoRowStoreOptions) BatchDeleteRequest(io.dingodb.store.row.cmd.store.BatchDeleteRequest) FollowerStateListener(io.dingodb.store.row.FollowerStateListener) MapFailoverFuture(io.dingodb.store.row.client.failover.impl.MapFailoverFuture) CompletableFuture(java.util.concurrent.CompletableFuture) LogExceptionHandler(io.dingodb.raft.util.LogExceptionHandler) ApiExceptionHelper(io.dingodb.store.row.errors.ApiExceptionHelper) CompareAndPutRequest(io.dingodb.store.row.cmd.store.CompareAndPutRequest) GetSequenceRequest(io.dingodb.store.row.cmd.store.GetSequenceRequest) AffinityNamedThreadFactory(io.dingodb.store.row.util.concurrent.AffinityNamedThreadFactory) RetryRunner(io.dingodb.store.row.client.failover.RetryRunner) FailoverClosureImpl(io.dingodb.store.row.client.failover.impl.FailoverClosureImpl) Sequence(io.dingodb.store.row.storage.Sequence) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Dispatcher(io.dingodb.store.row.util.concurrent.disruptor.Dispatcher) RemotePlacementDriverClient(io.dingodb.store.row.client.pd.RemotePlacementDriverClient) DeleteRequest(io.dingodb.store.row.cmd.store.DeleteRequest) BatchingOptions(io.dingodb.store.row.options.BatchingOptions) EventHandler(com.lmax.disruptor.EventHandler) ContainsKeyRequest(io.dingodb.store.row.cmd.store.ContainsKeyRequest) KVIterator(io.dingodb.store.row.storage.KVIterator) ByteArray(io.dingodb.store.row.util.ByteArray) NodeExecuteRequest(io.dingodb.store.row.cmd.store.NodeExecuteRequest) RetryCallable(io.dingodb.store.row.client.failover.RetryCallable) Logger(org.slf4j.Logger) NamedThreadFactory(io.dingodb.raft.util.NamedThreadFactory) GetAndPutRequest(io.dingodb.store.row.cmd.store.GetAndPutRequest) DingoRowStoreRuntimeException(io.dingodb.store.row.errors.DingoRowStoreRuntimeException) RingBuffer(com.lmax.disruptor.RingBuffer) Region(io.dingodb.store.row.metadata.Region) ErrorsHelper(io.dingodb.store.row.errors.ErrorsHelper) ScanRequest(io.dingodb.store.row.cmd.store.ScanRequest) TaskDispatcher(io.dingodb.store.row.util.concurrent.disruptor.TaskDispatcher) TimeUnit(java.util.concurrent.TimeUnit) RawKVStore(io.dingodb.store.row.storage.RawKVStore) StateListenerContainer(io.dingodb.store.row.StateListenerContainer) LeaderStateListener(io.dingodb.store.row.LeaderStateListener) ListFailoverFuture(io.dingodb.store.row.client.failover.impl.ListFailoverFuture) PeerId(io.dingodb.raft.entity.PeerId) BytesUtil(io.dingodb.raft.util.BytesUtil) EventFactory(com.lmax.disruptor.EventFactory) Collections(java.util.Collections) Disruptor(com.lmax.disruptor.dsl.Disruptor) ExtSerializerSupports(io.dingodb.store.row.rpc.ExtSerializerSupports) CASEntry(io.dingodb.store.row.storage.CASEntry) Errors(io.dingodb.store.row.errors.Errors) CompletableFuture(java.util.concurrent.CompletableFuture) KVEntry(io.dingodb.store.row.storage.KVEntry) ListFailoverFuture(io.dingodb.store.row.client.failover.impl.ListFailoverFuture) Region(io.dingodb.store.row.metadata.Region)

Example 10 with Errors

use of io.dingodb.store.row.errors.Errors in project dingo by dingodb.

the class DefaultDingoRowStore method internalDelete.

private void internalDelete(final byte[] key, 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 -> internalDelete(key, future, retriesLeft - 1, retryCause);
    final FailoverClosure<Boolean> closure = new FailoverClosureImpl<>(future, retriesLeft, retryRunner);
    if (regionEngine != null) {
        if (ensureOnValidEpoch(region, regionEngine, closure)) {
            getRawKVStore(regionEngine).delete(key, closure);
        }
    } else {
        final DeleteRequest request = new DeleteRequest();
        request.setKey(key);
        request.setRegionId(region.getId());
        request.setRegionEpoch(region.getRegionEpoch());
        this.dingoRowStoreRpcService.callAsyncWithRpc(request, closure, lastCause);
    }
}
Also used : Constants(io.dingodb.store.row.util.Constants) CASAllRequest(io.dingodb.store.row.cmd.store.CASAllRequest) LoggerFactory(org.slf4j.LoggerFactory) RouteTable(io.dingodb.raft.RouteTable) ListRetryCallable(io.dingodb.store.row.client.failover.ListRetryCallable) DeleteRangeRequest(io.dingodb.store.row.cmd.store.DeleteRangeRequest) Strings(io.dingodb.store.row.util.Strings) DistributedLock(io.dingodb.store.row.util.concurrent.DistributedLock) PlacementDriverClient(io.dingodb.store.row.client.pd.PlacementDriverClient) BoolFailoverFuture(io.dingodb.store.row.client.failover.impl.BoolFailoverFuture) Map(java.util.Map) RegionEngine(io.dingodb.store.row.RegionEngine) BatchPutRequest(io.dingodb.store.row.cmd.store.BatchPutRequest) ThreadFactory(java.util.concurrent.ThreadFactory) JRaftHelper(io.dingodb.store.row.JRaftHelper) ResetSequenceRequest(io.dingodb.store.row.cmd.store.ResetSequenceRequest) NodeExecutor(io.dingodb.store.row.storage.NodeExecutor) GetRequest(io.dingodb.store.row.cmd.store.GetRequest) Errors(io.dingodb.store.row.errors.Errors) FailoverClosure(io.dingodb.store.row.client.failover.FailoverClosure) FakePlacementDriverClient(io.dingodb.store.row.client.pd.FakePlacementDriverClient) StoreEngineOptions(io.dingodb.store.row.options.StoreEngineOptions) Status(io.dingodb.raft.Status) PutRequest(io.dingodb.store.row.cmd.store.PutRequest) Lists(io.dingodb.store.row.util.Lists) Utils(io.dingodb.raft.util.Utils) MergeRequest(io.dingodb.store.row.cmd.store.MergeRequest) MultiGetRequest(io.dingodb.store.row.cmd.store.MultiGetRequest) StackTraceUtil(io.dingodb.store.row.util.StackTraceUtil) StateListener(io.dingodb.store.row.StateListener) StoreEngine(io.dingodb.store.row.StoreEngine) PlacementDriverOptions(io.dingodb.store.row.options.PlacementDriverOptions) List(java.util.List) DescriberManager(io.dingodb.store.row.DescriberManager) RpcOptions(io.dingodb.store.row.options.RpcOptions) PutIfAbsentRequest(io.dingodb.store.row.cmd.store.PutIfAbsentRequest) KVMetrics(io.dingodb.store.row.metrics.KVMetrics) KVEntry(io.dingodb.store.row.storage.KVEntry) ZipStrategyManager(io.dingodb.store.row.storage.zip.ZipStrategyManager) WaitStrategyType(io.dingodb.store.row.util.concurrent.disruptor.WaitStrategyType) Endpoint(io.dingodb.raft.util.Endpoint) Histogram(com.codahale.metrics.Histogram) KeyLockRequest(io.dingodb.store.row.cmd.store.KeyLockRequest) KeyUnlockRequest(io.dingodb.store.row.cmd.store.KeyUnlockRequest) KVStoreClosure(io.dingodb.store.row.storage.KVStoreClosure) Requires(io.dingodb.raft.util.Requires) KVMetricNames(io.dingodb.store.row.metrics.KVMetricNames) DingoRowStoreOptions(io.dingodb.store.row.options.DingoRowStoreOptions) BatchDeleteRequest(io.dingodb.store.row.cmd.store.BatchDeleteRequest) FollowerStateListener(io.dingodb.store.row.FollowerStateListener) MapFailoverFuture(io.dingodb.store.row.client.failover.impl.MapFailoverFuture) CompletableFuture(java.util.concurrent.CompletableFuture) LogExceptionHandler(io.dingodb.raft.util.LogExceptionHandler) ApiExceptionHelper(io.dingodb.store.row.errors.ApiExceptionHelper) CompareAndPutRequest(io.dingodb.store.row.cmd.store.CompareAndPutRequest) GetSequenceRequest(io.dingodb.store.row.cmd.store.GetSequenceRequest) AffinityNamedThreadFactory(io.dingodb.store.row.util.concurrent.AffinityNamedThreadFactory) RetryRunner(io.dingodb.store.row.client.failover.RetryRunner) FailoverClosureImpl(io.dingodb.store.row.client.failover.impl.FailoverClosureImpl) Sequence(io.dingodb.store.row.storage.Sequence) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Dispatcher(io.dingodb.store.row.util.concurrent.disruptor.Dispatcher) RemotePlacementDriverClient(io.dingodb.store.row.client.pd.RemotePlacementDriverClient) DeleteRequest(io.dingodb.store.row.cmd.store.DeleteRequest) BatchingOptions(io.dingodb.store.row.options.BatchingOptions) EventHandler(com.lmax.disruptor.EventHandler) ContainsKeyRequest(io.dingodb.store.row.cmd.store.ContainsKeyRequest) KVIterator(io.dingodb.store.row.storage.KVIterator) ByteArray(io.dingodb.store.row.util.ByteArray) NodeExecuteRequest(io.dingodb.store.row.cmd.store.NodeExecuteRequest) RetryCallable(io.dingodb.store.row.client.failover.RetryCallable) Logger(org.slf4j.Logger) NamedThreadFactory(io.dingodb.raft.util.NamedThreadFactory) GetAndPutRequest(io.dingodb.store.row.cmd.store.GetAndPutRequest) DingoRowStoreRuntimeException(io.dingodb.store.row.errors.DingoRowStoreRuntimeException) RingBuffer(com.lmax.disruptor.RingBuffer) Region(io.dingodb.store.row.metadata.Region) ErrorsHelper(io.dingodb.store.row.errors.ErrorsHelper) ScanRequest(io.dingodb.store.row.cmd.store.ScanRequest) TaskDispatcher(io.dingodb.store.row.util.concurrent.disruptor.TaskDispatcher) TimeUnit(java.util.concurrent.TimeUnit) RawKVStore(io.dingodb.store.row.storage.RawKVStore) StateListenerContainer(io.dingodb.store.row.StateListenerContainer) LeaderStateListener(io.dingodb.store.row.LeaderStateListener) ListFailoverFuture(io.dingodb.store.row.client.failover.impl.ListFailoverFuture) PeerId(io.dingodb.raft.entity.PeerId) BytesUtil(io.dingodb.raft.util.BytesUtil) EventFactory(com.lmax.disruptor.EventFactory) Collections(java.util.Collections) Disruptor(com.lmax.disruptor.dsl.Disruptor) ExtSerializerSupports(io.dingodb.store.row.rpc.ExtSerializerSupports) CASEntry(io.dingodb.store.row.storage.CASEntry) FailoverClosureImpl(io.dingodb.store.row.client.failover.impl.FailoverClosureImpl) Region(io.dingodb.store.row.metadata.Region) RegionEngine(io.dingodb.store.row.RegionEngine) BatchDeleteRequest(io.dingodb.store.row.cmd.store.BatchDeleteRequest) DeleteRequest(io.dingodb.store.row.cmd.store.DeleteRequest) RetryRunner(io.dingodb.store.row.client.failover.RetryRunner)

Aggregations

Errors (io.dingodb.store.row.errors.Errors)33 Endpoint (io.dingodb.raft.util.Endpoint)32 FailoverClosure (io.dingodb.store.row.client.failover.FailoverClosure)32 RetryRunner (io.dingodb.store.row.client.failover.RetryRunner)32 FailoverClosureImpl (io.dingodb.store.row.client.failover.impl.FailoverClosureImpl)32 CompletableFuture (java.util.concurrent.CompletableFuture)32 Histogram (com.codahale.metrics.Histogram)27 EventFactory (com.lmax.disruptor.EventFactory)27 EventHandler (com.lmax.disruptor.EventHandler)27 RingBuffer (com.lmax.disruptor.RingBuffer)27 Disruptor (com.lmax.disruptor.dsl.Disruptor)27 RouteTable (io.dingodb.raft.RouteTable)27 Status (io.dingodb.raft.Status)27 PeerId (io.dingodb.raft.entity.PeerId)27 BytesUtil (io.dingodb.raft.util.BytesUtil)27 LogExceptionHandler (io.dingodb.raft.util.LogExceptionHandler)27 NamedThreadFactory (io.dingodb.raft.util.NamedThreadFactory)27 Requires (io.dingodb.raft.util.Requires)27 Utils (io.dingodb.raft.util.Utils)27 DescriberManager (io.dingodb.store.row.DescriberManager)27