Search in sources :

Example 1 with HierarchicalObjectRepository

use of org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository 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 HierarchicalObjectRepository

use of org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository 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 3 with HierarchicalObjectRepository

use of org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository in project activemq-artemis by apache.

the class RepositoryTest method testAddListener.

@Test
public void testAddListener() {
    HierarchicalRepository<String> repository = new HierarchicalObjectRepository<>();
    repository.addMatch("#", "1");
    repository.addMatch("B", "2");
    final AtomicInteger called = new AtomicInteger(0);
    repository.registerListener(new HierarchicalRepositoryChangeListener() {

        @Override
        public void onChange() {
            called.incrementAndGet();
        }
    });
    assertEquals(1, called.get());
    repository.disableListeners();
    repository.addMatch("C", "3");
    assertEquals(1, called.get());
    repository.enableListeners();
    assertEquals(2, called.get());
    repository.addMatch("D", "4");
    assertEquals(3, called.get());
    repository.removeMatch("D");
    assertEquals(4, called.get());
    repository.disableListeners();
    repository.removeMatch("C");
    assertEquals(4, called.get());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HierarchicalObjectRepository(org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository) Test(org.junit.Test)

Example 4 with HierarchicalObjectRepository

use of org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository in project activemq-artemis by apache.

the class RepositoryTest method testMatchingDocsCustomUnderscorDelimiter.

@Test
public void testMatchingDocsCustomUnderscorDelimiter() throws Throwable {
    WildcardConfiguration wildcardConfiguration = new WildcardConfiguration();
    wildcardConfiguration.setDelimiter('_');
    HierarchicalObjectRepository<String> repo = new HierarchicalObjectRepository<>(wildcardConfiguration);
    repo.addMatch("a_b_#", "ab#");
    repo.addMatch("a_b_d_#", "abd#");
    repo.addMatch("#", "root");
    Assert.assertEquals("ab#", repo.getMatch("a_b"));
    Assert.assertEquals("ab#", repo.getMatch("a_b_c"));
    Assert.assertEquals("abd#", repo.getMatch("a_b_d_lll"));
    Assert.assertEquals("root", repo.getMatch("z_z_z_z_z"));
    Assert.assertEquals("root", repo.getMatch("a_babc"));
    Assert.assertEquals("ab#", repo.getMatch("a_b_dabc"));
    Assert.assertEquals("abd#", repo.getMatch("a_b_d"));
}
Also used : WildcardConfiguration(org.apache.activemq.artemis.core.config.WildcardConfiguration) HierarchicalObjectRepository(org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository) Test(org.junit.Test)

Example 5 with HierarchicalObjectRepository

use of org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository in project activemq-artemis by apache.

the class RepositoryTest method testMatchingDocsCustomForwardSlashDelimiter.

@Test
public void testMatchingDocsCustomForwardSlashDelimiter() throws Throwable {
    WildcardConfiguration wildcardConfiguration = new WildcardConfiguration();
    wildcardConfiguration.setDelimiter('/');
    HierarchicalObjectRepository<String> repo = new HierarchicalObjectRepository<>(wildcardConfiguration);
    repo.addMatch("a/b/#", "ab#");
    repo.addMatch("a/b/d/#", "abd#");
    repo.addMatch("#", "root");
    Assert.assertEquals("ab#", repo.getMatch("a/b"));
    Assert.assertEquals("ab#", repo.getMatch("a/b/c"));
    Assert.assertEquals("abd#", repo.getMatch("a/b/d/lll"));
    Assert.assertEquals("root", repo.getMatch("z/z/z/z/z"));
    Assert.assertEquals("root", repo.getMatch("a/babc"));
    Assert.assertEquals("ab#", repo.getMatch("a/b/dabc"));
    Assert.assertEquals("abd#", repo.getMatch("a/b/d"));
}
Also used : WildcardConfiguration(org.apache.activemq.artemis.core.config.WildcardConfiguration) HierarchicalObjectRepository(org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository) Test(org.junit.Test)

Aggregations

HierarchicalObjectRepository (org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository)7 Test (org.junit.Test)5 PagingManagerImpl (org.apache.activemq.artemis.core.paging.impl.PagingManagerImpl)4 PagingStoreFactoryNIO (org.apache.activemq.artemis.core.paging.impl.PagingStoreFactoryNIO)4 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)4 StorageManager (org.apache.activemq.artemis.core.persistence.StorageManager)3 NullStorageManager (org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager)3 ExecutorService (java.util.concurrent.ExecutorService)2 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)2 WildcardConfiguration (org.apache.activemq.artemis.core.config.WildcardConfiguration)2 PagingStore (org.apache.activemq.artemis.core.paging.PagingStore)2 PagingStoreFactory (org.apache.activemq.artemis.core.paging.PagingStoreFactory)2 OrderedExecutorFactory (org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 ICoreMessage (org.apache.activemq.artemis.api.core.ICoreMessage)1 PagedMessage (org.apache.activemq.artemis.core.paging.PagedMessage)1 PagingManager (org.apache.activemq.artemis.core.paging.PagingManager)1