Search in sources :

Example 11 with NullStorageManager

use of org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager in project activemq-artemis by apache.

the class PagingManagerImplTest method testPagingManager.

@Test
public void testPagingManager() throws Exception {
    HierarchicalRepository<AddressSettings> addressSettings = new HierarchicalObjectRepository<>();
    addressSettings.setDefault(new AddressSettings().setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE));
    final StorageManager storageManager = new NullStorageManager();
    PagingStoreFactoryNIO storeFactory = new PagingStoreFactoryNIO(storageManager, getPageDirFile(), 100, null, getOrderedExecutor(), true, null);
    PagingManagerImpl managerImpl = new PagingManagerImpl(storeFactory, addressSettings);
    managerImpl.start();
    PagingStore store = managerImpl.getPageStore(new SimpleString("simple-test"));
    ICoreMessage msg = createMessage(1L, new SimpleString("simple-test"), createRandomBuffer(10));
    final RoutingContextImpl ctx = new RoutingContextImpl(null);
    Assert.assertFalse(store.page(msg, ctx.getTransaction(), ctx.getContextListing(store.getStoreName()), lock));
    store.startPaging();
    Assert.assertTrue(store.page(msg, ctx.getTransaction(), ctx.getContextListing(store.getStoreName()), lock));
    Page page = store.depage();
    page.open();
    List<PagedMessage> msgs = page.read(new NullStorageManager());
    page.close();
    Assert.assertEquals(1, msgs.size());
    ActiveMQTestBase.assertEqualsByteArrays(msg.getBodyBuffer().writerIndex(), msg.getBodyBuffer().toByteBuffer().array(), (msgs.get(0).getMessage()).toCore().getBodyBuffer().toByteBuffer().array());
    Assert.assertTrue(store.isPaging());
    Assert.assertNull(store.depage());
    final RoutingContextImpl ctx2 = new RoutingContextImpl(null);
    Assert.assertFalse(store.page(msg, ctx2.getTransaction(), ctx2.getContextListing(store.getStoreName()), lock));
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) PagedMessage(org.apache.activemq.artemis.core.paging.PagedMessage) StorageManager(org.apache.activemq.artemis.core.persistence.StorageManager) NullStorageManager(org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Page(org.apache.activemq.artemis.core.paging.impl.Page) HierarchicalObjectRepository(org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository) RoutingContextImpl(org.apache.activemq.artemis.core.server.impl.RoutingContextImpl) ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) NullStorageManager(org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager) PagingStoreFactoryNIO(org.apache.activemq.artemis.core.paging.impl.PagingStoreFactoryNIO) PagingManagerImpl(org.apache.activemq.artemis.core.paging.impl.PagingManagerImpl) PagingStore(org.apache.activemq.artemis.core.paging.PagingStore) Test(org.junit.Test)

Aggregations

NullStorageManager (org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager)11 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)9 PagedMessage (org.apache.activemq.artemis.core.paging.PagedMessage)7 Page (org.apache.activemq.artemis.core.paging.impl.Page)7 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)7 Test (org.junit.Test)6 PagingStoreFactory (org.apache.activemq.artemis.core.paging.PagingStoreFactory)5 RoutingContextImpl (org.apache.activemq.artemis.core.server.impl.RoutingContextImpl)5 ArrayList (java.util.ArrayList)4 Message (org.apache.activemq.artemis.api.core.Message)4 SequentialFile (org.apache.activemq.artemis.core.io.SequentialFile)4 CoreMessage (org.apache.activemq.artemis.core.message.impl.CoreMessage)4 PagingStore (org.apache.activemq.artemis.core.paging.PagingStore)4 PagingStoreImpl (org.apache.activemq.artemis.core.paging.impl.PagingStoreImpl)4 SequentialFileFactory (org.apache.activemq.artemis.core.io.SequentialFileFactory)3 NIOSequentialFileFactory (org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory)3 PagingManagerImpl (org.apache.activemq.artemis.core.paging.impl.PagingManagerImpl)3 PagingStoreFactoryNIO (org.apache.activemq.artemis.core.paging.impl.PagingStoreFactoryNIO)3 StorageManager (org.apache.activemq.artemis.core.persistence.StorageManager)3 HierarchicalObjectRepository (org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository)3