Search in sources :

Example 11 with NamedThreadFactory

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();
}
Also used : ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) NamedThreadFactory(io.dingodb.raft.util.NamedThreadFactory) Endpoint(io.dingodb.raft.util.Endpoint) CallerRunsPolicyWithReport(io.dingodb.store.row.util.concurrent.CallerRunsPolicyWithReport)

Example 12 with NamedThreadFactory

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;
}
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)12 DisruptorMetricSet (io.dingodb.raft.util.DisruptorMetricSet)4 BlockingWaitStrategy (com.lmax.disruptor.BlockingWaitStrategy)3 Endpoint (io.dingodb.raft.util.Endpoint)3 HashedWheelTimer (io.dingodb.raft.util.timer.HashedWheelTimer)3 Status (io.dingodb.raft.Status)2 ConfigurationEntry (io.dingodb.raft.conf.ConfigurationEntry)2 ConfigurationManager (io.dingodb.raft.conf.ConfigurationManager)2 LogId (io.dingodb.raft.entity.LogId)2 RaftException (io.dingodb.raft.error.RaftException)2 CallerRunsPolicyWithReport (io.dingodb.store.row.util.concurrent.CallerRunsPolicyWithReport)2 DiscardOldPolicyWithReport (io.dingodb.store.row.util.concurrent.DiscardOldPolicyWithReport)2 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)2 ThreadFactory (java.util.concurrent.ThreadFactory)2 com.lmax.disruptor (com.lmax.disruptor)1 Disruptor (com.lmax.disruptor.dsl.Disruptor)1 ProducerType (com.lmax.disruptor.dsl.ProducerType)1 FSMCaller (io.dingodb.raft.FSMCaller)1 Configuration (io.dingodb.raft.conf.Configuration)1 NodeMetrics (io.dingodb.raft.core.NodeMetrics)1