Search in sources :

Example 6 with StoreEntry

use of com.swiftmq.swiftlet.store.StoreEntry in project swiftmq-ce by iitsoftware.

the class IndexAnalyzer method checkPage.

private PR checkPage(QueueIndexPage p) throws Exception {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/checkPage, p=" + p + " ...");
    PR pagePR = new PR();
    List entries = new ArrayList();
    for (Iterator iter = p.iterator(); iter.hasNext(); ) {
        IndexEntry entry = (IndexEntry) iter.next();
        if (entry.isValid())
            entries.add(entry);
    }
    for (Iterator iter = entries.iterator(); iter.hasNext(); ) {
        QueueIndexEntry entry = (QueueIndexEntry) iter.next();
        try {
            PR elementPR = new PR();
            PageInputStream pis = new PageInputStream(ctx);
            pis.setPageRecorder(elementPR);
            pis.setRootPageNo(entry.getRootPageNo());
            StoreEntry storeEntry = new StoreEntry();
            storeEntry.key = entry;
            storeEntry.priority = entry.getPriority();
            storeEntry.deliveryCount = entry.getDeliveryCount();
            storeEntry.expirationTime = entry.getExpirationTime();
            storeEntry.message = MessageImpl.createInstance(pis.readInt());
            storeEntry.message.readContent(pis);
            pis.unloadPages();
            pis.reset();
            pagePR.addAll(elementPR);
        } catch (Exception e) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace("sys$store", toString() + "/checkPage, p=" + p + ", entry=" + entry + ", exception=" + e);
            throw e;
        }
    }
    try {
        ctx.cacheManager.shrink();
    } catch (Exception e) {
    }
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/checkPage, p=" + p + " done");
    return pagePR;
}
Also used : StoreEntry(com.swiftmq.swiftlet.store.StoreEntry) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList)

Example 7 with StoreEntry

use of com.swiftmq.swiftlet.store.StoreEntry in project swiftmq-ce by iitsoftware.

the class CacheImpl method put.

public void put(StoreId storeId, MessageImpl message) throws Exception {
    long msgSize = message.getMessageLength();
    storeId.setMsgSize(msgSize);
    if (cacheTable.size() < maxMessages && currentBytes + msgSize < maxBytes) {
        cacheTable.put(storeId, new MessageEntry(storeId, message));
        currentBytes += msgSize;
    } else {
        // rollback, it is!)
        if (!storeId.isPersistent() && cacheTable.get(storeId) == null) {
            StoreEntry se = new StoreEntry();
            se.priority = storeId.getPriority();
            se.deliveryCount = storeId.getDeliveryCount();
            se.expirationTime = storeId.getExpirationTime();
            se.message = message;
            swapStore.insert(se);
            se.message = null;
            storeId.setPersistentKey(se);
        }
    }
}
Also used : StoreEntry(com.swiftmq.swiftlet.store.StoreEntry) MessageEntry(com.swiftmq.swiftlet.queue.MessageEntry)

Example 8 with StoreEntry

use of com.swiftmq.swiftlet.store.StoreEntry in project swiftmq-ce by iitsoftware.

the class CacheImpl method get.

public MessageEntry get(StoreId storeId) throws Exception {
    MessageEntry me = (MessageEntry) cacheTable.get(storeId);
    if (me == null) {
        me = new MessageEntry();
        me.setMessageIndex(storeId);
        if (storeId.isPersistent())
            me.setMessage(((StoreEntry) pStore.get(((StoreEntry) storeId.getPersistentKey()).key)).message);
        else
            me.setMessage(((StoreEntry) swapStore.get(((StoreEntry) storeId.getPersistentKey()).key)).message);
        storeId.setMsgSize(me.getMessage().getMessageLength());
    }
    return me;
}
Also used : StoreEntry(com.swiftmq.swiftlet.store.StoreEntry) MessageEntry(com.swiftmq.swiftlet.queue.MessageEntry)

Aggregations

StoreEntry (com.swiftmq.swiftlet.store.StoreEntry)8 ArrayList (java.util.ArrayList)3 List (java.util.List)3 BytesMessageImpl (com.swiftmq.jms.BytesMessageImpl)2 MessageEntry (com.swiftmq.swiftlet.queue.MessageEntry)2 QueueIndexEntry (com.swiftmq.impl.store.standard.index.QueueIndexEntry)1 CommitLogRecord (com.swiftmq.impl.store.standard.log.CommitLogRecord)1 SwapAddress (com.swiftmq.impl.store.standard.swap.SwapAddress)1 StoreException (com.swiftmq.swiftlet.store.StoreException)1 Semaphore (com.swiftmq.tools.concurrent.Semaphore)1 EOFException (java.io.EOFException)1 IOException (java.io.IOException)1 Iterator (java.util.Iterator)1