Search in sources :

Example 6 with ActiveMQThreadFactory

use of org.apache.activemq.artemis.utils.ActiveMQThreadFactory in project activemq-artemis by apache.

the class ReplicationTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    tFactory = new ActiveMQThreadFactory("ActiveMQ-ReplicationTest", false, this.getClass().getClassLoader());
    executor = Executors.newCachedThreadPool(tFactory);
    scheduledExecutor = new ScheduledThreadPoolExecutor(10, tFactory);
    factory = new OrderedExecutorFactory(executor);
}
Also used : OrderedExecutorFactory(org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) ActiveMQThreadFactory(org.apache.activemq.artemis.utils.ActiveMQThreadFactory) Before(org.junit.Before)

Example 7 with ActiveMQThreadFactory

use of org.apache.activemq.artemis.utils.ActiveMQThreadFactory in project activemq-artemis by apache.

the class JournalImpl method start.

@Override
public synchronized void start() {
    if (state != JournalState.STOPPED) {
        throw new IllegalStateException("Journal " + this + " is not stopped, state is " + state);
    }
    if (providedIOThreadPool == null) {
        ThreadFactory factory = AccessController.doPrivileged(new PrivilegedAction<ThreadFactory>() {

            @Override
            public ThreadFactory run() {
                return new ActiveMQThreadFactory("ArtemisIOThread", true, JournalImpl.class.getClassLoader());
            }
        });
        threadPool = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue(), factory);
        ioExecutorFactory = new OrderedExecutorFactory(threadPool);
    } else {
        ioExecutorFactory = providedIOThreadPool;
    }
    filesExecutor = ioExecutorFactory.getExecutor();
    compactorExecutor = ioExecutorFactory.getExecutor();
    appendExecutor = ioExecutorFactory.getExecutor();
    filesRepository.setExecutor(filesExecutor);
    fileFactory.start();
    setJournalState(JournalState.STARTED);
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) ActiveMQThreadFactory(org.apache.activemq.artemis.utils.ActiveMQThreadFactory) OrderedExecutorFactory(org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory) SynchronousQueue(java.util.concurrent.SynchronousQueue) ActiveMQThreadFactory(org.apache.activemq.artemis.utils.ActiveMQThreadFactory) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Example 8 with ActiveMQThreadFactory

use of org.apache.activemq.artemis.utils.ActiveMQThreadFactory in project activemq-artemis by apache.

the class ActiveMQServerImpl method initializeExecutorServices.

/**
 * Sets up ActiveMQ Artemis Executor Services.
 */
private void initializeExecutorServices() {
    /* We check to see if a Thread Pool is supplied in the InjectedObjectRegistry.  If so we created a new Ordered
       * Executor based on the provided Thread pool.  Otherwise we create a new ThreadPool.
       */
    if (serviceRegistry.getExecutorService() == null) {
        ThreadFactory tFactory = AccessController.doPrivileged(new PrivilegedAction<ThreadFactory>() {

            @Override
            public ThreadFactory run() {
                return new ActiveMQThreadFactory("ActiveMQ-server-" + this.toString(), false, ClientSessionFactoryImpl.class.getClassLoader());
            }
        });
        if (configuration.getThreadPoolMaxSize() == -1) {
            threadPool = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), tFactory);
        } else {
            threadPool = new ActiveMQThreadPoolExecutor(0, configuration.getThreadPoolMaxSize(), 60L, TimeUnit.SECONDS, tFactory);
        }
    } else {
        threadPool = serviceRegistry.getExecutorService();
        this.threadPoolSupplied = true;
    }
    this.executorFactory = new OrderedExecutorFactory(threadPool);
    if (serviceRegistry.getIOExecutorService() != null) {
        this.ioExecutorFactory = new OrderedExecutorFactory(serviceRegistry.getIOExecutorService());
    } else {
        ThreadFactory tFactory = AccessController.doPrivileged(new PrivilegedAction<ThreadFactory>() {

            @Override
            public ThreadFactory run() {
                return new ActiveMQThreadFactory("ActiveMQ-IO-server-" + this.toString(), false, ClientSessionFactoryImpl.class.getClassLoader());
            }
        });
        this.ioExecutorPool = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), tFactory);
        this.ioExecutorFactory = new OrderedExecutorFactory(ioExecutorPool);
    }
    /* We check to see if a Scheduled Executor Service is provided in the InjectedObjectRegistry.  If so we use this
       * Scheduled ExecutorService otherwise we create a new one.
       */
    if (serviceRegistry.getScheduledExecutorService() == null) {
        ThreadFactory tFactory = AccessController.doPrivileged(new PrivilegedAction<ThreadFactory>() {

            @Override
            public ThreadFactory run() {
                return new ActiveMQThreadFactory("ActiveMQ-scheduled-threads", false, ClientSessionFactoryImpl.class.getClassLoader());
            }
        });
        scheduledPool = new ScheduledThreadPoolExecutor(configuration.getScheduledThreadPoolMaxSize(), tFactory);
    } else {
        this.scheduledPoolSupplied = true;
        this.scheduledPool = serviceRegistry.getScheduledExecutorService();
    }
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) ActiveMQThreadFactory(org.apache.activemq.artemis.utils.ActiveMQThreadFactory) OrderedExecutorFactory(org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) SynchronousQueue(java.util.concurrent.SynchronousQueue) ActiveMQThreadFactory(org.apache.activemq.artemis.utils.ActiveMQThreadFactory) ActiveMQThreadPoolExecutor(org.apache.activemq.artemis.utils.ActiveMQThreadPoolExecutor) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) ActiveMQThreadPoolExecutor(org.apache.activemq.artemis.utils.ActiveMQThreadPoolExecutor)

Aggregations

ActiveMQThreadFactory (org.apache.activemq.artemis.utils.ActiveMQThreadFactory)8 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)4 ThreadFactory (java.util.concurrent.ThreadFactory)4 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)3 OrderedExecutorFactory (org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory)3 SynchronousQueue (java.util.concurrent.SynchronousQueue)2 ActiveMQThreadPoolExecutor (org.apache.activemq.artemis.utils.ActiveMQThreadPoolExecutor)2 Before (org.junit.Before)2 ServerBootstrap (io.netty.bootstrap.ServerBootstrap)1 Channel (io.netty.channel.Channel)1 ChannelInitializer (io.netty.channel.ChannelInitializer)1 ChannelPipeline (io.netty.channel.ChannelPipeline)1 DefaultEventLoopGroup (io.netty.channel.DefaultEventLoopGroup)1 ServerChannel (io.netty.channel.ServerChannel)1 WriteBufferWaterMark (io.netty.channel.WriteBufferWaterMark)1 EpollEventLoopGroup (io.netty.channel.epoll.EpollEventLoopGroup)1 EpollServerSocketChannel (io.netty.channel.epoll.EpollServerSocketChannel)1 DefaultChannelGroup (io.netty.channel.group.DefaultChannelGroup)1 KQueueEventLoopGroup (io.netty.channel.kqueue.KQueueEventLoopGroup)1 KQueueServerSocketChannel (io.netty.channel.kqueue.KQueueServerSocketChannel)1