Search in sources :

Example 1 with PagedMessageImpl

use of org.apache.activemq.artemis.core.paging.impl.PagedMessageImpl in project activemq-artemis by apache.

the class ReplicationPageWriteMessage method decodeRest.

@Override
public void decodeRest(final ActiveMQBuffer buffer) {
    pageNumber = buffer.readInt();
    pagedMessage = new PagedMessageImpl(null);
    pagedMessage.decode(buffer);
}
Also used : PagedMessageImpl(org.apache.activemq.artemis.core.paging.impl.PagedMessageImpl)

Example 2 with PagedMessageImpl

use of org.apache.activemq.artemis.core.paging.impl.PagedMessageImpl in project activemq-artemis by apache.

the class PageTest method addPageElements.

/**
 * @param simpleDestination
 * @param page
 * @param numberOfElements
 * @return
 * @throws Exception
 */
protected void addPageElements(final SimpleString simpleDestination, final Page page, final int numberOfElements) throws Exception {
    int initialNumberOfMessages = page.getNumberOfMessages();
    for (int i = 0; i < numberOfElements; i++) {
        ICoreMessage msg = new CoreMessage().initBuffer(100);
        for (int j = 0; j < 10; j++) {
            msg.getBodyBuffer().writeByte((byte) 'b');
        }
        msg.setAddress(simpleDestination);
        page.write(new PagedMessageImpl(msg, new long[0]));
        Assert.assertEquals(initialNumberOfMessages + i + 1, page.getNumberOfMessages());
    }
}
Also used : ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) PagedMessageImpl(org.apache.activemq.artemis.core.paging.impl.PagedMessageImpl) CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage) ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage)

Example 3 with PagedMessageImpl

use of org.apache.activemq.artemis.core.paging.impl.PagedMessageImpl 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());
}
Also used : PagedMessage(org.apache.activemq.artemis.core.paging.PagedMessage) PagingManager(org.apache.activemq.artemis.core.paging.PagingManager) PagedMessageImpl(org.apache.activemq.artemis.core.paging.impl.PagedMessageImpl) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ReplicatedJournal(org.apache.activemq.artemis.core.replication.ReplicatedJournal) Journal(org.apache.activemq.artemis.core.journal.Journal) ReplicatedJournal(org.apache.activemq.artemis.core.replication.ReplicatedJournal) PagingStore(org.apache.activemq.artemis.core.paging.PagingStore) CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage) JournalStorageManager(org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager) ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer) Test(org.junit.Test)

Aggregations

PagedMessageImpl (org.apache.activemq.artemis.core.paging.impl.PagedMessageImpl)3 CoreMessage (org.apache.activemq.artemis.core.message.impl.CoreMessage)2 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)1 ICoreMessage (org.apache.activemq.artemis.api.core.ICoreMessage)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 Journal (org.apache.activemq.artemis.core.journal.Journal)1 PagedMessage (org.apache.activemq.artemis.core.paging.PagedMessage)1 PagingManager (org.apache.activemq.artemis.core.paging.PagingManager)1 PagingStore (org.apache.activemq.artemis.core.paging.PagingStore)1 JournalStorageManager (org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager)1 ReplicatedJournal (org.apache.activemq.artemis.core.replication.ReplicatedJournal)1 Test (org.junit.Test)1