Search in sources :

Example 1 with JournalStorageManager

use of org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager 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 JournalStorageManager

use of org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager in project activemq-artemis by apache.

the class ActiveMQServerImpl method createStorageManager.

/**
 * This method is protected as it may be used as a hook for creating a custom storage manager (on tests for instance)
 */
protected StorageManager createStorageManager() {
    if (configuration.isPersistenceEnabled()) {
        if (configuration.getStoreConfiguration() != null && configuration.getStoreConfiguration().getStoreType() == StoreConfiguration.StoreType.DATABASE) {
            JDBCJournalStorageManager journal = new JDBCJournalStorageManager(configuration, getCriticalAnalyzer(), getScheduledPool(), executorFactory, ioExecutorFactory, shutdownOnCriticalIO);
            this.getCriticalAnalyzer().add(journal);
            return journal;
        } else {
            // Default to File Based Storage Manager, (Legacy default configuration).
            JournalStorageManager journal = new JournalStorageManager(configuration, getCriticalAnalyzer(), executorFactory, scheduledPool, ioExecutorFactory, shutdownOnCriticalIO);
            this.getCriticalAnalyzer().add(journal);
            return journal;
        }
    }
    return new NullStorageManager();
}
Also used : JDBCJournalStorageManager(org.apache.activemq.artemis.core.persistence.impl.journal.JDBCJournalStorageManager) NullStorageManager(org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager) JDBCJournalStorageManager(org.apache.activemq.artemis.core.persistence.impl.journal.JDBCJournalStorageManager) JournalStorageManager(org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager)

Example 3 with JournalStorageManager

use of org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager in project activemq-artemis by apache.

the class ShutdownServerTest method testShutdownServer.

@Test
public void testShutdownServer() throws Throwable {
    ClientSessionFactory sf = createSessionFactory(locator);
    ClientSession session = sf.createSession(false, true, true, false);
    session.createQueue(QUEUE, QUEUE, null, true);
    ClientConsumer consumer = session.createConsumer(QUEUE);
    ClientProducer producer = session.createProducer(QUEUE);
    ClientMessage message = session.createMessage(Message.TEXT_TYPE, true, 0, System.currentTimeMillis(), (byte) 4);
    message.getBodyBuffer().writeString("hi");
    message.putStringProperty("hello", "elo");
    producer.send(message);
    ActiveMQServerImpl impl = (ActiveMQServerImpl) server;
    JournalStorageManager journal = (JournalStorageManager) impl.getStorageManager();
    JDBCJournalImpl journalimpl = (JDBCJournalImpl) journal.getMessageJournal();
    journalimpl.handleException(null, new Exception("failure"));
    Wait.waitFor(() -> !server.isStarted());
    Assert.assertFalse(server.isStarted());
}
Also used : ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) JDBCJournalImpl(org.apache.activemq.artemis.jdbc.store.journal.JDBCJournalImpl) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) ClientConsumer(org.apache.activemq.artemis.api.core.client.ClientConsumer) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) ClientProducer(org.apache.activemq.artemis.api.core.client.ClientProducer) JournalStorageManager(org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager) Test(org.junit.Test)

Example 4 with JournalStorageManager

use of org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager in project activemq-artemis by apache.

the class ShutdownOnCriticalIOErrorMoveNextTest method createServer.

ActiveMQServer createServer(String folder) throws Exception {
    final AtomicBoolean blocked = new AtomicBoolean(false);
    Configuration conf = createConfig(folder);
    ActiveMQSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), new SecurityConfiguration());
    conf.setPersistenceEnabled(true);
    ActiveMQServer server = new ActiveMQServerImpl(conf, securityManager) {

        @Override
        protected StorageManager createStorageManager() {
            JournalStorageManager storageManager = new JournalStorageManager(conf, getCriticalAnalyzer(), executorFactory, scheduledPool, ioExecutorFactory, shutdownOnCriticalIO) {

                @Override
                protected Journal createMessageJournal(Configuration config, IOCriticalErrorListener criticalErrorListener, int fileSize) {
                    return new JournalImpl(ioExecutorFactory, fileSize, config.getJournalMinFiles(), config.getJournalPoolFiles(), config.getJournalCompactMinFiles(), config.getJournalCompactPercentage(), config.getJournalFileOpenTimeout(), journalFF, "activemq-data", "amq", journalFF.getMaxIO(), 0, criticalErrorListener) {

                        @Override
                        protected void moveNextFile(boolean scheduleReclaim) throws Exception {
                            super.moveNextFile(scheduleReclaim);
                            if (blocked.get()) {
                                throw new IllegalStateException("forcibly down");
                            }
                        }
                    };
                }

                @Override
                public void storeMessage(Message message) throws Exception {
                    super.storeMessage(message);
                    blocked.set(true);
                }
            };
            this.getCriticalAnalyzer().add(storageManager);
            return storageManager;
        }
    };
    return server;
}
Also used : IOCriticalErrorListener(org.apache.activemq.artemis.core.io.IOCriticalErrorListener) Configuration(org.apache.activemq.artemis.core.config.Configuration) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) Message(org.apache.activemq.artemis.api.core.Message) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) InVMLoginModule(org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) JournalStorageManager(org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) ActiveMQSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager) JournalImpl(org.apache.activemq.artemis.core.journal.impl.JournalImpl)

Example 5 with JournalStorageManager

use of org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager in project activemq-artemis by apache.

the class XmlImportExportTest method checkForLongs.

protected void checkForLongs() {
    if (forceLongs) {
        JournalStorageManager manager = (JournalStorageManager) server.getStorageManager();
        BatchingIDGenerator idGenerator = (BatchingIDGenerator) manager.getIDGenerator();
        idGenerator.forceNextID((Integer.MAX_VALUE) + 1L);
    }
}
Also used : BatchingIDGenerator(org.apache.activemq.artemis.core.persistence.impl.journal.BatchingIDGenerator) JournalStorageManager(org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager)

Aggregations

JournalStorageManager (org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager)19 Test (org.junit.Test)13 LinkedList (java.util.LinkedList)6 PreparedTransactionInfo (org.apache.activemq.artemis.core.journal.PreparedTransactionInfo)5 RecordInfo (org.apache.activemq.artemis.core.journal.RecordInfo)5 OrderedExecutorFactory (org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory)5 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)4 Configuration (org.apache.activemq.artemis.core.config.Configuration)4 CoreMessage (org.apache.activemq.artemis.core.message.impl.CoreMessage)4 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)4 List (java.util.List)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 ConfigurationImpl (org.apache.activemq.artemis.core.config.impl.ConfigurationImpl)3 JDBCJournalStorageManager (org.apache.activemq.artemis.core.persistence.impl.journal.JDBCJournalStorageManager)3 ArrayList (java.util.ArrayList)2 Message (org.apache.activemq.artemis.api.core.Message)2 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)2 SecurityConfiguration (org.apache.activemq.artemis.core.config.impl.SecurityConfiguration)2 TransactionFailureCallback (org.apache.activemq.artemis.core.journal.TransactionFailureCallback)2 JournalImpl (org.apache.activemq.artemis.core.journal.impl.JournalImpl)2