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);
}
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);
}
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();
}
}
Aggregations