use of org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager in project activemq-artemis by apache.
the class JournalPageCountSizeTest method testPageCursorCounterRecordSizeTX.
@Test
public void testPageCursorCounterRecordSizeTX() throws Exception {
long tx = server.getStorageManager().generateID();
server.getStorageManager().storePageCounterInc(tx, 1, 1, 1000);
server.getStorageManager().commit(tx);
server.getStorageManager().stop();
JournalStorageManager journalStorageManager = (JournalStorageManager) server.getStorageManager();
List<RecordInfo> committedRecords = new LinkedList<>();
List<PreparedTransactionInfo> preparedTransactions = new LinkedList<>();
try {
journalStorageManager.getMessageJournal().start();
journalStorageManager.getMessageJournal().load(committedRecords, preparedTransactions, transactionFailure);
ActiveMQBuffer buff = ActiveMQBuffers.wrappedBuffer(committedRecords.get(0).data);
PageCountRecordInc encoding = new PageCountRecordInc();
encoding.decode(buff);
Assert.assertEquals(1000, encoding.getPersistentSize());
} finally {
journalStorageManager.getMessageJournal().stop();
}
}
use of org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager in project activemq-artemis by apache.
the class ReplicationTest method testSendPackets.
@Test
public void testSendPackets() throws Exception {
setupServer(true);
JournalStorageManager storage = getStorage();
manager = liveServer.getReplicationManager();
waitForComponent(manager);
Journal replicatedJournal = new ReplicatedJournal((byte) 1, new FakeJournal(), manager);
replicatedJournal.appendPrepareRecord(1, new FakeData(), false);
replicatedJournal.appendAddRecord(1, (byte) 1, new FakeData(), false);
replicatedJournal.appendUpdateRecord(1, (byte) 2, new FakeData(), false);
replicatedJournal.appendDeleteRecord(1, false);
replicatedJournal.appendAddRecordTransactional(2, 2, (byte) 1, new FakeData());
replicatedJournal.appendUpdateRecordTransactional(2, 2, (byte) 2, new FakeData());
replicatedJournal.appendCommitRecord(2, false);
replicatedJournal.appendDeleteRecordTransactional(3, 4, new FakeData());
replicatedJournal.appendPrepareRecord(3, new FakeData(), false);
replicatedJournal.appendRollbackRecord(3, false);
blockOnReplication(storage, manager);
Assert.assertTrue("Expecting no active tokens:" + manager.getActiveTokens(), manager.getActiveTokens().isEmpty());
CoreMessage msg = new CoreMessage().initBuffer(1024).setMessageID(1);
SimpleString dummy = new SimpleString("dummy");
msg.setAddress(dummy);
replicatedJournal.appendAddRecordTransactional(23, 24, (byte) 1, new FakeData());
PagedMessage pgmsg = new PagedMessageImpl(msg, new long[0]);
manager.pageWrite(pgmsg, 1);
manager.pageWrite(pgmsg, 2);
manager.pageWrite(pgmsg, 3);
manager.pageWrite(pgmsg, 4);
blockOnReplication(storage, manager);
PagingManager pagingManager = createPageManager(backupServer.getStorageManager(), backupServer.getConfiguration(), backupServer.getExecutorFactory(), backupServer.getAddressSettingsRepository());
PagingStore store = pagingManager.getPageStore(dummy);
store.start();
Assert.assertEquals(4, store.getNumberOfPages());
store.stop();
manager.pageDeleted(dummy, 1);
manager.pageDeleted(dummy, 2);
manager.pageDeleted(dummy, 3);
manager.pageDeleted(dummy, 4);
manager.pageDeleted(dummy, 5);
manager.pageDeleted(dummy, 6);
blockOnReplication(storage, manager);
CoreMessage serverMsg = new CoreMessage();
serverMsg.setMessageID(500);
serverMsg.setAddress(new SimpleString("tttt"));
ActiveMQBuffer buffer = ActiveMQBuffers.dynamicBuffer(100);
serverMsg.encodeHeadersAndProperties(buffer.byteBuf());
manager.largeMessageBegin(500);
manager.largeMessageWrite(500, new byte[1024]);
manager.largeMessageDelete(Long.valueOf(500), storage);
blockOnReplication(storage, manager);
store.start();
Assert.assertEquals(0, store.getNumberOfPages());
}
use of org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager in project activemq-artemis by apache.
the class JournalFileSizeTest method testIncorrectFileSizeHigher.
@Test
public void testIncorrectFileSizeHigher() {
ConfigurationImpl config = new ConfigurationImpl();
int origFileSize = config.getJournalFileSize();
config.setJournalFileSize(origFileSize + (align / 2 + 1));
JournalStorageManager manager = new JournalStorageManager(config, EmptyCriticalAnalyzer.getInstance(), new OrderedExecutorFactory(null), new OrderedExecutorFactory(null));
int fileSize = manager.getMessageJournal().getFileSize();
Assert.assertEquals(origFileSize + align, fileSize);
}
use of org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager in project activemq-artemis by apache.
the class JournalFileSizeTest method testIncorrectFileSizeHalf.
@Test
public void testIncorrectFileSizeHalf() {
ConfigurationImpl config = new ConfigurationImpl();
int origFileSize = config.getJournalFileSize();
config.setJournalFileSize(origFileSize + (align / 2));
JournalStorageManager manager = new JournalStorageManager(config, EmptyCriticalAnalyzer.getInstance(), new OrderedExecutorFactory(null), new OrderedExecutorFactory(null));
int fileSize = manager.getMessageJournal().getFileSize();
Assert.assertEquals(origFileSize + align, fileSize);
}
use of org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager in project activemq-artemis by apache.
the class JournalFileSizeTest method testIncorrectFileSizeLower.
@Test
public void testIncorrectFileSizeLower() {
ConfigurationImpl config = new ConfigurationImpl();
int origFileSize = config.getJournalFileSize();
config.setJournalFileSize(origFileSize + (align / 2 - 1));
JournalStorageManager manager = new JournalStorageManager(config, EmptyCriticalAnalyzer.getInstance(), new OrderedExecutorFactory(null), new OrderedExecutorFactory(null));
int fileSize = manager.getMessageJournal().getFileSize();
Assert.assertEquals(origFileSize, fileSize);
}
Aggregations