Search in sources :

Example 1 with RegionHeartbeatRequest

use of io.dingodb.store.row.cmd.pd.RegionHeartbeatRequest 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));
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) TimeInterval(io.dingodb.store.row.metadata.TimeInterval) List(java.util.List) RegionHeartbeatRequest(io.dingodb.store.row.cmd.pd.RegionHeartbeatRequest)

Aggregations

RegionHeartbeatRequest (io.dingodb.store.row.cmd.pd.RegionHeartbeatRequest)1 TimeInterval (io.dingodb.store.row.metadata.TimeInterval)1 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1