use of org.apache.activemq.artemis.core.persistence.GroupingInfo in project activemq-artemis by apache.
the class ActiveMQServerImpl method loadJournals.
private JournalLoadInformation[] loadJournals() throws Exception {
JournalLoader journalLoader = activation.createJournalLoader(postOffice, pagingManager, storageManager, queueFactory, nodeManager, managementService, groupingHandler, configuration, parentServer);
JournalLoadInformation[] journalInfo = new JournalLoadInformation[2];
List<QueueBindingInfo> queueBindingInfos = new ArrayList<>();
List<GroupingInfo> groupingInfos = new ArrayList<>();
List<AddressBindingInfo> addressBindingInfos = new ArrayList<>();
journalInfo[0] = storageManager.loadBindingJournal(queueBindingInfos, groupingInfos, addressBindingInfos);
recoverStoredConfigs();
Map<Long, AddressBindingInfo> addressBindingInfosMap = new HashMap<>();
journalLoader.initAddresses(addressBindingInfosMap, addressBindingInfos);
Map<Long, QueueBindingInfo> queueBindingInfosMap = new HashMap<>();
journalLoader.initQueues(queueBindingInfosMap, queueBindingInfos);
journalLoader.handleGroupingBindings(groupingInfos);
Map<SimpleString, List<Pair<byte[], Long>>> duplicateIDMap = new HashMap<>();
HashSet<Pair<Long, Long>> pendingLargeMessages = new HashSet<>();
List<PageCountPending> pendingNonTXPageCounter = new LinkedList<>();
journalInfo[1] = storageManager.loadMessageJournal(postOffice, pagingManager, resourceManager, queueBindingInfosMap, duplicateIDMap, pendingLargeMessages, pendingNonTXPageCounter, journalLoader);
journalLoader.handleDuplicateIds(duplicateIDMap);
for (Pair<Long, Long> msgToDelete : pendingLargeMessages) {
ActiveMQServerLogger.LOGGER.deletingPendingMessage(msgToDelete);
LargeServerMessage msg = storageManager.createLargeMessage();
msg.setMessageID(msgToDelete.getB());
msg.setPendingRecordID(msgToDelete.getA());
msg.setDurable(true);
msg.deleteFile();
}
if (pendingNonTXPageCounter.size() != 0) {
try {
journalLoader.recoverPendingPageCounters(pendingNonTXPageCounter);
} catch (Throwable e) {
ActiveMQServerLogger.LOGGER.errorRecoveringPageCounter(e);
}
}
journalLoader.cleanUp();
return journalInfo;
}
use of org.apache.activemq.artemis.core.persistence.GroupingInfo in project activemq-artemis by apache.
the class DeleteMessagesOnStartupTest method testDeleteMessagesOnStartup.
@Test
public void testDeleteMessagesOnStartup() throws Exception {
createStorage();
Queue theQueue = new FakeQueue(new SimpleString(""));
HashMap<Long, Queue> queues = new HashMap<>();
queues.put(100L, theQueue);
Message msg = new CoreMessage(1, 100);
journal.storeMessage(msg);
for (int i = 2; i < 100; i++) {
journal.storeMessage(new CoreMessage(i, 100));
}
journal.storeReference(100, 1, true);
journal.stop();
journal.start();
journal.loadBindingJournal(new ArrayList<QueueBindingInfo>(), new ArrayList<GroupingInfo>(), new ArrayList<AddressBindingInfo>());
FakePostOffice postOffice = new FakePostOffice();
journal.loadMessageJournal(postOffice, null, null, null, null, null, null, new PostOfficeJournalLoader(postOffice, null, journal, null, null, null, null, null, queues));
Assert.assertEquals(98, deletedMessage.size());
for (Long messageID : deletedMessage) {
Assert.assertTrue("messageID = " + messageID, messageID.longValue() >= 2 && messageID <= 99);
}
}
use of org.apache.activemq.artemis.core.persistence.GroupingInfo in project activemq-artemis by apache.
the class StorageManagerTestBase method createStorage.
/**
* @throws Exception
*/
protected void createStorage() throws Exception {
if (storeType == StoreConfiguration.StoreType.DATABASE) {
journal = createJDBCJournalStorageManager(createDefaultJDBCConfig(true));
} else {
journal = createJournalStorageManager(createDefaultInVMConfig());
}
journal.start();
journal.loadBindingJournal(new ArrayList<QueueBindingInfo>(), new ArrayList<GroupingInfo>(), new ArrayList<AddressBindingInfo>());
journal.loadMessageJournal(new FakePostOffice(), null, null, null, null, null, null, new FakeJournalLoader());
}
use of org.apache.activemq.artemis.core.persistence.GroupingInfo in project activemq-artemis by apache.
the class DuplicateDetectionUnitTest method testReloadDuplication.
// Public --------------------------------------------------------
@Test
public void testReloadDuplication() throws Exception {
JournalStorageManager journal = null;
try {
clearDataRecreateServerDirs();
SimpleString ADDRESS = new SimpleString("address");
Configuration configuration = createDefaultInVMConfig();
PostOffice postOffice = new FakePostOffice();
ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(ActiveMQDefaultConfiguration.getDefaultScheduledThreadPoolMaxSize(), ActiveMQThreadFactory.defaultThreadFactory());
journal = new JournalStorageManager(configuration, EmptyCriticalAnalyzer.getInstance(), factory, factory);
journal.start();
journal.loadBindingJournal(new ArrayList<QueueBindingInfo>(), new ArrayList<GroupingInfo>(), new ArrayList<AddressBindingInfo>());
HashMap<SimpleString, List<Pair<byte[], Long>>> mapDups = new HashMap<>();
FakePagingManager pagingManager = new FakePagingManager();
journal.loadMessageJournal(postOffice, pagingManager, new ResourceManagerImpl(0, 0, scheduledThreadPool), null, mapDups, null, null, new PostOfficeJournalLoader(postOffice, pagingManager, null, null, null, null, null, null));
Assert.assertEquals(0, mapDups.size());
DuplicateIDCacheImpl cacheID = new DuplicateIDCacheImpl(ADDRESS, 10, journal, true);
for (int i = 0; i < 100; i++) {
cacheID.addToCache(RandomUtil.randomBytes());
}
journal.stop();
journal = new JournalStorageManager(configuration, EmptyCriticalAnalyzer.getInstance(), factory, factory);
journal.start();
journal.loadBindingJournal(new ArrayList<QueueBindingInfo>(), new ArrayList<GroupingInfo>(), new ArrayList<AddressBindingInfo>());
journal.loadMessageJournal(postOffice, pagingManager, new ResourceManagerImpl(0, 0, scheduledThreadPool), null, mapDups, null, null, new PostOfficeJournalLoader(postOffice, pagingManager, null, null, null, null, null, null));
Assert.assertEquals(1, mapDups.size());
List<Pair<byte[], Long>> values = mapDups.get(ADDRESS);
Assert.assertEquals(10, values.size());
cacheID = new DuplicateIDCacheImpl(ADDRESS, 10, journal, true);
cacheID.load(values);
for (int i = 0; i < 100; i++) {
cacheID.addToCache(RandomUtil.randomBytes(), null);
}
journal.stop();
mapDups.clear();
journal = new JournalStorageManager(configuration, EmptyCriticalAnalyzer.getInstance(), factory, factory);
journal.start();
journal.loadBindingJournal(new ArrayList<QueueBindingInfo>(), new ArrayList<GroupingInfo>(), new ArrayList<AddressBindingInfo>());
journal.loadMessageJournal(postOffice, pagingManager, new ResourceManagerImpl(0, 0, scheduledThreadPool), null, mapDups, null, null, new PostOfficeJournalLoader(postOffice, pagingManager, null, null, null, null, null, null));
Assert.assertEquals(1, mapDups.size());
values = mapDups.get(ADDRESS);
Assert.assertEquals(10, values.size());
scheduledThreadPool.shutdown();
} finally {
if (journal != null) {
try {
journal.stop();
} catch (Throwable ignored) {
}
}
}
}
use of org.apache.activemq.artemis.core.persistence.GroupingInfo in project activemq-artemis by apache.
the class RestartSMTest method testRestartStorageManager.
@Test
public void testRestartStorageManager() throws Exception {
File testdir = new File(getTestDir());
deleteDirectory(testdir);
PostOffice postOffice = new FakePostOffice();
final JournalStorageManager journal = new JournalStorageManager(createDefaultInVMConfig(), EmptyCriticalAnalyzer.getInstance(), execFactory, execFactory);
try {
journal.start();
List<QueueBindingInfo> queueBindingInfos = new ArrayList<>();
journal.loadBindingJournal(queueBindingInfos, new ArrayList<GroupingInfo>(), new ArrayList<AddressBindingInfo>());
journal.loadMessageJournal(postOffice, null, null, null, null, null, null, new FakeJournalLoader());
journal.stop();
deleteDirectory(testdir);
journal.start();
journal.loadMessageJournal(postOffice, null, null, null, null, null, null, new FakeJournalLoader());
queueBindingInfos = new ArrayList<>();
journal.loadBindingJournal(queueBindingInfos, new ArrayList<GroupingInfo>(), new ArrayList<AddressBindingInfo>());
journal.start();
} finally {
try {
journal.stop();
} catch (Exception ex) {
RestartSMTest.log.warn(ex.getMessage(), ex);
}
}
}
Aggregations