Search in sources :

Example 6 with Endpoint

use of io.dingodb.raft.util.Endpoint in project dingo by dingodb.

the class InstructionProcessor method processTransferLeader.

private boolean processTransferLeader(final Instruction instruction) {
    try {
        final Instruction.TransferLeader transferLeader = instruction.getTransferLeader();
        if (transferLeader == null) {
            return false;
        }
        final Endpoint toEndpoint = transferLeader.getMoveToEndpoint();
        if (toEndpoint == null) {
            LOG.error("TransferLeader#toEndpoint must not be null, {}.", instruction);
            return false;
        }
        final Region region = instruction.getRegion();
        final String regionId = region.getId();
        final RegionEngine engine = this.storeEngine.getRegionEngine(regionId);
        if (engine == null) {
            LOG.error("Could not found regionEngine, {}.", instruction);
            return false;
        }
        if (!region.equals(engine.getRegion())) {
            LOG.warn("Instruction [{}] is out of date.", instruction);
            return false;
        }
        return engine.transferLeadershipTo(toEndpoint);
    } catch (final Throwable t) {
        LOG.error("Caught an exception on #processTransferLeader: {}.", StackTraceUtil.stackTrace(t));
        return false;
    }
}
Also used : Endpoint(io.dingodb.raft.util.Endpoint) Region(io.dingodb.store.row.metadata.Region) RegionEngine(io.dingodb.store.row.RegionEngine) Instruction(io.dingodb.store.row.metadata.Instruction)

Example 7 with Endpoint

use of io.dingodb.raft.util.Endpoint in project dingo by dingodb.

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);
}
Also used : CreateRegionIdRequest(io.dingodb.store.row.cmd.pd.CreateRegionIdRequest) GetClusterInfoRequest(io.dingodb.store.row.cmd.pd.GetClusterInfoRequest) Errors(io.dingodb.store.row.errors.Errors) FailoverClosure(io.dingodb.store.row.client.failover.FailoverClosure) Store(io.dingodb.store.row.metadata.Store) CompletableFuture(java.util.concurrent.CompletableFuture) Cluster(io.dingodb.store.row.metadata.Cluster) SetStoreInfoRequest(io.dingodb.store.row.cmd.pd.SetStoreInfoRequest) RetryRunner(io.dingodb.store.row.client.failover.RetryRunner) FailoverClosureImpl(io.dingodb.store.row.client.failover.impl.FailoverClosureImpl) GetStoreInfoRequest(io.dingodb.store.row.cmd.pd.GetStoreInfoRequest) GetStoreIdRequest(io.dingodb.store.row.cmd.pd.GetStoreIdRequest) Endpoint(io.dingodb.raft.util.Endpoint) FutureHelper(io.dingodb.store.row.client.FutureHelper) FailoverClosureImpl(io.dingodb.store.row.client.failover.impl.FailoverClosureImpl) GetStoreIdRequest(io.dingodb.store.row.cmd.pd.GetStoreIdRequest) RetryRunner(io.dingodb.store.row.client.failover.RetryRunner)

Example 8 with Endpoint

use of io.dingodb.raft.util.Endpoint in project dingo by dingodb.

the class StoreHeartbeatSender method sendStoreHeartbeat.

private void sendStoreHeartbeat(final long nextDelay, final boolean forceRefreshLeader, final long lastTime) {
    final long now = System.currentTimeMillis();
    final StoreHeartbeatRequest request = new StoreHeartbeatRequest();
    request.setClusterId(this.storeEngine.getClusterId());
    final TimeInterval timeInterval = new TimeInterval(lastTime, now);
    final StoreStats stats = this.statsCollector.collectStoreStats(timeInterval);
    request.setStats(stats);
    final HeartbeatClosure<Object> closure = new HeartbeatClosure<Object>() {

        @Override
        public void run(final Status status) {
            final boolean forceRefresh = !status.isOk() && ErrorsHelper.isInvalidPeer(getError());
            final StoreHeartbeatTask nexTask = new StoreHeartbeatTask(nextDelay, now, forceRefresh);
            heartbeatTimer.newTimeout(nexTask, nexTask.getNextDelay(), TimeUnit.SECONDS);
        }
    };
    final Endpoint endpoint = this.pdClient.getPdLeader(forceRefreshLeader, this.heartbeatRpcTimeoutMillis);
    callAsyncWithRpc(endpoint, request, closure);
}
Also used : StoreHeartbeatRequest(io.dingodb.store.row.cmd.pd.StoreHeartbeatRequest) Status(io.dingodb.raft.Status) StoreStats(io.dingodb.store.row.metadata.StoreStats) TimeInterval(io.dingodb.store.row.metadata.TimeInterval) Endpoint(io.dingodb.raft.util.Endpoint)

Example 9 with Endpoint

use of io.dingodb.raft.util.Endpoint in project dingo by dingodb.

the class ExecutorServer method buildRowStoreOptions.

