Search in sources :

Example 1 with OrderedExecutorFactory

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

the class DBOption method initializeJournal.

protected void initializeJournal(Configuration configuration) throws Exception {
    this.config = configuration;
    executor = Executors.newFixedThreadPool(5, ActiveMQThreadFactory.defaultThreadFactory());
    executorFactory = new OrderedExecutorFactory(executor);
    scheduledExecutorService = new ScheduledThreadPoolExecutor(configuration.getScheduledThreadPoolMaxSize(), new ThreadFactory() {

        @Override
        public Thread newThread(Runnable r) {
            return new Thread(r);
        }
    });
    HierarchicalRepository<AddressSettings> addressSettingsRepository = new HierarchicalObjectRepository<>(config.getWildcardConfiguration());
    addressSettingsRepository.setDefault(new AddressSettings());
    if (configuration.isJDBC()) {
        storageManager = new JDBCJournalStorageManager(config, null, scheduledExecutorService, executorFactory, executorFactory, null);
        PagingStoreFactory pageStoreFactory = new PagingStoreFactoryDatabase((DatabaseStorageConfiguration) configuration.getStoreConfiguration(), storageManager, 1000L, scheduledExecutorService, executorFactory, false, null);
        pagingmanager = new PagingManagerImpl(pageStoreFactory, addressSettingsRepository);
    } else {
        storageManager = new JournalStorageManager(config, EmptyCriticalAnalyzer.getInstance(), executorFactory, executorFactory);
        PagingStoreFactory pageStoreFactory = new PagingStoreFactoryNIO(storageManager, config.getPagingLocation(), 1000L, scheduledExecutorService, executorFactory, true, null);
        pagingmanager = new PagingManagerImpl(pageStoreFactory, addressSettingsRepository);
    }
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) ActiveMQThreadFactory(org.apache.activemq.artemis.utils.ActiveMQThreadFactory) AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) JDBCJournalStorageManager(org.apache.activemq.artemis.core.persistence.impl.journal.JDBCJournalStorageManager) OrderedExecutorFactory(org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) PagingStoreFactoryDatabase(org.apache.activemq.artemis.core.paging.impl.PagingStoreFactoryDatabase) HierarchicalObjectRepository(org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository) JDBCJournalStorageManager(org.apache.activemq.artemis.core.persistence.impl.journal.JDBCJournalStorageManager) JournalStorageManager(org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager) PagingStoreFactoryNIO(org.apache.activemq.artemis.core.paging.impl.PagingStoreFactoryNIO) PagingStoreFactory(org.apache.activemq.artemis.core.paging.PagingStoreFactory) PagingManagerImpl(org.apache.activemq.artemis.core.paging.impl.PagingManagerImpl)

Example 2 with OrderedExecutorFactory

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

the class JournalCleanupCompactStressTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    threadPool = Executors.newFixedThreadPool(20, tFactory);
    executorFactory = new OrderedExecutorFactory(threadPool);
    testExecutor = executorFactory.getExecutor();
    maxRecords = new Semaphore(MAX_WRITES);
    errors.set(0);
    File dir = new File(getTemporaryDir());
    dir.mkdirs();
    SequentialFileFactory factory;
    int maxAIO;
    if (LibaioContext.isLoaded()) {
        factory = new AIOSequentialFileFactory(dir, 10);
        maxAIO = ActiveMQDefaultConfiguration.getDefaultJournalMaxIoAio();
    } else {
        factory = new NIOSequentialFileFactory(dir, true, 1);
        maxAIO = ActiveMQDefaultConfiguration.getDefaultJournalMaxIoNio();
    }
    journal = new JournalImpl(50 * 1024, 20, 20, 50, ActiveMQDefaultConfiguration.getDefaultJournalCompactPercentage(), factory, "activemq-data", "amq", maxAIO) {

        @Override
        protected void onCompactLockingTheJournal() throws Exception {
        }

        @Override
        protected void onCompactStart() throws Exception {
            testExecutor.execute(new Runnable() {

                @Override
                public void run() {
                    try {
                        // System.out.println("OnCompactStart enter");
                        if (running) {
                            long id = idGen.generateID();
                            journal.appendAddRecord(id, (byte) 0, new byte[] { 1, 2, 3 }, false);
                            journal.forceMoveNextFile();
                            journal.appendDeleteRecord(id, id == 20);
                        }
                    // System.out.println("OnCompactStart leave");
                    } catch (Exception e) {
                        e.printStackTrace();
                        errors.incrementAndGet();
                    }
                }
            });
        }
    };
    journal.start();
    journal.loadInternalOnly();
}
Also used : OrderedExecutorFactory(org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory) AIOSequentialFileFactory(org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory) Semaphore(java.util.concurrent.Semaphore) File(java.io.File) SequentialFileFactory(org.apache.activemq.artemis.core.io.SequentialFileFactory) NIOSequentialFileFactory(org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory) AIOSequentialFileFactory(org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory) NIOSequentialFileFactory(org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory) JournalImpl(org.apache.activemq.artemis.core.journal.impl.JournalImpl) Before(org.junit.Before)

