Search in sources :

Example 1 with NonBlockingThreadFactory

use of org.infinispan.factories.threads.NonBlockingThreadFactory in project infinispan by infinispan.

the class AsyncStoreStressTest method startMarshaller.

@BeforeClass(alwaysRun = true)
void startMarshaller() {
    marshaller = new TestObjectStreamMarshaller();
    location = CommonsTestingUtil.tmpDirectory(this.getClass());
    nonBlockingExecutor = new ThreadPoolExecutor(0, ProcessorInfo.availableProcessors() * 2, 60L, TimeUnit.SECONDS, new ArrayBlockingQueue<>(KnownComponentNames.getDefaultQueueSize(KnownComponentNames.NON_BLOCKING_EXECUTOR)), new NonBlockingThreadFactory("ISPN-non-blocking-thread-group", Thread.NORM_PRIORITY, DefaultThreadFactory.DEFAULT_PATTERN, "Test", "non-blocking"), NonBlockingRejectedExecutionHandler.getInstance());
    blockingExecutor = new ThreadPoolExecutor(0, 150, 60L, TimeUnit.SECONDS, new ArrayBlockingQueue<>(KnownComponentNames.getDefaultQueueSize(KnownComponentNames.BLOCKING_EXECUTOR)), getTestThreadFactory("Blocking"), BlockingRejectedExecutionHandler.getInstance());
    PerKeyLockContainer lockContainer = new PerKeyLockContainer();
    TestingUtil.inject(lockContainer, new DefaultTimeService());
    locks = lockContainer;
    timeService = new DefaultTimeService();
    TestingUtil.inject(locks, timeService, nonBlockingExecutor);
}
Also used : PerKeyLockContainer(org.infinispan.util.concurrent.locks.impl.PerKeyLockContainer) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) NonBlockingThreadFactory(org.infinispan.factories.threads.NonBlockingThreadFactory) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) TestObjectStreamMarshaller(org.infinispan.marshall.TestObjectStreamMarshaller) DefaultTimeService(org.infinispan.commons.time.DefaultTimeService) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with NonBlockingThreadFactory

use of org.infinispan.factories.threads.NonBlockingThreadFactory in project infinispan by infinispan.

the class NettyEventLoopFactory method construct.

@Override
public Object construct(String componentName) {
    ThreadFactory threadFactory = globalConfiguration.nonBlockingThreadPool().threadFactory();
    if (threadFactory == null) {
        threadFactory = new NonBlockingThreadFactory("ISPN-non-blocking-thread-group", getDefaultThreadPrio(KnownComponentNames.NON_BLOCKING_EXECUTOR), DefaultThreadFactory.DEFAULT_PATTERN, globalConfiguration.transport().nodeName(), shortened(KnownComponentNames.NON_BLOCKING_EXECUTOR));
    }
    ThreadPoolExecutorFactory<?> tpef = globalConfiguration.nonBlockingThreadPool().threadPoolFactory();
    int threadAmount = tpef instanceof NonBlockingThreadPoolExecutorFactory ? ((NonBlockingThreadPoolExecutorFactory) tpef).maxThreads() : getDefaultThreads(KnownComponentNames.NON_BLOCKING_EXECUTOR);
    // which means the non blocking executor may have an unbounded queue, depending upon netty implementation
    return new NonRecursiveEventLoopGroup(buildEventLoop(threadAmount, threadFactory, "non-blocking-thread-netty"));
}
Also used : DefaultThreadFactory(org.infinispan.factories.threads.DefaultThreadFactory) NonBlockingThreadFactory(org.infinispan.factories.threads.NonBlockingThreadFactory) ThreadFactory(java.util.concurrent.ThreadFactory) NonBlockingThreadPoolExecutorFactory(org.infinispan.factories.threads.NonBlockingThreadPoolExecutorFactory) NonBlockingThreadFactory(org.infinispan.factories.threads.NonBlockingThreadFactory) NonRecursiveEventLoopGroup(org.infinispan.server.core.transport.NonRecursiveEventLoopGroup)

Aggregations

NonBlockingThreadFactory (org.infinispan.factories.threads.NonBlockingThreadFactory)2 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 DefaultTimeService (org.infinispan.commons.time.DefaultTimeService)1 DefaultThreadFactory (org.infinispan.factories.threads.DefaultThreadFactory)1 NonBlockingThreadPoolExecutorFactory (org.infinispan.factories.threads.NonBlockingThreadPoolExecutorFactory)1 TestObjectStreamMarshaller (org.infinispan.marshall.TestObjectStreamMarshaller)1 NonRecursiveEventLoopGroup (org.infinispan.server.core.transport.NonRecursiveEventLoopGroup)1 PerKeyLockContainer (org.infinispan.util.concurrent.locks.impl.PerKeyLockContainer)1 BeforeClass (org.testng.annotations.BeforeClass)1