use of org.infinispan.configuration.global.ThreadPoolConfiguration 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;
}
use of org.infinispan.configuration.global.ThreadPoolConfiguration 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();
}
}
Aggregations