Search in sources :

Example 1 with StoreHeartbeatRequest

use of io.dingodb.store.row.cmd.pd.StoreHeartbeatRequest 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 2 with StoreHeartbeatRequest

use of io.dingodb.store.row.cmd.pd.StoreHeartbeatRequest 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

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 TimeInterval (io.dingodb.store.row.metadata.TimeInterval)2