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