Search in sources :

Example 1 with NulsThreadFactory

use of io.nuls.core.thread.manager.NulsThreadFactory in project nuls by nuls-io.

the class DisruptorUtil method createDisruptor.

/**
 * create a disruptor
 *
 * @param name           The title of the disruptor
 * @param ringBufferSize The size of ringBuffer
 */
public void createDisruptor(String name, int ringBufferSize) {
    if (DISRUPTOR_MAP.keySet().contains(name)) {
        throw new NulsRuntimeException(ErrorCode.FAILED, "create disruptor faild,the name is repetitive!");
    }
    Disruptor<DisruptorEvent> disruptor = new Disruptor<DisruptorEvent>(EVENT_FACTORY, ringBufferSize, new NulsThreadFactory(ModuleService.getInstance().getModuleId(EventBusModuleBootstrap.class), name), ProducerType.SINGLE, new BlockingWaitStrategy());
    // SleepingWaitStrategy
    // disruptor.handleEventsWith(new EventHandler<DisruptorEvent>() {
    // @Override
    // public void onEvent(DisruptorEvent disruptorEvent, long l, boolean b) throws Exception {
    // Log.debug(disruptorEvent.getData() + "");
    // }
    // });
    DISRUPTOR_MAP.put(name, disruptor);
}
Also used : NulsThreadFactory(io.nuls.core.thread.manager.NulsThreadFactory) NulsRuntimeException(io.nuls.core.exception.NulsRuntimeException) Disruptor(com.lmax.disruptor.dsl.Disruptor)

Example 2 with NulsThreadFactory

use of io.nuls.core.thread.manager.NulsThreadFactory in project nuls by nuls-io.

the class ProcessorManager method init.

public final void init() {
    pool = TaskManager.createThreadPool(EventBusConstant.THREAD_COUNT, 0, new NulsThreadFactory(NulsConstant.MODULE_ID_EVENT_BUS, EventBusConstant.THREAD_POOL_NAME));
    disruptorService.createDisruptor(disruptorName, EventBusConstant.DEFAULT_RING_BUFFER_SIZE);
    List<EventDispatchThread> handlerList = new ArrayList<>();
    for (int i = 0; i < EventBusConstant.THREAD_COUNT; i++) {
        EventDispatchThread handler = new EventDispatchThread(this);
        handlerList.add(handler);
    }
    disruptorService.handleEventsWithWorkerPool(disruptorName, handlerList.toArray(new EventDispatchThread[handlerList.size()]));
    disruptorService.start(disruptorName);
}
Also used : NulsThreadFactory(io.nuls.core.thread.manager.NulsThreadFactory) EventDispatchThread(io.nuls.event.bus.processor.thread.EventDispatchThread)

Example 3 with NulsThreadFactory

use of io.nuls.core.thread.manager.NulsThreadFactory in project nuls by nuls-io.

the class QueueManager method start.

public static void start() {
    ScheduledExecutorService service = TaskManager.createScheduledThreadPool(new NulsThreadFactory(NulsConstant.MODULE_ID_MICROKERNEL, "queueStatusLogPool"));
    service.scheduleAtFixedRate(new StatusLogThread(), 0, QueueManager.getLatelySecond(), TimeUnit.SECONDS);
    Running = true;
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) NulsThreadFactory(io.nuls.core.thread.manager.NulsThreadFactory) StatusLogThread(io.nuls.core.utils.queue.thread.StatusLogThread)

Aggregations

NulsThreadFactory (io.nuls.core.thread.manager.NulsThreadFactory)3 Disruptor (com.lmax.disruptor.dsl.Disruptor)1 NulsRuntimeException (io.nuls.core.exception.NulsRuntimeException)1 StatusLogThread (io.nuls.core.utils.queue.thread.StatusLogThread)1 EventDispatchThread (io.nuls.event.bus.processor.thread.EventDispatchThread)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1