private DingoRowStoreOptions buildRowStoreOptions() {
    DingoRowStoreOptions rowStoreOpts = new DingoRowStoreOptions();
    ExecutorExtOptions extOpts = svrOpts.getOptions();
    rowStoreOpts.setClusterName(DingoOptions.instance().getClusterOpts().getName());
    rowStoreOpts.setInitialServerList(svrOpts.getRaft().getInitExecRaftSvrList());
    rowStoreOpts.setFailoverRetries(extOpts.getCliOptions().getMaxRetry());
    rowStoreOpts.setFutureTimeoutMillis(extOpts.getCliOptions().getTimeoutMs());
    PlacementDriverOptions driverOptions = new PlacementDriverOptions();
    driverOptions.setFake(false);
    driverOptions.setPdGroupId(extOpts.getCoordOptions().getGroup());
    driverOptions.setInitialPdServerList(extOpts.getCoordOptions().getInitCoordRaftSvrList());
    CliOptions cliOptions = new CliOptions();
    cliOptions.setMaxRetry(extOpts.getCliOptions().getMaxRetry());
    cliOptions.setTimeoutMs(extOpts.getCliOptions().getTimeoutMs());
    driverOptions.setCliOptions(cliOptions);
    rowStoreOpts.setPlacementDriverOptions(driverOptions);
    Endpoint endpoint = new Endpoint(svrOpts.getIp(), svrOpts.getRaft().getPort());
    extOpts.getStoreEngineOptions().setServerAddress(endpoint);
    rowStoreOpts.setStoreEngineOptions(extOpts.getStoreEngineOptions());
    return rowStoreOpts;
}
Also used : PlacementDriverOptions(io.dingodb.store.row.options.PlacementDriverOptions) Endpoint(io.dingodb.raft.util.Endpoint) DingoRowStoreOptions(io.dingodb.store.row.options.DingoRowStoreOptions) ExecutorExtOptions(io.dingodb.server.executor.config.ExecutorExtOptions) CliOptions(io.dingodb.raft.option.CliOptions)

Example 10 with Endpoint

use of io.dingodb.raft.util.Endpoint in project dingo by dingodb.

the class StoreHeartbeatSender method sendStoreHeartbeat.

private void sendStoreHeartbeat(final long nextDelay, final boolean forceRefreshLeader, final long lastTime) {
    final long now = System.currentTimeMillis();
    final StoreHeartbeatRequest request = new StoreHeartbeatRequest();
    request.setClusterId(this.storeEngine.getClusterId());
    final TimeInterval timeInterval = new TimeInterval(lastTime, now);
    final StoreStats stats = this.statsCollector.collectStoreStats(timeInterval);
    stats.setLocation(CURRENT_LOCATION);
    request.setStats(stats);
    final HeartbeatClosure<Object> closure = new HeartbeatClosure<Object>() {

        @Override
        public void run(final Status status) {
            final boolean forceRefresh = !status.isOk() && ErrorsHelper.isInvalidPeer(getError());
            final StoreHeartbeatTask nexTask = new StoreHeartbeatTask(nextDelay, now, forceRefresh);
            heartbeatTimer.newTimeout(nexTask, nexTask.getNextDelay(), TimeUnit.SECONDS);
        }
    };
    final Endpoint endpoint = this.pdClient.getPdLeader(forceRefreshLeader, this.heartbeatRpcTimeoutMillis);
    callAsyncWithRpc(endpoint, request, closure);
}
Also used : StoreHeartbeatRequest(io.dingodb.store.row.cmd.pd.StoreHeartbeatRequest) Status(io.dingodb.raft.Status) StoreStats(io.dingodb.store.row.metadata.StoreStats) TimeInterval(io.dingodb.store.row.metadata.TimeInterval) Endpoint(io.dingodb.raft.util.Endpoint)

Aggregations

Endpoint (io.dingodb.raft.util.Endpoint)25 Store (io.dingodb.store.row.metadata.Store)6 PeerId (io.dingodb.raft.entity.PeerId)5 Cluster (io.dingodb.store.row.metadata.Cluster)5 NodeOptions (io.dingodb.raft.option.NodeOptions)4 Status (io.dingodb.raft.Status)3 FutureHelper (io.dingodb.store.row.client.FutureHelper)3 FailoverClosure (io.dingodb.store.row.client.failover.FailoverClosure)3 RetryRunner (io.dingodb.store.row.client.failover.RetryRunner)3 FailoverClosureImpl (io.dingodb.store.row.client.failover.impl.FailoverClosureImpl)3 CreateRegionIdRequest (io.dingodb.store.row.cmd.pd.CreateRegionIdRequest)3 GetClusterInfoRequest (io.dingodb.store.row.cmd.pd.GetClusterInfoRequest)3 GetStoreIdRequest (io.dingodb.store.row.cmd.pd.GetStoreIdRequest)3 GetStoreInfoRequest (io.dingodb.store.row.cmd.pd.GetStoreInfoRequest)3 SetStoreInfoRequest (io.dingodb.store.row.cmd.pd.SetStoreInfoRequest)3 Region (io.dingodb.store.row.metadata.Region)3 StoreStats (io.dingodb.store.row.metadata.StoreStats)3 RouteTable (io.dingodb.raft.RouteTable)2 Configuration (io.dingodb.raft.conf.Configuration)2 RpcServer (io.dingodb.raft.rpc.RpcServer)2