Search in sources :

Example 6 with OrderedExecutorFactory

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

the class NettyFailoverTest method createNodeManager.

@Override
protected NodeManager createNodeManager() throws Exception {
    switch(nodeManagerType) {
        case InVM:
            return new InVMNodeManager(false);
        case Jdbc:
            final ThreadFactory daemonThreadFactory = t -> {
                final Thread th = new Thread(t);
                th.setDaemon(true);
                return th;
            };
            final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(daemonThreadFactory);
            scheduledExecutorServices.add(scheduledExecutorService);
            final ExecutorService executor = Executors.newFixedThreadPool(2, daemonThreadFactory);
            executors.add(executor);
            final DatabaseStorageConfiguration dbConf = createDefaultDatabaseStorageConfiguration();
            final ExecutorFactory executorFactory = new OrderedExecutorFactory(executor);
            return JdbcNodeManager.with(dbConf, scheduledExecutorService, executorFactory, (code, message, file) -> {
                code.printStackTrace();
                Assert.fail(message);
            });
        default:
            throw new AssertionError("enum type not supported!");
    }
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) Arrays(java.util.Arrays) SameProcessActiveMQServer(org.apache.activemq.artemis.tests.integration.cluster.util.SameProcessActiveMQServer) OrderedExecutorFactory(org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory) ClientSessionFactoryInternal(org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal) DatabaseStorageConfiguration(org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration) TransportConstants(org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) ClientConsumer(org.apache.activemq.artemis.api.core.client.ClientConsumer) ArrayList(java.util.ArrayList) ActiveMQClient(org.apache.activemq.artemis.api.core.client.ActiveMQClient) ServerLocator(org.apache.activemq.artemis.api.core.client.ServerLocator) Is(org.hamcrest.core.Is) TestableServer(org.apache.activemq.artemis.tests.integration.cluster.util.TestableServer) Map(java.util.Map) After(org.junit.After) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) InVMNodeManager(org.apache.activemq.artemis.core.server.impl.InVMNodeManager) Assume(org.junit.Assume) NodeManager(org.apache.activemq.artemis.core.server.NodeManager) ThreadFactory(java.util.concurrent.ThreadFactory) ExecutorService(java.util.concurrent.ExecutorService) Parameterized(org.junit.runners.Parameterized) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) Test(org.junit.Test) ExecutorFactory(org.apache.activemq.artemis.utils.ExecutorFactory) Executors(java.util.concurrent.Executors) List(java.util.List) ClientProducer(org.apache.activemq.artemis.api.core.client.ClientProducer) JdbcNodeManager(org.apache.activemq.artemis.core.server.impl.jdbc.JdbcNodeManager) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ThreadLeakCheckRule(org.apache.activemq.artemis.utils.ThreadLeakCheckRule) Assert(org.junit.Assert) DatabaseStorageConfiguration(org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration) ThreadFactory(java.util.concurrent.ThreadFactory) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) OrderedExecutorFactory(org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory) InVMNodeManager(org.apache.activemq.artemis.core.server.impl.InVMNodeManager) OrderedExecutorFactory(org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory) ExecutorFactory(org.apache.activemq.artemis.utils.ExecutorFactory) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ExecutorService(java.util.concurrent.ExecutorService)

Example 7 with OrderedExecutorFactory

use of org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory 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 8 with OrderedExecutorFactory

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

the class JournalFileSizeTest method testIncorrectFileSizeHigher.

@Test
public void testIncorrectFileSizeHigher() {
    ConfigurationImpl config = new ConfigurationImpl();
    int origFileSize = config.getJournalFileSize();
    config.setJournalFileSize(origFileSize + (align / 2 + 1));
    JournalStorageManager manager = new JournalStorageManager(config, EmptyCriticalAnalyzer.getInstance(), new OrderedExecutorFactory(null), new OrderedExecutorFactory(null));
    int fileSize = manager.getMessageJournal().getFileSize();
    Assert.assertEquals(origFileSize + align, fileSize);
}
Also used : OrderedExecutorFactory(org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl) JournalStorageManager(org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager) Test(org.junit.Test)

Example 9 with OrderedExecutorFactory

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

the class JournalFileSizeTest method testIncorrectFileSizeHalf.

@Test
public void testIncorrectFileSizeHalf() {
    ConfigurationImpl config = new ConfigurationImpl();
    int origFileSize = config.getJournalFileSize();
    config.setJournalFileSize(origFileSize + (align / 2));
    JournalStorageManager manager = new JournalStorageManager(config, EmptyCriticalAnalyzer.getInstance(), new OrderedExecutorFactory(null), new OrderedExecutorFactory(null));
    int fileSize = manager.getMessageJournal().getFileSize();
    Assert.assertEquals(origFileSize + align, fileSize);
}
Also used : OrderedExecutorFactory(org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl) JournalStorageManager(org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager) Test(org.junit.Test)

Example 10 with OrderedExecutorFactory

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

the class JournalFileSizeTest method testIncorrectFileSizeLower.

@Test
public void testIncorrectFileSizeLower() {
    ConfigurationImpl config = new ConfigurationImpl();
    int origFileSize = config.getJournalFileSize();
    config.setJournalFileSize(origFileSize + (align / 2 - 1));
    JournalStorageManager manager = new JournalStorageManager(config, EmptyCriticalAnalyzer.getInstance(), new OrderedExecutorFactory(null), new OrderedExecutorFactory(null));
    int fileSize = manager.getMessageJournal().getFileSize();
    Assert.assertEquals(origFileSize, fileSize);
}
Also used : OrderedExecutorFactory(org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl) JournalStorageManager(org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager) Test(org.junit.Test)

Aggregations

OrderedExecutorFactory (org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory)13 Test (org.junit.Test)6 JournalStorageManager (org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager)5 ExecutorService (java.util.concurrent.ExecutorService)4 ThreadFactory (java.util.concurrent.ThreadFactory)4 ActiveMQThreadFactory (org.apache.activemq.artemis.utils.ActiveMQThreadFactory)4 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)3 ConfigurationImpl (org.apache.activemq.artemis.core.config.impl.ConfigurationImpl)3 SynchronousQueue (java.util.concurrent.SynchronousQueue)2 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)2 Configuration (org.apache.activemq.artemis.core.config.Configuration)2 JournalImpl (org.apache.activemq.artemis.core.journal.impl.JournalImpl)2 PagingManagerImpl (org.apache.activemq.artemis.core.paging.impl.PagingManagerImpl)2 PagingStoreFactoryNIO (org.apache.activemq.artemis.core.paging.impl.PagingStoreFactoryNIO)2 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)2 HierarchicalObjectRepository (org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository)2 Before (org.junit.Before)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1