[jboss-dev-forums] [Design of Messaging on JBoss (Messaging/JBoss)] - Re: Journal Clean up / Compactor
clebert.suconic@jboss.com
do-not-reply at jboss.com
Mon Feb 16 10:56:21 EST 2009
This is a summary of the main changes:
- JournalFile..
I have added:
| void addCleanupInfo(long id, JournalFile deleteFile);
| JournalFile getCleanupInfo(long id);
|
I need to know what records are possibly bad. If a delete happened on a different file, I need that information to later perform a delete. The cleanupInfo will give me that List.
On JournalImpl, when a record is deleted, if the record is on a different file, I add the Information on that list:
| inner class PosFiles:
| ...
|
| void addDelete(final long id, final JournalFile deleteFile)
| {
| if (addFile != deleteFile)
| {
| addFile.addCleanupInfo(id, deleteFile);
| }
|
| deleteFile.incNegCount(addFile);
|
| if (updateFiles != null)
| {
| for (JournalFile updateF : updateFiles)
| {
| if (addFile != updateF)
| {
|
| // ... (some comments suppressed here)
| updateF.addCleanupInfo(id, deleteFile);
| }
|
| deleteFile.incNegCount(updateF);
| }
| }
| }
|
During the cleanup, if a record is on that list, I change the field-type for that record as CLEARED.
readJournalFile(journalFile, new JournalReader()
| {
|
| public void addRecord(final int recordPos, final RecordInfo recordInfo) throws Exception
| {
| JournalFile cleanupFile = journalFile.getCleanupInfo(recordInfo.id);
| if (cleanupFile != null)
| {
| if (trace)
| {
| trace("Cleaning addRecord id = " + recordInfo.id);
| }
|
| ByteBufferWrapper buffer = generateAddRecord(false,
| fileID,
| recordInfo.id,
| recordInfo.userRecordType,
| new ByteArrayEncoding(recordInfo.data));
|
| buffer.rewind();
|
| sf.position(recordPos);
| sf.write(buffer.getBuffer(), false);
|
| // Eliminating the dependency between a and b
|
| cleanupFile.decNegCount(journalFile);
| journalFile.decPosCount();
| }
|
| }
|
And to support reading JournalFiles for different purposes other than loading, I have created a method readJournalFile, that will be used by both load, cleaning, and compacting (in the future). The logic of reading the file is kept on a single place:
| // Used by both load, cleanup, and compact (in future)
| private int readJournalFile(final JournalFile file, final JournalReader reader) throws Exception
| {
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4210400#4210400
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4210400
More information about the jboss-dev-forums
mailing list