Search in sources :

Example 1 with NodeExecutor

use of io.dingodb.store.row.storage.NodeExecutor 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);
    }
}
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) NodeExecuteRequest(io.dingodb.store.row.cmd.store.NodeExecuteRequest) RetryRunner(io.dingodb.store.row.client.failover.RetryRunner)

Example 2 with NodeExecutor

use of io.dingodb.store.row.storage.NodeExecutor in project dingo by dingodb.

the class DefaultRegionKVService method handleNodeExecuteRequest.

@Override
public void handleNodeExecuteRequest(final NodeExecuteRequest request, final RequestProcessClosure<BaseRequest, BaseResponse<?>> closure) {
    final NodeExecuteResponse response = new NodeExecuteResponse();
    response.setRegionId(getRegionId());
    response.setRegionEpoch(getRegionEpoch());
    try {
        KVParameterRequires.requireSameEpoch(request, getRegionEpoch());
        final NodeExecutor executor = KVParameterRequires.requireNonNull(request.getNodeExecutor(), "node.executor");
        this.rawKVStore.execute(executor, true, new BaseKVStoreClosure() {

            @Override
            public void run(final Status status) {
                if (status.isOk()) {
                    response.setValue((Boolean) getData());
                } else {
                    setFailure(request, response, status, getError());
                }
                closure.sendResponse(response);
            }
        });
    } catch (final Throwable t) {
        LOG.error("Failed to handle: {}, {}.", request, StackTraceUtil.stackTrace(t));
        response.setError(Errors.forException(t));
        closure.sendResponse(response);
    }
}
Also used : Status(io.dingodb.raft.Status) BaseKVStoreClosure(io.dingodb.store.row.storage.BaseKVStoreClosure) NodeExecuteResponse(io.dingodb.store.row.cmd.store.NodeExecuteResponse) NodeExecutor(io.dingodb.store.row.storage.NodeExecutor)

Aggregations

Status (io.dingodb.raft.Status)2 NodeExecutor (io.dingodb.store.row.storage.NodeExecutor)2 Histogram (com.codahale.metrics.Histogram)1 EventFactory (com.lmax.disruptor.EventFactory)1 EventHandler (com.lmax.disruptor.EventHandler)1 RingBuffer (com.lmax.disruptor.RingBuffer)1 Disruptor (com.lmax.disruptor.dsl.Disruptor)1 RouteTable (io.dingodb.raft.RouteTable)1 PeerId (io.dingodb.raft.entity.PeerId)1 BytesUtil (io.dingodb.raft.util.BytesUtil)1 Endpoint (io.dingodb.raft.util.Endpoint)1 LogExceptionHandler (io.dingodb.raft.util.LogExceptionHandler)1 NamedThreadFactory (io.dingodb.raft.util.NamedThreadFactory)1 Requires (io.dingodb.raft.util.Requires)1 Utils (io.dingodb.raft.util.Utils)1 DescriberManager (io.dingodb.store.row.DescriberManager)1 FollowerStateListener (io.dingodb.store.row.FollowerStateListener)1 JRaftHelper (io.dingodb.store.row.JRaftHelper)1 LeaderStateListener (io.dingodb.store.row.LeaderStateListener)1 RegionEngine (io.dingodb.store.row.RegionEngine)1