Search in sources :

Example 1 with HashedWheelTimer

use of io.dingodb.raft.util.timer.HashedWheelTimer in project dingo by dingodb.

the class StoreHeartbeatSender method init.

@Override
public synchronized boolean init(final HeartbeatOptions opts) {
    if (this.started) {
        LOG.info("[HeartbeatSender] already started.");
        return true;
    }
    this.statsCollector = new StatsCollector(this.storeEngine);
    this.heartbeatTimer = new HashedWheelTimer(new NamedThreadFactory("heartbeat-timer", true), 50, TimeUnit.MILLISECONDS, 4096);
    this.heartbeatRpcTimeoutMillis = opts.getHeartbeatRpcTimeoutMillis();
    if (this.heartbeatRpcTimeoutMillis <= 0) {
        throw new IllegalArgumentException("Heartbeat rpc timeout millis must > 0, " + this.heartbeatRpcTimeoutMillis);
    }
    final String name = "dingo-row-store-heartbeat-callback";
    this.heartbeatRpcCallbackExecutor = ThreadPoolUtil.newBuilder().poolName(name).enableMetric(true).coreThreads(4).maximumThreads(4).keepAliveSeconds(120L).workQueue(new ArrayBlockingQueue<>(1024)).threadFactory(new NamedThreadFactory(name, true)).rejectedHandler(new DiscardOldPolicyWithReport(name)).build();
    final long storeHeartbeatIntervalSeconds = opts.getStoreHeartbeatIntervalSeconds();
    if (storeHeartbeatIntervalSeconds <= 0) {
        throw new IllegalArgumentException("Store heartbeat interval seconds must > 0, " + storeHeartbeatIntervalSeconds);
    }
    final long now = System.currentTimeMillis();
    final StoreHeartbeatTask storeHeartbeatTask = new StoreHeartbeatTask(storeHeartbeatIntervalSeconds, now, false);
    this.heartbeatTimer.newTimeout(storeHeartbeatTask, storeHeartbeatTask.getNextDelay(), TimeUnit.SECONDS);
    LOG.info("[StoreHeartbeatSender] start successfully, options: {}.", opts);
    return this.started = true;
}
Also used : DiscardOldPolicyWithReport(io.dingodb.store.row.util.concurrent.DiscardOldPolicyWithReport) NamedThreadFactory(io.dingodb.raft.util.NamedThreadFactory) HashedWheelTimer(io.dingodb.raft.util.timer.HashedWheelTimer)

Example 2 with HashedWheelTimer

use of io.dingodb.raft.util.timer.HashedWheelTimer in project dingo by dingodb.

the class RegionHeartbeatSender method start.

public synchronized void start() {
    if (heartbeatTimer == null) {
        this.heartbeatTimer = new HashedWheelTimer(new NamedThreadFactory(TIMER_THREAD_NAME, true), 50, TimeUnit.MILLISECONDS, 4096);
    }
    this.heartbeatTimer.start();
    final RegionHeartbeatTask regionHeartbeatTask = new RegionHeartbeatTask(-1);
    this.heartbeatTimer.newTimeout(regionHeartbeatTask, 0, TimeUnit.SECONDS);
}
Also used : NamedThreadFactory(io.dingodb.raft.util.NamedThreadFactory) HashedWheelTimer(io.dingodb.raft.util.timer.HashedWheelTimer)

Example 3 with HashedWheelTimer

use of io.dingodb.raft.util.timer.HashedWheelTimer in project dingo by dingodb.

the class StoreHeartbeatSender method init.

@Override
public synchronized boolean init(final HeartbeatOptions opts) {
    if (this.started) {
        LOG.info("[StoreHeartbeatSender] already started.");
        return true;
    }
    this.statsCollector = new StatsCollector(this.storeEngine);
    this.heartbeatTimer = new HashedWheelTimer(new NamedThreadFactory("heartbeat-timer", true), 50, TimeUnit.MILLISECONDS, 4096);
    this.heartbeatRpcTimeoutMillis = opts.getHeartbeatRpcTimeoutMillis();
    if (this.heartbeatRpcTimeoutMillis <= 0) {
        throw new IllegalArgumentException("Heartbeat rpc timeout millis must > 0, " + this.heartbeatRpcTimeoutMillis);
    }
    final String name = "dingo-row-store-heartbeat-callback";
    this.heartbeatRpcCallbackExecutor = ThreadPoolUtil.newBuilder().poolName(name).enableMetric(true).coreThreads(4).maximumThreads(4).keepAliveSeconds(120L).workQueue(new ArrayBlockingQueue<>(1024)).threadFactory(new NamedThreadFactory(name, true)).rejectedHandler(new DiscardOldPolicyWithReport(name)).build();
    final long storeHeartbeatIntervalSeconds = opts.getStoreHeartbeatIntervalSeconds();
    if (storeHeartbeatIntervalSeconds <= 0) {
        throw new IllegalArgumentException("Store heartbeat interval seconds must > 0, " + storeHeartbeatIntervalSeconds);
    }
    final long now = System.currentTimeMillis();
    final StoreHeartbeatTask storeHeartbeatTask = new StoreHeartbeatTask(storeHeartbeatIntervalSeconds, now, false);
    this.heartbeatTimer.newTimeout(storeHeartbeatTask, storeHeartbeatTask.getNextDelay(), TimeUnit.SECONDS);
    LOG.info("[StoreHeartbeatSender] start successfully, options: {}.", opts);
    return this.started = true;
}
Also used : DiscardOldPolicyWithReport(io.dingodb.store.row.util.concurrent.DiscardOldPolicyWithReport) StatsCollector(io.dingodb.store.row.client.pd.StatsCollector) NamedThreadFactory(io.dingodb.raft.util.NamedThreadFactory) HashedWheelTimer(io.dingodb.raft.util.timer.HashedWheelTimer)

Aggregations

NamedThreadFactory (io.dingodb.raft.util.NamedThreadFactory)3 HashedWheelTimer (io.dingodb.raft.util.timer.HashedWheelTimer)3 DiscardOldPolicyWithReport (io.dingodb.store.row.util.concurrent.DiscardOldPolicyWithReport)2 StatsCollector (io.dingodb.store.row.client.pd.StatsCollector)1