Search in sources :

Example 1 with DefaultThreadFactory

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

the class Parser method createThreadPoolConfiguration.

private ThreadPoolConfiguration createThreadPoolConfiguration(String threadPoolName, String componentName, ConfigurationBuilderHolder holder) {
    ThreadsConfigurationBuilder threads = holder.getGlobalConfigurationBuilder().threads();
    ThreadPoolBuilderAdapter threadPool = threads.getThreadPool(threadPoolName);
    if (threadPool == null)
        throw CONFIG.undefinedThreadPoolName(threadPoolName);
    ThreadPoolConfiguration threadPoolConfiguration = threadPool.asThreadPoolConfigurationBuilder();
    boolean isNonBlocking = threadPoolConfiguration.threadPoolFactory().createsNonBlockingThreads();
    if (NON_BLOCKING_EXECUTOR.equals(componentName) && !isNonBlocking) {
        throw CONFIG.threadPoolFactoryIsBlocking(threadPoolName, componentName);
    }
    DefaultThreadFactory threadFactory = threadPoolConfiguration.threadFactory();
    if (threadFactory != null) {
        threadFactory.setComponent(shortened(componentName));
    }
    return threadPoolConfiguration;
}
Also used : DefaultThreadFactory(org.infinispan.factories.threads.DefaultThreadFactory) ThreadPoolConfiguration(org.infinispan.configuration.global.ThreadPoolConfiguration) ThreadsConfigurationBuilder(org.infinispan.configuration.global.ThreadsConfigurationBuilder) ThreadPoolBuilderAdapter(org.infinispan.configuration.global.ThreadPoolBuilderAdapter)

Example 2 with DefaultThreadFactory

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

the class CoreConfigurationSerializer method writeThreads.

private void writeThreads(ConfigurationWriter writer, GlobalConfiguration globalConfiguration) {
    ConcurrentMap<String, DefaultThreadFactory> threadFactories = new ConcurrentHashMap<>();
    for (ThreadPoolConfiguration threadPoolConfiguration : Arrays.asList(globalConfiguration.expirationThreadPool(), globalConfiguration.listenerThreadPool(), globalConfiguration.nonBlockingThreadPool(), globalConfiguration.blockingThreadPool(), globalConfiguration.transport().remoteCommandThreadPool(), globalConfiguration.transport().transportThreadPool())) {
        ThreadFactory threadFactory = threadPoolConfiguration.threadFactory();
        if (threadFactory instanceof DefaultThreadFactory) {
            DefaultThreadFactory tf = (DefaultThreadFactory) threadFactory;
            threadFactories.putIfAbsent(tf.getName(), tf);
        }
    }
    if (threadFactories.size() > 0) {
        writer.writeStartElement(Element.THREADS);
        writer.writeStartMap(Element.THREAD_FACTORIES);
        for (DefaultThreadFactory threadFactory : threadFactories.values()) {
            writeThreadFactory(writer, threadFactory);
        }
        writer.writeEndMap();
        writer.writeStartMap(Element.THREAD_POOLS);
        writeThreadPool(writer, globalConfiguration.nonBlockingThreadPoolName(), globalConfiguration.nonBlockingThreadPool());
        writeThreadPool(writer, globalConfiguration.expirationThreadPoolName(), globalConfiguration.expirationThreadPool());
        writeThreadPool(writer, globalConfiguration.listenerThreadPoolName(), globalConfiguration.listenerThreadPool());
        writeThreadPool(writer, globalConfiguration.blockingThreadPoolName(), globalConfiguration.blockingThreadPool());
        writeThreadPool(writer, globalConfiguration.transport().remoteThreadPoolName(), globalConfiguration.transport().remoteCommandThreadPool());
        writer.writeEndMap();
        writer.writeEndElement();
    }
}
Also used : DefaultThreadFactory(org.infinispan.factories.threads.DefaultThreadFactory) DefaultThreadFactory(org.infinispan.factories.threads.DefaultThreadFactory) ThreadFactory(java.util.concurrent.ThreadFactory) ThreadPoolConfiguration(org.infinispan.configuration.global.ThreadPoolConfiguration) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 3 with DefaultThreadFactory

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

