use of io.dingodb.store.row.metadata.TimeInterval in project dingo by dingodb.
the class RegionHeartbeatSender method sendRegionHeartbeat.
private void sendRegionHeartbeat(final long lastTime) throws Exception {
final long now = System.currentTimeMillis();
final RegionHeartbeatRequest request = new RegionHeartbeatRequest();
request.setClusterId(this.regionEngine.getStoreEngine().getClusterId());
request.setLeastKeysOnSplit(this.regionEngine.getStoreEngine().getStoreOpts().getLeastKeysOnSplit());
request.setRegion(region);
request.setRegionStats(collectRegionStats(new TimeInterval(lastTime, now)));
request.setSelfEndpoint(selfEndpoint);
CompletableFuture<List<Instruction>> future = new CompletableFuture<>();
callAsyncWithRpc(future, request, 3, null);
future.whenCompleteAsync(this::processHeartbeatResponse);
future.thenRunAsync(() -> heartbeatTimer.newTimeout(new RegionHeartbeatTask(now), interval, TimeUnit.SECONDS));
}
use of io.dingodb.store.row.metadata.TimeInterval 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.store.row.metadata.TimeInterval 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