Search in sources :

Example 1 with QueueExecutor

use of org.jboss.threads.QueueExecutor in project wildfly-core by wildfly.

the class RemoteChannelPairSetup method setupRemoting.

public void setupRemoting(final ManagementMessageHandler handler) throws IOException {
    // executorService = new ThreadPoolExecutor(16, 16, 1L, TimeUnit.DAYS, new LinkedBlockingQueue<Runnable>());
    ThreadFactory threadFactory = new JBossThreadFactory(new ThreadGroup("Remoting"), Boolean.FALSE, null, "Remoting %f thread %t", null, null);
    executorService = new QueueExecutor(EXECUTOR_MAX_THREADS / 4 + 1, EXECUTOR_MAX_THREADS, EXECUTOR_KEEP_ALIVE_TIME, TimeUnit.MILLISECONDS, 500, threadFactory, true, null);
    ChannelServer.Configuration configuration = new ChannelServer.Configuration();
    configuration.setEndpointName(ENDPOINT_NAME);
    configuration.setUriScheme(URI_SCHEME);
    configuration.setBindAddress(new InetSocketAddress("127.0.0.1", PORT));
    configuration.setExecutor(executorService);
    channelServer = ChannelServer.create(configuration);
    final Channel.Receiver receiver = ManagementChannelReceiver.createDelegating(handler);
    this.registration = channelServer.addChannelOpenListener(TEST_CHANNEL, new OpenListener() {

        @Override
        public void registrationTerminated() {
        }

        @Override
        public void channelOpened(Channel channel) {
            serverChannel = channel;
            serverChannel.receiveMessage(receiver);
            clientConnectedLatch.countDown();
        }
    });
}
Also used : JBossThreadFactory(org.jboss.threads.JBossThreadFactory) ThreadFactory(java.util.concurrent.ThreadFactory) JBossThreadFactory(org.jboss.threads.JBossThreadFactory) ProtocolConnectionConfiguration(org.jboss.as.protocol.ProtocolConnectionConfiguration) QueueExecutor(org.jboss.threads.QueueExecutor) InetSocketAddress(java.net.InetSocketAddress) OpenListener(org.jboss.remoting3.OpenListener) Channel(org.jboss.remoting3.Channel)

Example 2 with QueueExecutor

use of org.jboss.threads.QueueExecutor in project wildfly-core by wildfly.

the class RemoteChannelPairSetup method setupRemoting.

public void setupRemoting(final ManagementChannelInitialization initialization) throws IOException {
    // executorService = Executors.newCachedThreadPool();
    final ThreadFactory threadFactory = new JBossThreadFactory(new ThreadGroup("Remoting"), Boolean.FALSE, null, "Remoting %f thread %t", null, null);
    executorService = new QueueExecutor(EXECUTOR_MAX_THREADS / 4 + 1, EXECUTOR_MAX_THREADS, EXECUTOR_KEEP_ALIVE_TIME, TimeUnit.MILLISECONDS, 500, threadFactory, true, null);
    final ChannelServer.Configuration configuration = new ChannelServer.Configuration();
    configuration.setEndpointName(ENDPOINT_NAME);
    configuration.setUriScheme(URI_SCHEME);
    configuration.setBindAddress(new InetSocketAddress("127.0.0.1", PORT));
    configuration.setExecutor(executorService);
    channelServer = ChannelServer.create(configuration);
    channelServer.addChannelOpenListener(TEST_CHANNEL, new OpenListener() {

        @Override
        public void registrationTerminated() {
        }

        @Override
        public void channelOpened(Channel channel) {
            serverChannel = channel;
            initialization.startReceiving(channel);
            clientConnectedLatch.countDown();
        }
    });
}
Also used : JBossThreadFactory(org.jboss.threads.JBossThreadFactory) ThreadFactory(java.util.concurrent.ThreadFactory) JBossThreadFactory(org.jboss.threads.JBossThreadFactory) ProtocolConnectionConfiguration(org.jboss.as.protocol.ProtocolConnectionConfiguration) QueueExecutor(org.jboss.threads.QueueExecutor) InetSocketAddress(java.net.InetSocketAddress) OpenListener(org.jboss.remoting3.OpenListener) Channel(org.jboss.remoting3.Channel)

Example 3 with QueueExecutor

use of org.jboss.threads.QueueExecutor in project wildfly-core by wildfly.

the class BoundedQueueThreadPoolService method start.

public synchronized void start(final StartContext context) throws StartException {
    final TimeSpec keepAliveSpec = keepAlive;
    long keepAliveTime = keepAliveSpec == null ? Long.MAX_VALUE : keepAliveSpec.getUnit().toNanos(keepAliveSpec.getDuration());
    QueueExecutor queueExecutor = new QueueExecutor(coreThreads, maxThreads, keepAliveTime, TimeUnit.NANOSECONDS, queueLength, threadFactoryValue.getValue(), blocking, handoffExecutorValue.getOptionalValue());
    queueExecutor.setAllowCoreThreadTimeout(allowCoreTimeout);
    executor = new ManagedQueueExecutorService(queueExecutor);
}
Also used : QueueExecutor(org.jboss.threads.QueueExecutor)

Aggregations

QueueExecutor (org.jboss.threads.QueueExecutor)3 InetSocketAddress (java.net.InetSocketAddress)2 ThreadFactory (java.util.concurrent.ThreadFactory)2 ProtocolConnectionConfiguration (org.jboss.as.protocol.ProtocolConnectionConfiguration)2 Channel (org.jboss.remoting3.Channel)2 OpenListener (org.jboss.remoting3.OpenListener)2 JBossThreadFactory (org.jboss.threads.JBossThreadFactory)2