Search in sources :

Example 6 with PagingManager

use of org.apache.activemq.artemis.core.paging.PagingManager 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 7 with PagingManager

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

the class ReplicationTest method createPageManager.

protected PagingManager createPageManager(final StorageManager storageManager, final Configuration configuration, final ExecutorFactory executorFactory, final HierarchicalRepository<AddressSettings> addressSettingsRepository) throws Exception {
    PagingManager paging = new PagingManagerImpl(new PagingStoreFactoryNIO(storageManager, configuration.getPagingLocation(), 1000, null, executorFactory, false, null), addressSettingsRepository);
    paging.start();
    return paging;
}
Also used : PagingStoreFactoryNIO(org.apache.activemq.artemis.core.paging.impl.PagingStoreFactoryNIO) PagingManager(org.apache.activemq.artemis.core.paging.PagingManager) PagingManagerImpl(org.apache.activemq.artemis.core.paging.impl.PagingManagerImpl)

Aggregations

PagingManager (org.apache.activemq.artemis.core.paging.PagingManager)7 Configuration (org.apache.activemq.artemis.core.config.Configuration)4 DivertConfiguration (org.apache.activemq.artemis.core.config.DivertConfiguration)4 StoreConfiguration (org.apache.activemq.artemis.core.config.StoreConfiguration)4 DatabaseStorageConfiguration (org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration)4 OperationContext (org.apache.activemq.artemis.core.persistence.OperationContext)4 ExecutorService (java.util.concurrent.ExecutorService)3 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)3 File (java.io.File)2 IOException (java.io.IOException)2 PrintWriter (java.io.PrintWriter)2 StringWriter (java.io.StringWriter)2 ManagementFactory (java.lang.management.ManagementFactory)2 URL (java.net.URL)2 AccessController (java.security.AccessController)2 PrivilegedAction (java.security.PrivilegedAction)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Date (java.util.Date)2 EnumSet (java.util.EnumSet)2