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;
}
}
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);
}
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);
}
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;
}
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);
}
Aggregations