use of org.jboss.as.clustering.context.DefaultThreadFactory in project wildfly by wildfly.
the class ScheduledThreadPoolServiceConfigurator method configure.
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
int minThreads = this.definition.getMinThreads().resolveModelAttribute(context, model).asInt();
long keepAliveTime = this.definition.getKeepAliveTime().resolveModelAttribute(context, model).asLong();
ThreadPoolExecutorFactory<?> factory = new ThreadPoolExecutorFactory<ScheduledExecutorService>() {
@Override
public ScheduledExecutorService createExecutor(ThreadFactory factory) {
// Use fixed size, based on maxThreads
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(minThreads, new DefaultThreadFactory(factory));
executor.setKeepAliveTime(keepAliveTime, TimeUnit.MILLISECONDS);
executor.setRemoveOnCancelPolicy(true);
executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
return executor;
}
@Override
public void validate() {
// Do nothing
}
};
this.builder.threadPoolFactory(factory);
return this;
}
use of org.jboss.as.clustering.context.DefaultThreadFactory in project wildfly by wildfly.
the class CacheContainerServiceConfigurator method get.
@Override
public EmbeddedCacheManager get() {
GlobalConfiguration config = this.configuration.get();
String defaultCacheName = config.defaultCacheName().orElse(null);
ConfigurationBuilderHolder holder = new ConfigurationBuilderHolder(config.classLoader(), new GlobalConfigurationBuilder().read(config));
// We need to create a dummy default configuration if cache has a default cache
if (defaultCacheName != null) {
holder.newConfigurationBuilder(defaultCacheName);
}
EmbeddedCacheManager manager = new DefaultCacheManager(holder, false);
// Undefine the default cache, if we defined one
if (defaultCacheName != null) {
manager.undefineConfiguration(defaultCacheName);
}
manager.start();
// Must create executor before registering cache listener
this.executor = Executors.newSingleThreadExecutor(new DefaultThreadFactory(this.getClass()));
manager.addListener(this);
InfinispanLogger.ROOT_LOGGER.debugf("%s cache container started", this.name);
return manager;
}
use of org.jboss.as.clustering.context.DefaultThreadFactory in project wildfly by wildfly.
the class ClientThreadPoolServiceConfigurator method configure.
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
int maxThreads = this.definition.getMaxThreads().resolveModelAttribute(context, model).asInt();
int minThreads = this.definition.getMinThreads().resolveModelAttribute(context, model).asInt();
int queueLength = this.definition.getQueueLength().resolveModelAttribute(context, model).asInt();
long keepAliveTime = this.definition.getKeepAliveTime().resolveModelAttribute(context, model).asLong();
boolean nonBlocking = this.definition.isNonBlocking();
this.factory = new ExecutorFactory() {
@Override
public ExecutorService getExecutor(Properties property) {
BlockingQueue<Runnable> queue = queueLength == 0 ? new SynchronousQueue<>() : new LinkedBlockingQueue<>(queueLength);
ThreadFactory factory = new DefaultThreadFactory(new DaemonThreadFactory(DefaultAsyncExecutorFactory.THREAD_NAME));
if (nonBlocking) {
factory = new DefaultNonBlockingThreadFactory(factory);
}
RejectedExecutionHandler handler = nonBlocking ? NonBlockingRejectedExecutionHandler.getInstance() : BlockingRejectedExecutionHandler.getInstance();
return new ThreadPoolExecutor(minThreads, maxThreads, keepAliveTime, TimeUnit.MILLISECONDS, queue, factory, handler);
}
};
return this;
}
use of org.jboss.as.clustering.context.DefaultThreadFactory in project wildfly by wildfly.
the class UndertowEventHandlerAdapterService method start.
@Override
public void start(StartContext context) {
UndertowService service = this.configuration.getUndertowService();
ContainerEventHandler eventHandler = this.configuration.getContainerEventHandler();
this.connector = new UndertowConnector(this.configuration.getListener());
this.serverName = this.configuration.getServer().getName();
this.server = new UndertowServer(this.serverName, service, this.connector);
// Register ourselves as a listener to the container events
service.registerListener(this);
// Initialize mod_cluster and start it now
eventHandler.init(this.server);
eventHandler.start(this.server);
for (Engine engine : this.server.getEngines()) {
for (org.jboss.modcluster.container.Host host : engine.getHosts()) {
host.getContexts().forEach(c -> contexts.add(c));
}
}
// Start the periodic STATUS thread
this.executor = Executors.newScheduledThreadPool(1, new DefaultThreadFactory(UndertowEventHandlerAdapterService.class));
this.executor.scheduleWithFixedDelay(this, 0, this.configuration.getStatusInterval().toMillis(), TimeUnit.MILLISECONDS);
this.configuration.getSuspendController().registerActivity(this);
}
Aggregations