use of org.apache.activemq.artemis.core.io.SequentialFileFactory in project activemq-artemis by apache.
the class PagingStoreImplTest method testConcurrentDepage.
@Test
public void testConcurrentDepage() throws Exception {
SequentialFileFactory factory = new FakeSequentialFileFactory(1, false);
testConcurrentPaging(factory, 10);
}
use of org.apache.activemq.artemis.core.io.SequentialFileFactory in project activemq-artemis by apache.
the class PagingStoreImplTest method testRestartPage.
@Test
public void testRestartPage() throws Throwable {
clearDataRecreateServerDirs();
SequentialFileFactory factory = new NIOSequentialFileFactory(new File(getPageDir()), 1);
PagingStoreFactory storeFactory = new FakeStoreFactory(factory);
final int MAX_SIZE = 1024 * 10;
AddressSettings settings = new AddressSettings().setPageSizeBytes(MAX_SIZE).setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE);
final PagingStore storeImpl = new PagingStoreImpl(PagingStoreImplTest.destinationTestName, null, 100, createMockManager(), createStorageManagerMock(), factory, storeFactory, new SimpleString("test"), settings, getExecutorFactory().getExecutor(), true);
storeImpl.start();
Assert.assertEquals(0, storeImpl.getNumberOfPages());
// Marked the store to be paged
storeImpl.startPaging();
storeImpl.depage();
Assert.assertNull(storeImpl.getCurrentPage());
storeImpl.startPaging();
Assert.assertNotNull(storeImpl.getCurrentPage());
storeImpl.stop();
}
use of org.apache.activemq.artemis.core.io.SequentialFileFactory in project activemq-artemis by apache.
the class JournalCleanupCompactStressTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
threadPool = Executors.newFixedThreadPool(20, tFactory);
executorFactory = new OrderedExecutorFactory(threadPool);
testExecutor = executorFactory.getExecutor();
maxRecords = new Semaphore(MAX_WRITES);
errors.set(0);
File dir = new File(getTemporaryDir());
dir.mkdirs();
SequentialFileFactory factory;
int maxAIO;
if (LibaioContext.isLoaded()) {
factory = new AIOSequentialFileFactory(dir, 10);
maxAIO = ActiveMQDefaultConfiguration.getDefaultJournalMaxIoAio();
} else {
factory = new NIOSequentialFileFactory(dir, true, 1);
maxAIO = ActiveMQDefaultConfiguration.getDefaultJournalMaxIoNio();
}
journal = new JournalImpl(50 * 1024, 20, 20, 50, ActiveMQDefaultConfiguration.getDefaultJournalCompactPercentage(), factory, "activemq-data", "amq", maxAIO) {
@Override
protected void onCompactLockingTheJournal() throws Exception {
}
@Override
protected void onCompactStart() throws Exception {
testExecutor.execute(new Runnable() {
@Override
public void run() {
try {
// System.out.println("OnCompactStart enter");
if (running) {
long id = idGen.generateID();
journal.appendAddRecord(id, (byte) 0, new byte[] { 1, 2, 3 }, false);
journal.forceMoveNextFile();
journal.appendDeleteRecord(id, id == 20);
}
// System.out.println("OnCompactStart leave");
} catch (Exception e) {
e.printStackTrace();
errors.incrementAndGet();
}
}
});
}
};
journal.start();
journal.loadInternalOnly();
}
use of org.apache.activemq.artemis.core.io.SequentialFileFactory in project activemq-artemis by apache.
the class CleanBufferTest method testCleanOnNIO.
// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
@Test
public void testCleanOnNIO() {
SequentialFileFactory factory = new NIOSequentialFileFactory(new File("Whatever"), 1);
testBuffer(factory);
}
use of org.apache.activemq.artemis.core.io.SequentialFileFactory in project activemq-artemis by apache.
the class ActiveMQTestBase method internalCountJournalLivingRecords.
/**
* This method will load a journal and count the living records
*
* @param config
* @param messageJournal if true -> MessageJournal, false -> BindingsJournal
* @return
* @throws Exception
*/
protected HashMap<Integer, AtomicInteger> internalCountJournalLivingRecords(Configuration config, boolean messageJournal) throws Exception {
final HashMap<Integer, AtomicInteger> recordsType = new HashMap<>();
SequentialFileFactory ff;
JournalImpl journal;
if (messageJournal) {
ff = new NIOSequentialFileFactory(config.getJournalLocation(), null, 1);
journal = new JournalImpl(config.getJournalFileSize(), config.getJournalMinFiles(), config.getJournalPoolFiles(), 0, 0, ff, "activemq-data", "amq", 1);
} else {
ff = new NIOSequentialFileFactory(config.getBindingsLocation(), null, 1);
journal = new JournalImpl(1024 * 1024, 2, config.getJournalCompactMinFiles(), config.getJournalPoolFiles(), config.getJournalCompactPercentage(), ff, "activemq-bindings", "bindings", 1);
}
journal.start();
final List<RecordInfo> committedRecords = new LinkedList<>();
final List<PreparedTransactionInfo> preparedTransactions = new LinkedList<>();
journal.load(committedRecords, preparedTransactions, null, false);
for (RecordInfo info : committedRecords) {
Integer ikey = new Integer(info.getUserRecordType());
AtomicInteger value = recordsType.get(ikey);
if (value == null) {
value = new AtomicInteger();
recordsType.put(ikey, value);
}
value.incrementAndGet();
}
journal.stop();
return recordsType;
}
Aggregations