use of org.infinispan.configuration.global.ThreadsConfigurationBuilder 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.ThreadsConfigurationBuilder in project infinispan by infinispan.
the class Parser method parseBoundedQueueThreadPool.
public void parseBoundedQueueThreadPool(ConfigurationReader reader, ConfigurationBuilderHolder holder, String name, boolean isNonBlocking) {
ThreadsConfigurationBuilder threadsBuilder = holder.getGlobalConfigurationBuilder().threads();
String threadFactoryName = null;
int maxThreads = 0;
int coreThreads = 0;
int queueLength = 0;
long keepAlive = 0;
for (int i = 0; i < reader.getAttributeCount(); i++) {
ParseUtils.requireNoNamespaceAttribute(reader, i);
String value = reader.getAttributeValue(i);
Attribute attribute = Attribute.forName(reader.getAttributeName(i));
switch(attribute) {
case NAME:
{
// Already seen
break;
}
case THREAD_FACTORY:
{
threadFactoryName = value;
break;
}
case CORE_THREADS:
{
coreThreads = Integer.parseInt(value);
break;
}
case MAX_THREADS:
{
maxThreads = Integer.parseInt(value);
break;
}
case QUEUE_LENGTH:
{
queueLength = Integer.parseInt(value);
break;
}
case KEEP_ALIVE_TIME:
{
keepAlive = Long.parseLong(value);
break;
}
default:
{
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
}
threadsBuilder.addBoundedThreadPool(name).threadFactory(threadFactoryName).coreThreads(coreThreads).maxThreads(maxThreads).queueLength(queueLength).keepAliveTime(keepAlive).nonBlocking(isNonBlocking);
ParseUtils.requireNoContent(reader);
}
use of org.infinispan.configuration.global.ThreadsConfigurationBuilder in project infinispan by infinispan.
the class Parser method parseCachedThreadPool.
private void parseCachedThreadPool(ConfigurationReader reader, ConfigurationBuilderHolder holder, String name) {
ThreadsConfigurationBuilder threadsBuilder = holder.getGlobalConfigurationBuilder().threads();
String threadFactoryName = null;
for (int i = 0; i < reader.getAttributeCount(); i++) {
ParseUtils.requireNoNamespaceAttribute(reader, i);
String value = reader.getAttributeValue(i);
Attribute attribute = Attribute.forName(reader.getAttributeName(i));
switch(attribute) {
case NAME:
{
// Ignore
break;
}
case THREAD_FACTORY:
{
threadFactoryName = value;
break;
}
default:
{
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
}
threadsBuilder.addCachedThreadPool(name).threadFactory(threadFactoryName);
ParseUtils.requireNoContent(reader);
}
use of org.infinispan.configuration.global.ThreadsConfigurationBuilder in project infinispan by infinispan.
the class Parser method parseScheduledThreadPool.
private void parseScheduledThreadPool(ConfigurationReader reader, ConfigurationBuilderHolder holder, String name) {
ThreadsConfigurationBuilder threadsBuilder = holder.getGlobalConfigurationBuilder().threads();
String threadFactoryName = null;
for (int i = 0; i < reader.getAttributeCount(); i++) {
ParseUtils.requireNoNamespaceAttribute(reader, i);
String value = reader.getAttributeValue(i);
Attribute attribute = Attribute.forName(reader.getAttributeName(i));
switch(attribute) {
case NAME:
{
// Already seen
break;
}
case THREAD_FACTORY:
{
threadFactoryName = value;
break;
}
default:
{
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
}
threadsBuilder.addScheduledThreadPool(name).threadFactory(threadFactoryName);
ParseUtils.requireNoContent(reader);
}
Aggregations