Search in sources :

Example 1 with ShutdownRejectedExecutionHandler

use of org.jgroups.util.ShutdownRejectedExecutionHandler in project wildfly by wildfly.

the class ThreadPoolFactoryBuilder method build.

@Override
public ServiceBuilder<ThreadPoolFactory> build(ServiceTarget target) {
    int queueLength = this.getQueueLength();
    BlockingQueue<Runnable> queue = (queueLength > 0) ? new ArrayBlockingQueue<>(queueLength) : new SynchronousQueue<>();
    ClassLoader loader = JChannelFactory.class.getClassLoader();
    ThreadFactory threadFactory = new ClassLoaderThreadFactory(new DefaultThreadFactory(this.getThreadGroupPrefix(), false, true), loader);
    RejectedExecutionHandler handler = new ShutdownRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
    ThreadPoolFactory factory = () -> new ThreadPoolExecutor(this.getMinThreads(), this.getMaxThreads(), this.getKeepAliveTime(), TimeUnit.MILLISECONDS, queue, threadFactory, handler);
    return target.addService(this.getServiceName(), new ValueService<>(new ImmediateValue<>(factory)));
}
Also used : ClassLoaderThreadFactory(org.jboss.as.clustering.jgroups.ClassLoaderThreadFactory) DefaultThreadFactory(org.jgroups.util.DefaultThreadFactory) ThreadFactory(org.jgroups.util.ThreadFactory) ShutdownRejectedExecutionHandler(org.jgroups.util.ShutdownRejectedExecutionHandler) RejectedExecutionHandler(java.util.concurrent.RejectedExecutionHandler) ImmediateValue(org.jboss.msc.value.ImmediateValue) DefaultThreadFactory(org.jgroups.util.DefaultThreadFactory) ClassLoaderThreadFactory(org.jboss.as.clustering.jgroups.ClassLoaderThreadFactory) ShutdownRejectedExecutionHandler(org.jgroups.util.ShutdownRejectedExecutionHandler) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Aggregations

RejectedExecutionHandler (java.util.concurrent.RejectedExecutionHandler)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 ClassLoaderThreadFactory (org.jboss.as.clustering.jgroups.ClassLoaderThreadFactory)1 ImmediateValue (org.jboss.msc.value.ImmediateValue)1 DefaultThreadFactory (org.jgroups.util.DefaultThreadFactory)1 ShutdownRejectedExecutionHandler (org.jgroups.util.ShutdownRejectedExecutionHandler)1 ThreadFactory (org.jgroups.util.ThreadFactory)1