{
ArrayList<RecordInfo> acks = new ArrayList<RecordInfo>();
List<RecordInfo> records = new LinkedList<RecordInfo>();
Journal messageJournal = storageManager.getMessageJournal();
log.debug("Reading journal from " + config.getJournalDirectory());
messageJournal.start();
((JournalImpl) messageJournal).load(records, null, null, false);
for (RecordInfo info : records)
{
byte[] data = info.data;
HornetQBuffer buff = HornetQBuffers.wrappedBuffer(data);
Object o = JournalStorageManager.newObjectEncoding(info, storageManager);
if (info.getUserRecordType() == JournalStorageManager.ADD_MESSAGE)
{
messages.put(info.id, ((MessageDescribe) o).msg);
}
else if (info.getUserRecordType() == JournalStorageManager.ADD_LARGE_MESSAGE)
{
messages.put(info.id, ((MessageDescribe) o).msg);
}
else if (info.getUserRecordType() == JournalStorageManager.ADD_REF)
{
ReferenceDescribe ref = (ReferenceDescribe) o;
HashMap<Long, ReferenceDescribe> map = messageRefs.get(info.id);
if (map == null)
{
HashMap<Long, ReferenceDescribe> newMap = new HashMap<Long, ReferenceDescribe>();
newMap.put(ref.refEncoding.queueID, ref);
messageRefs.put(info.id, newMap);
}
else
{
map.put(ref.refEncoding.queueID, ref);
}
}
else if (info.getUserRecordType() == JournalStorageManager.ACKNOWLEDGE_REF)
{
acks.add(info);
}
else if (info.userRecordType == JournalStorageManager.ACKNOWLEDGE_CURSOR)
{
CursorAckRecordEncoding encoding = new CursorAckRecordEncoding();
encoding.decode(buff);
Set<PagePosition> set = cursorRecords.get(encoding.queueID);
if (set == null)
{
set = new HashSet<PagePosition>();
cursorRecords.put(encoding.queueID, set);
}
set.add(encoding.position);
}
else if (info.userRecordType == JournalStorageManager.PAGE_TRANSACTION)
{
if (info.isUpdate)
{
PageUpdateTXEncoding pageUpdate = new PageUpdateTXEncoding();
pageUpdate.decode(buff);
pgTXs.add(pageUpdate.pageTX);
}
else
{
PageTransactionInfoImpl pageTransactionInfo = new PageTransactionInfoImpl();
pageTransactionInfo.decode(buff);
pageTransactionInfo.setRecordID(info.id);
pgTXs.add(pageTransactionInfo.getTransactionID());
}
}
}
messageJournal.stop();
removeAcked(acks);
}