Search in sources :

Example 1 with DefaultThreadFactory

use of org.jgroups.util.DefaultThreadFactory in project geode by apache.

the class Transport method init.

/*
   * (non-Javadoc) JGroups does not currently (3.6.6) allow you to specify that threads should be
   * daemon, so we override the init() method here and create the factories before initializing UDP
   * 
   * @see org.jgroups.protocols.UDP#init()
   */
@Override
public void init() throws Exception {
    global_thread_factory = new DefaultThreadFactory("Geode ", true);
    timer_thread_factory = new LazyThreadFactory(THREAD_POOL_NAME_PREFIX + " Timer", true, true);
    default_thread_factory = new DefaultThreadFactory(THREAD_POOL_NAME_PREFIX + " Incoming", true, true);
    oob_thread_factory = new DefaultThreadFactory(THREAD_POOL_NAME_PREFIX + " OOB", true, true);
    internal_thread_factory = new DefaultThreadFactory(THREAD_POOL_NAME_PREFIX + " INT", true, true);
    super.init();
}
Also used : DefaultThreadFactory(org.jgroups.util.DefaultThreadFactory) LazyThreadFactory(org.jgroups.util.LazyThreadFactory)

Example 2 with DefaultThreadFactory

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

the class TransportConfigurator method afterCreation.

@Override
public void afterCreation(Protocol protocol) throws Exception {
    if (protocol instanceof TP) {
        TP transport = (TP) protocol;
        ClassLoader loader = JChannelFactory.class.getClassLoader();
        transport.setThreadFactory(new ClassLoaderThreadFactory(new DefaultThreadFactory("", false), loader));
        transport.setTimerThreadFactory(new ClassLoaderThreadFactory(new LazyThreadFactory("Timer", true, true), loader));
        transport.setDefaultThreadPoolThreadFactory(new ClassLoaderThreadFactory(new DefaultThreadFactory("Incoming", false, true), loader));
        transport.setOOBThreadPoolThreadFactory(new ClassLoaderThreadFactory(new DefaultThreadFactory("OOB", false, true), loader));
        transport.setInternalThreadPoolThreadFactory(new ClassLoaderThreadFactory(new DefaultThreadFactory("INT", false, true), loader));
    }
}
Also used : DefaultThreadFactory(org.jgroups.util.DefaultThreadFactory) LazyThreadFactory(org.jgroups.util.LazyThreadFactory) TP(org.jgroups.protocols.TP)

Example 3 with DefaultThreadFactory

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

the class TransportConfigurationBuilder method accept.

@Override
public void accept(T protocol) {
    InetSocketAddress socketAddress = this.getSocketBinding().getSocketAddress();
    protocol.setBindAddress(socketAddress.getAddress());
    protocol.setBindPort(socketAddress.getPort());
    protocol.setThreadFactory(new ClassLoaderThreadFactory(new DefaultThreadFactory("", false), JChannelFactory.class.getClassLoader()));
    protocol.setDefaultThreadPool(this.threadPoolFactories.get(ThreadPoolResourceDefinition.DEFAULT).getValue().get());
    protocol.setInternalThreadPool(this.threadPoolFactories.get(ThreadPoolResourceDefinition.INTERNAL).getValue().get());
    protocol.setOOBThreadPool(this.threadPoolFactories.get(ThreadPoolResourceDefinition.OOB).getValue().get());
    protocol.setTimer(this.timerFactory.getValue().get());
    Optional<InetSocketAddress> diagnosticsSocketAddress = Optional.ofNullable(this.diagnosticsSocketBinding).map(Value::getValue).map(SocketBinding::getSocketAddress);
    protocol.setValue("enable_diagnostics", diagnosticsSocketAddress.isPresent());
    diagnosticsSocketAddress.ifPresent(address -> {
        protocol.setValue("diagnostics_addr", address.getAddress());
        protocol.setValue("diagnostics_port", address.getPort());
    });
}
Also used : DefaultThreadFactory(org.jgroups.util.DefaultThreadFactory) SocketBinding(org.jboss.as.network.SocketBinding) InetSocketAddress(java.net.InetSocketAddress) ClassLoaderThreadFactory(org.jboss.as.clustering.jgroups.ClassLoaderThreadFactory)

Example 4 with DefaultThreadFactory

use of org.jgroups.util.DefaultThreadFactory 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

DefaultThreadFactory (org.jgroups.util.DefaultThreadFactory)4 ClassLoaderThreadFactory (org.jboss.as.clustering.jgroups.ClassLoaderThreadFactory)2 LazyThreadFactory (org.jgroups.util.LazyThreadFactory)2 InetSocketAddress (java.net.InetSocketAddress)1 RejectedExecutionHandler (java.util.concurrent.RejectedExecutionHandler)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 SocketBinding (org.jboss.as.network.SocketBinding)1 ImmediateValue (org.jboss.msc.value.ImmediateValue)1 TP (org.jgroups.protocols.TP)1 ShutdownRejectedExecutionHandler (org.jgroups.util.ShutdownRejectedExecutionHandler)1 ThreadFactory (org.jgroups.util.ThreadFactory)1