Search in sources :

Example 1 with InsertLogAction

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());
    }
}
Also used : InsertLogAction(com.swiftmq.impl.store.standard.log.InsertLogAction) Page(com.swiftmq.impl.store.standard.cache.Page) IOException(java.io.IOException) UpdatePortionLogAction(com.swiftmq.impl.store.standard.log.UpdatePortionLogAction) IOException(java.io.IOException) UTFDataFormatException(java.io.UTFDataFormatException)

Example 2 with InsertLogAction

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());
}
Also used : CommitLogRecord(com.swiftmq.impl.store.standard.log.CommitLogRecord) ArrayList(java.util.ArrayList) InsertLogAction(com.swiftmq.impl.store.standard.log.InsertLogAction) List(java.util.List) ArrayList(java.util.ArrayList) Semaphore(com.swiftmq.tools.concurrent.Semaphore)

Aggregations

InsertLogAction (com.swiftmq.impl.store.standard.log.InsertLogAction)2 Page (com.swiftmq.impl.store.standard.cache.Page)1 CommitLogRecord (com.swiftmq.impl.store.standard.log.CommitLogRecord)1 UpdatePortionLogAction (com.swiftmq.impl.store.standard.log.UpdatePortionLogAction)1 Semaphore (com.swiftmq.tools.concurrent.Semaphore)1 IOException (java.io.IOException)1 UTFDataFormatException (java.io.UTFDataFormatException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1