Search in sources :

Example 11 with Journal

use of org.apache.activemq.artemis.core.journal.Journal in project activemq-artemis by apache.

the class ReplicationEndpoint method handleAppendDelete.

/**
 * @param packet
 */
private void handleAppendDelete(final ReplicationDeleteMessage packet) throws Exception {
    Journal journalToUse = getJournal(packet.getJournalID());
    journalToUse.appendDeleteRecord(packet.getId(), noSync);
}
Also used : Journal(org.apache.activemq.artemis.core.journal.Journal) FileWrapperJournal(org.apache.activemq.artemis.core.journal.impl.FileWrapperJournal)

Example 12 with Journal

use of org.apache.activemq.artemis.core.journal.Journal in project activemq-artemis by apache.

the class ReplicationEndpoint method handleAppendDeleteTX.

/**
 * @param packet
 */
private void handleAppendDeleteTX(final ReplicationDeleteTXMessage packet) throws Exception {
    Journal journalToUse = getJournal(packet.getJournalID());
    journalToUse.appendDeleteRecordTransactional(packet.getTxId(), packet.getId(), packet.getRecordData());
}
Also used : Journal(org.apache.activemq.artemis.core.journal.Journal) FileWrapperJournal(org.apache.activemq.artemis.core.journal.impl.FileWrapperJournal)

Example 13 with Journal

use of org.apache.activemq.artemis.core.journal.Journal in project activemq-artemis by apache.

the class ReplicationEndpoint method handlePrepare.

/**
 * @param packet
 */
private void handlePrepare(final ReplicationPrepareMessage packet) throws Exception {
    Journal journalToUse = getJournal(packet.getJournalID());
    journalToUse.appendPrepareRecord(packet.getTxId(), packet.getRecordData(), noSync);
}
Also used : Journal(org.apache.activemq.artemis.core.journal.Journal) FileWrapperJournal(org.apache.activemq.artemis.core.journal.impl.FileWrapperJournal)

Example 14 with Journal

use of org.apache.activemq.artemis.core.journal.Journal 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)

Example 15 with Journal

use of org.apache.activemq.artemis.core.journal.Journal in project activemq-artemis by apache.

the class ReplicationTest method testNoActions.

@Test
public void testNoActions() throws Exception {
    setupServer(true);
    StorageManager storage = getStorage();
    manager = liveServer.getReplicationManager();
    waitForComponent(manager);
    Journal replicatedJournal = new ReplicatedJournal((byte) 1, new FakeJournal(), manager);
    replicatedJournal.appendPrepareRecord(1, new FakeData(), false);
    final CountDownLatch latch = new CountDownLatch(1);
    storage.afterCompleteOperations(new IOCallback() {

        @Override
        public void onError(final int errorCode, final String errorMessage) {
        }

        @Override
        public void done() {
            latch.countDown();
        }
    });
    Assert.assertTrue(latch.await(1, TimeUnit.SECONDS));
    Assert.assertEquals("should be empty " + manager.getActiveTokens(), 0, manager.getActiveTokens().size());
}
Also used : JournalStorageManager(org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager) StorageManager(org.apache.activemq.artemis.core.persistence.StorageManager) ReplicatedJournal(org.apache.activemq.artemis.core.replication.ReplicatedJournal) Journal(org.apache.activemq.artemis.core.journal.Journal) ReplicatedJournal(org.apache.activemq.artemis.core.replication.ReplicatedJournal) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) CountDownLatch(java.util.concurrent.CountDownLatch) IOCallback(org.apache.activemq.artemis.core.io.IOCallback) Test(org.junit.Test)

Aggregations

Journal (org.apache.activemq.artemis.core.journal.Journal)17 RecordInfo (org.apache.activemq.artemis.core.journal.RecordInfo)7 FileWrapperJournal (org.apache.activemq.artemis.core.journal.impl.FileWrapperJournal)6 Test (org.junit.Test)6 JournalImpl (org.apache.activemq.artemis.core.journal.impl.JournalImpl)5 ArrayList (java.util.ArrayList)4 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)4 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)4 ReplicatedJournal (org.apache.activemq.artemis.core.replication.ReplicatedJournal)4 NIOSequentialFileFactory (org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory)3 PreparedTransactionInfo (org.apache.activemq.artemis.core.journal.PreparedTransactionInfo)3 JournalContent (org.apache.activemq.artemis.core.persistence.impl.journal.AbstractJournalStorageManager.JournalContent)3 DescribeJournal (org.apache.activemq.artemis.core.persistence.impl.journal.DescribeJournal)3 JournalStorageManager (org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager)3 File (java.io.File)2 ByteBuffer (java.nio.ByteBuffer)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 IOCallback (org.apache.activemq.artemis.core.io.IOCallback)2