use of com.swiftmq.impl.store.standard.log.InsertLogAction in project swiftmq-ce by iitsoftware.
the class PageOutputStream method flipPage.
private void flipPage() throws IOException {
try {
Page page = ctx.cacheManager.createAndPin();
page.dirty = true;
page.empty = false;
if (rootPageNo == -1)
rootPageNo = page.pageNo;
pages.add(page);
MessagePage mp = new MessagePage(page);
if (actPage != null) {
actPage.setNextPage(page.pageNo);
mp.setPrevPage(actPage.page.pageNo);
journal.add(new UpdatePortionLogAction(actPage.page.pageNo, 0, null, getPortion()));
} else
mp.setPrevPage(-1);
mp.setNextPage(-1);
actPage = mp;
available = Page.PAGE_SIZE - MessagePage.START_DATA;
pos = MessagePage.START_DATA;
journal.add(new InsertLogAction(page.pageNo));
} catch (Exception e) {
e.printStackTrace();
throw new IOException(e.toString());
}
}
use of com.swiftmq.impl.store.standard.log.InsertLogAction in project swiftmq-ce by iitsoftware.
the class RootIndex method getQueueIndex.
public synchronized QueueIndex getQueueIndex(String queueName) throws Exception {
IndexEntry entry = find(queueName);
if (entry == null) {
Semaphore sem = new Semaphore();
List journal = new ArrayList();
setJournal(journal);
QueueIndexPage indexPage = new QueueIndexPage(ctx, -1);
journal.add(new InsertLogAction(indexPage.getPage().pageNo));
indexPage.setJournal(journal);
indexPage.setPrevPage(-1);
indexPage.setNextPage(-1);
entry = new RootIndexEntry();
entry.setKey(queueName);
entry.setRootPageNo(indexPage.getPage().pageNo);
add(entry);
long txId = ctx.transactionManager.createTxId();
CommitLogRecord logRecord = new CommitLogRecord(txId, sem, journal, new IndexPageRelease(this, indexPage), null);
ctx.recoveryManager.commit(logRecord);
sem.waitHere();
ctx.transactionManager.removeTxId(txId);
} else
unloadPages();
return new QueueIndex(ctx, entry.getRootPageNo());
}
Aggregations