use of io.dingodb.store.row.client.pd.StatsCollector 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;
}
Aggregations