public void testCompactAddAndUpdateFollowedByADelete4() throws Exception
{
setup(2, 60 * 1024, false);
SimpleIDGenerator idGen = new SimpleIDGenerator(1000);
final ReusableLatch reusableLatchDone = new ReusableLatch();
reusableLatchDone.countUp();
final ReusableLatch reusableLatchWait = new ReusableLatch();
reusableLatchWait.countUp();
journal = new JournalImpl(fileSize, minFiles, 0, 0, fileFactory, filePrefix, fileExtension, maxAIO)
{
@Override
public void onCompactDone()
{
reusableLatchDone.countDown();
System.out.println("Waiting on Compact");
try
{
reusableLatchWait.await();
}
catch (InterruptedException e)
{
e.printStackTrace();
}
System.out.println("Done");
}
};
journal.setAutoReclaim(false);
startJournal();
load();
long consumerTX = idGen.generateID();
long firstID = idGen.generateID();
long appendTX = idGen.generateID();
long addedRecord = idGen.generateID();
Thread tCompact = new Thread()
{
@Override
public void run()
{
try
{
journal.compact();
}
catch (Exception e)
{
e.printStackTrace();
}
}
};
tCompact.start();
reusableLatchDone.await();
addTx(consumerTX, firstID);
addTx(appendTX, addedRecord);
commit(appendTX);
updateTx(consumerTX, addedRecord);
commit(consumerTX);
delete(addedRecord);
reusableLatchWait.countDown();
tCompact.join();
journal.forceMoveNextFile();
long newRecord = idGen.generateID();
add(newRecord);
update(newRecord);
journal.compact();