Search in sources :

Example 1 with QueueIndexEntry

use of com.swiftmq.impl.store.standard.index.QueueIndexEntry in project swiftmq-ce by iitsoftware.

the class PersistentStoreImpl method getStoreEntries.

public List getStoreEntries() throws StoreException {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/getStoreEntries...");
    if (closed)
        throw new StoreException("Store is closed");
    List entries = null;
    try {
        List qiEntries = queueIndex.getEntries();
        queueIndex.unloadPages();
        entries = new ArrayList(qiEntries.size());
        for (int i = 0; i < qiEntries.size(); i++) {
            QueueIndexEntry entry = (QueueIndexEntry) qiEntries.get(i);
            StoreEntry storeEntry = new StoreEntry();
            storeEntry.key = entry;
            storeEntry.priority = entry.getPriority();
            storeEntry.deliveryCount = entry.getDeliveryCount();
            storeEntry.expirationTime = entry.getExpirationTime();
            storeEntry.message = null;
            entries.add(storeEntry);
        }
    } catch (Exception e) {
        throw new StoreException(e.getMessage());
    }
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/getStoreEntries done, entries.size()=" + entries.size());
    return entries;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) QueueIndexEntry(com.swiftmq.impl.store.standard.index.QueueIndexEntry)

Example 2 with QueueIndexEntry

use of com.swiftmq.impl.store.standard.index.QueueIndexEntry in project swiftmq-ce by iitsoftware.

the class StoreReadTransactionImpl method commit.

public void commit(AsyncCompletionCallback callback) {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/commit...");
    AsyncCompletionCallback localCallback = createLocalCallback(callback);
    if (checkClosedAsync(localCallback))
        return;
    txId = ctx.transactionManager.createTxId();
    journal = new ArrayList();
    queueIndex.setJournal(journal);
    try {
        for (int i = 0; i < keys.size(); i++) {
            addMessagePageReference(queueIndex.remove((QueueIndexEntry) keys.get(i)));
        }
    } catch (Exception e) {
        e.printStackTrace();
        localCallback.setException(e);
        localCallback.notifyCallbackStack(false);
        return;
    }
    keys.clear();
    if (journal != null && journal.size() > 0) {
        try {
            ctx.recoveryManager.commit(new CommitLogRecord(txId, null, journal, this, localCallback, messagePageRefs));
        } catch (Exception e) {
            localCallback.setException(new StoreException(e.toString()));
            localCallback.notifyCallbackStack(false);
        }
    } else
        localCallback.notifyCallbackStack(true);
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/commit...done.");
}
Also used : AsyncCompletionCallback(com.swiftmq.tools.concurrent.AsyncCompletionCallback) CommitLogRecord(com.swiftmq.impl.store.standard.log.CommitLogRecord) ArrayList(java.util.ArrayList) QueueIndexEntry(com.swiftmq.impl.store.standard.index.QueueIndexEntry) StoreException(com.swiftmq.swiftlet.store.StoreException) IOException(java.io.IOException) StoreException(com.swiftmq.swiftlet.store.StoreException)

Example 3 with QueueIndexEntry

use of com.swiftmq.impl.store.standard.index.QueueIndexEntry in project swiftmq-ce by iitsoftware.

the class PrepareLogRecordImpl method readEntry.

private QueueIndexEntry readEntry(DataInput in) throws IOException {
    int len = in.readInt();
    if (buffer == null || buffer.length < len)
        buffer = new byte[len];
    in.readFully(buffer, 0, len);
    QueueIndexEntry entry = new QueueIndexEntry();
    entry.readContent(buffer, 0);
    return entry;
}
Also used : QueueIndexEntry(com.swiftmq.impl.store.standard.index.QueueIndexEntry)

Example 4 with QueueIndexEntry

use of com.swiftmq.impl.store.standard.index.QueueIndexEntry in project swiftmq-ce by iitsoftware.

the class PreparedLogQueue method preload.

private void preload() throws Exception {
    List qiEntries = queueIndex.getEntries();
    queueIndex.unloadPages();
    for (int i = 0; i < qiEntries.size(); i++) {
        QueueIndexEntry entry = (QueueIndexEntry) qiEntries.get(i);
        StoreEntry storeEntry = queueIndex.get(entry);
        BytesMessageImpl msg = (BytesMessageImpl) storeEntry.message;
        byte[] b = new byte[(int) msg.getBodyLength()];
        msg.readBytes(b);
        inStream.setBuffer(b, 0, b.length);
        PrepareLogRecordImpl logRecord = new PrepareLogRecordImpl(0);
        logRecord.readContent(inStream);
        CacheEntry cacheEntry = new CacheEntry();
        cacheEntry.logRecord = logRecord;
        long address = (long) ArrayListTool.setFirstFreeOrExpand(cache, cacheEntry);
        logRecord.setAddress(address);
        cacheEntry.indexEntry = entry;
    }
    queueIndex.unloadPages();
}
Also used : BytesMessageImpl(com.swiftmq.jms.BytesMessageImpl) StoreEntry(com.swiftmq.swiftlet.store.StoreEntry) ArrayList(java.util.ArrayList) List(java.util.List) QueueIndexEntry(com.swiftmq.impl.store.standard.index.QueueIndexEntry)

Example 5 with QueueIndexEntry

use of com.swiftmq.impl.store.standard.index.QueueIndexEntry in project swiftmq-ce by iitsoftware.

the class StoreReadTransactionImpl method commit.

public void commit() throws StoreException {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/commit...");
    if (closed)
        throw new StoreException("Transaction is closed");
    txId = ctx.transactionManager.createTxId();
    journal = new ArrayList();
    queueIndex.setJournal(journal);
    try {
        for (int i = 0; i < keys.size(); i++) {
            addMessagePageReference(queueIndex.remove((QueueIndexEntry) keys.get(i)));
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw new StoreException(e.getMessage());
    }
    keys.clear();
    super.commit();
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/commit...done.");
}
Also used : ArrayList(java.util.ArrayList) QueueIndexEntry(com.swiftmq.impl.store.standard.index.QueueIndexEntry) StoreException(com.swiftmq.swiftlet.store.StoreException) IOException(java.io.IOException) StoreException(com.swiftmq.swiftlet.store.StoreException)

Aggregations

QueueIndexEntry (com.swiftmq.impl.store.standard.index.QueueIndexEntry)6 ArrayList (java.util.ArrayList)5 StoreException (com.swiftmq.swiftlet.store.StoreException)3 IOException (java.io.IOException)3 CommitLogRecord (com.swiftmq.impl.store.standard.log.CommitLogRecord)2 List (java.util.List)2 BytesMessageImpl (com.swiftmq.jms.BytesMessageImpl)1 StoreEntry (com.swiftmq.swiftlet.store.StoreEntry)1 AsyncCompletionCallback (com.swiftmq.tools.concurrent.AsyncCompletionCallback)1 Semaphore (com.swiftmq.tools.concurrent.Semaphore)1