Example 3 with OrderedExecutorFactory

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

the class DuplicateDetectionUnitTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    executor = Executors.newFixedThreadPool(10, ActiveMQThreadFactory.defaultThreadFactory());
    factory = new OrderedExecutorFactory(executor);
}
Also used : OrderedExecutorFactory(org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory) Before(org.junit.Before)

Example 4 with OrderedExecutorFactory

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

the class FileMoveManagerTest method testMoveOverPaging.

@Test
public void testMoveOverPaging() throws Exception {
    AssertionLoggerHandler.startCapture();
    ExecutorService threadPool = Executors.newCachedThreadPool();
    try {
        manager.setMaxFolders(3);
        for (int i = 1; i <= 10; i++) {
            HierarchicalRepository<AddressSettings> addressSettings = new HierarchicalObjectRepository<>();
            AddressSettings settings = new AddressSettings();
            settings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE);
            addressSettings.setDefault(settings);
            final StorageManager storageManager = new NullStorageManager();
            PagingStoreFactoryNIO storeFactory = new PagingStoreFactoryNIO(storageManager, dataLocation, 100, null, new OrderedExecutorFactory(threadPool), true, null);
            PagingManagerImpl managerImpl = new PagingManagerImpl(storeFactory, addressSettings, -1);
            managerImpl.start();
            PagingStore store = managerImpl.getPageStore(new SimpleString("simple-test"));
            store.startPaging();
            store.stop();
            managerImpl.stop();
            manager.doMove();
            Assert.assertEquals(Math.min(i, manager.getMaxFolders()), manager.getNumberOfFolders());
        }
        Assert.assertFalse("The loggers are complaining about address.txt", AssertionLoggerHandler.findText("address.txt"));
    } finally {
        AssertionLoggerHandler.stopCapture();
        threadPool.shutdown();
    }
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) NullStorageManager(org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager) OrderedExecutorFactory(org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory) PagingStoreFactoryNIO(org.apache.activemq.artemis.core.paging.impl.PagingStoreFactoryNIO) ExecutorService(java.util.concurrent.ExecutorService) StorageManager(org.apache.activemq.artemis.core.persistence.StorageManager) NullStorageManager(org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) PagingManagerImpl(org.apache.activemq.artemis.core.paging.impl.PagingManagerImpl) PagingStore(org.apache.activemq.artemis.core.paging.PagingStore) HierarchicalObjectRepository(org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository) Test(org.junit.Test)

Example 5 with OrderedExecutorFactory

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

the class ActiveMQTestBase method getOrderedExecutor.

protected final OrderedExecutorFactory getOrderedExecutor() {
    final ExecutorService executor = Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory());
    executorSet.add(executor);
    return new OrderedExecutorFactory(executor);
}
Also used : OrderedExecutorFactory(org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory) ExecutorService(java.util.concurrent.ExecutorService)

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