the class ScheduledThreadPoolConfigurationBuilder method asThreadPoolConfigurationBuilder.

@Override
public ThreadPoolConfiguration asThreadPoolConfigurationBuilder() {
    ThreadPoolConfigurationBuilder builder = new ThreadPoolConfigurationBuilder(getGlobalConfig());
    builder.threadPoolFactory(ScheduledThreadPoolExecutorFactory.create());
    DefaultThreadFactory threadFactory = getGlobalConfig().threads().getThreadFactory(threadFactory()).create().getThreadFactory(false);
    builder.threadFactory(threadFactory);
    builder.name(name());
    return builder.create();
}
Also used : DefaultThreadFactory(org.infinispan.factories.threads.DefaultThreadFactory)

Example 4 with DefaultThreadFactory

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

the class BoundedThreadPoolConfigurationBuilder method asThreadPoolConfigurationBuilder.

@Override
public ThreadPoolConfiguration asThreadPoolConfigurationBuilder() {
    ThreadPoolConfigurationBuilder builder = new ThreadPoolConfigurationBuilder(getGlobalConfig());
    boolean isNonBlocking = isNonBlocking();
    builder.threadPoolFactory(CoreExecutorFactory.executorFactory(maxThreads(), coreThreads(), queueLength(), keepAliveTime(), isNonBlocking));
    builder.name(name());
    if (threadFactory() != null) {
        DefaultThreadFactory threadFactory = getGlobalConfig().threads().getThreadFactory(threadFactory()).create().getThreadFactory(isNonBlocking);
        builder.threadFactory(threadFactory);
    }
    return builder.create();
}
Also used : DefaultThreadFactory(org.infinispan.factories.threads.DefaultThreadFactory)

Example 5 with DefaultThreadFactory

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

the class CachedThreadPoolConfigurationBuilder method asThreadPoolConfigurationBuilder.

@Override
public ThreadPoolConfiguration asThreadPoolConfigurationBuilder() {
    ThreadPoolConfigurationBuilder builder = new ThreadPoolConfigurationBuilder(getGlobalConfig());
    builder.threadPoolFactory(CachedThreadPoolExecutorFactory.create());
    DefaultThreadFactory threadFactory = getGlobalConfig().threads().getThreadFactory(threadFactory()).create().getThreadFactory(false);
    builder.threadFactory(threadFactory);
    builder.name(name());
    return builder.create();
}
Also used : DefaultThreadFactory(org.infinispan.factories.threads.DefaultThreadFactory)

Aggregations

DefaultThreadFactory (org.infinispan.factories.threads.DefaultThreadFactory)9 ThreadFactory (java.util.concurrent.ThreadFactory)2 ThreadPoolConfiguration (org.infinispan.configuration.global.ThreadPoolConfiguration)2 BitSet (java.util.BitSet)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ExecutorService (java.util.concurrent.ExecutorService)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AdvancedCache (org.infinispan.AdvancedCache)1 Cache (org.infinispan.Cache)1 InvocationHelper (org.infinispan.cache.impl.InvocationHelper)1 RemoteCache (org.infinispan.client.hotrod.RemoteCache)1 BlockingThreadPoolExecutorFactory (org.infinispan.commons.executors.BlockingThreadPoolExecutorFactory)1 TestMBeanServerLookup (org.infinispan.commons.jmx.TestMBeanServerLookup)1 AdvancedExternalizer (org.infinispan.commons.marshall.AdvancedExternalizer)1 AbstractStoreConfiguration (org.infinispan.configuration.cache.AbstractStoreConfiguration)1 ClusterLoaderConfiguration (org.infinispan.configuration.cache.ClusterLoaderConfiguration)1 Configuration (org.infinispan.configuration.cache.Configuration)1 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)1 InterceptorConfiguration (org.infinispan.configuration.cache.InterceptorConfiguration)1