Search in sources :

Example 1 with StoreEntry

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

the class NonPersistentStoreImpl method get.

public StoreEntry get(Object key) throws StoreException {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/get, key=" + key);
    StoreEntry entry = null;
    try {
        SwapAddress sa = (SwapAddress) key;
        entry = sa.swapFile.get(sa.filePointer);
        entry.key = key;
    } catch (Exception e) {
        throw new StoreException(e.getMessage());
    }
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/get done, key=" + key + ", entry=" + entry);
    return entry;
}
Also used : StoreEntry(com.swiftmq.swiftlet.store.StoreEntry) SwapAddress(com.swiftmq.impl.store.standard.swap.SwapAddress) StoreException(com.swiftmq.swiftlet.store.StoreException) StoreException(com.swiftmq.swiftlet.store.StoreException)

Example 2 with StoreEntry

use of com.swiftmq.swiftlet.store.StoreEntry 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 3 with StoreEntry

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

the class PreparedLogQueue method add.

public synchronized long add(PrepareLogRecordImpl logRecord) throws IOException {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/add, logRecord: " + logRecord);
    CacheEntry cacheEntry = new CacheEntry();
    cacheEntry.logRecord = logRecord;
    long address = (long) ArrayListTool.setFirstFreeOrExpand(cache, cacheEntry);
    logRecord.setAddress(address);
    outStream.rewind();
    logRecord.writeContent(outStream);
    try {
        BytesMessageImpl msg = new BytesMessageImpl();
        msg.writeBytes(outStream.getBuffer(), 0, outStream.getCount());
        StoreEntry storeEntry = new StoreEntry();
        storeEntry.message = msg;
        long txId = ctx.transactionManager.createTxId(false);
        List journal = new ArrayList();
        queueIndex.setJournal(journal);
        cacheEntry.indexEntry = queueIndex.add(storeEntry);
        Semaphore sem = new Semaphore();
        ctx.recoveryManager.commit(new CommitLogRecord(txId, sem, journal, this, null));
        sem.waitHere();
        ctx.transactionManager.removeTxId(txId);
    } catch (Exception e) {
        throw new IOException(e.toString());
    }
    return address;
}
Also used : BytesMessageImpl(com.swiftmq.jms.BytesMessageImpl) StoreEntry(com.swiftmq.swiftlet.store.StoreEntry) CommitLogRecord(com.swiftmq.impl.store.standard.log.CommitLogRecord) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Semaphore(com.swiftmq.tools.concurrent.Semaphore) IOException(java.io.IOException) IOException(java.io.IOException) EOFException(java.io.EOFException)

Example 4 with StoreEntry

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

the class QueueIndex method get.

public StoreEntry get(QueueIndexEntry indexEntry) throws Exception {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/get, indexEntry=" + indexEntry);
    pis.setRootPageNo(indexEntry.getRootPageNo());
    StoreEntry storeEntry = new StoreEntry();
    storeEntry.key = indexEntry;
    storeEntry.priority = indexEntry.getPriority();
    storeEntry.deliveryCount = indexEntry.getDeliveryCount();
    storeEntry.expirationTime = indexEntry.getExpirationTime();
    storeEntry.message = MessageImpl.createInstance(pis.readInt());
    storeEntry.message.readContent(pis);
    pis.unloadPages();
    pis.reset();
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/get, returns=" + storeEntry);
    return storeEntry;
}
Also used : StoreEntry(com.swiftmq.swiftlet.store.StoreEntry)

Example 5 with StoreEntry

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

the class SwapFileImpl method get.

public StoreEntry get(long fp) throws Exception {
    file.seek(fp);
    int len = file.readInt();
    if (buffer.length - 1 < len) {
        buffer = new byte[len];
        dis.setBuffer(buffer);
    }
    file.read(buffer, 0, len);
    StoreEntry storeEntry = new StoreEntry();
    storeEntry.key = null;
    storeEntry.deliveryCount = dis.readInt();
    storeEntry.message = MessageImpl.createInstance(dis.readInt());
    storeEntry.message.readContent(dis);
    dis.reset();
    return storeEntry;
}
Also used : StoreEntry(com.swiftmq.swiftlet.store.StoreEntry)

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