use of io.dingodb.raft.util.NamedThreadFactory in project dingo by dingodb.
the class DefaultDingoRowStoreRpcService method createRpcCallbackExecutor.
private ThreadPoolExecutor createRpcCallbackExecutor(final RpcOptions opts) {
final int callbackExecutorCorePoolSize = opts.getCallbackExecutorCorePoolSize();
final int callbackExecutorMaximumPoolSize = opts.getCallbackExecutorMaximumPoolSize();
if (callbackExecutorCorePoolSize <= 0 || callbackExecutorMaximumPoolSize <= 0) {
return null;
}
final String name = "dingo-row-store-rpc-callback";
return //
ThreadPoolUtil.newBuilder().poolName(//
name).enableMetric(//
true).coreThreads(//
callbackExecutorCorePoolSize).maximumThreads(//
callbackExecutorMaximumPoolSize).keepAliveSeconds(//
120L).workQueue(//
new ArrayBlockingQueue<>(opts.getCallbackExecutorQueueCapacity())).threadFactory(//
new NamedThreadFactory(name, true)).rejectedHandler(//
new CallerRunsPolicyWithReport(name)).build();
}
use of io.dingodb.raft.util.NamedThreadFactory 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