use of org.apache.activemq.artemis.core.paging.impl.PagingStoreFactoryNIO 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));
}
use of org.apache.activemq.artemis.core.paging.impl.PagingStoreFactoryNIO 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;
}
Aggregations