Search in sources :

Example 1 with TimeInterval

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

Example 2 with TimeInterval

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);
}
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 3 with TimeInterval

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

TimeInterval (io.dingodb.store.row.metadata.TimeInterval)3 Status (io.dingodb.raft.Status)2 Endpoint (io.dingodb.raft.util.Endpoint)2 StoreHeartbeatRequest (io.dingodb.store.row.cmd.pd.StoreHeartbeatRequest)2 StoreStats (io.dingodb.store.row.metadata.StoreStats)2 RegionHeartbeatRequest (io.dingodb.store.row.cmd.pd.RegionHeartbeatRequest)1 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1