Search in sources :

Example 1 with StoreException

use of com.swiftmq.swiftlet.store.StoreException 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 StoreException

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

the class NonPersistentStoreImpl method close.

public void close() throws StoreException {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/close...");
    try {
        if (swapFiles != null) {
            if (deleteSwapFilesOnClose()) {
                for (int i = 0; i < swapFiles.size(); i++) {
                    ((SwapFile) swapFiles.get(i)).close();
                }
            }
            swapFiles.clear();
            swapFiles = null;
            actSwapFile = null;
        }
    } catch (Exception e) {
        throw new StoreException(e.getMessage());
    }
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/close...done");
}
Also used : SwapFile(com.swiftmq.impl.store.standard.swap.SwapFile) StoreException(com.swiftmq.swiftlet.store.StoreException) StoreException(com.swiftmq.swiftlet.store.StoreException)

Example 3 with StoreException

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

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

the class StoreReadTransactionImpl method abort.

public void abort() throws StoreException {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/abort...");
    txId = ctx.transactionManager.createTxId();
    journal = new ArrayList();
    queueIndex.setJournal(journal);
    try {
        if (markRedelivered) {
            for (int i = 0; i < keys.size(); i++) {
                queueIndex.incDeliveryCount((QueueIndexEntry) keys.get(i));
            }
        }
    } catch (Exception e) {
        throw new StoreException(e.getMessage());
    }
    keys.clear();
    // don't wonder, we are committing the redelivered settings
    super.commit();
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/abort...done.");
}
Also used : ArrayList(java.util.ArrayList) StoreException(com.swiftmq.swiftlet.store.StoreException) IOException(java.io.IOException) StoreException(com.swiftmq.swiftlet.store.StoreException)

Example 5 with StoreException

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

the class StoreTransactionImpl method abort.

public void abort() throws StoreException {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/abort...");
    if (closed)
        throw new StoreException("Transaction is closed");
    try {
        if (journal != null && journal.size() > 0) {
            ctx.recoveryManager.abort(new AbortLogRecord(txId, sem, journal, this, null));
            sem.waitHere();
        }
        ctx.transactionManager.removeTxId(txId);
        close();
    } catch (Exception e) {
        throw new StoreException(e.getMessage());
    }
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/abort...done.");
}
Also used : AbortLogRecord(com.swiftmq.impl.store.standard.log.AbortLogRecord) StoreException(com.swiftmq.swiftlet.store.StoreException) StoreException(com.swiftmq.swiftlet.store.StoreException)

Aggregations

StoreException (com.swiftmq.swiftlet.store.StoreException)23 CommitLogRecord (com.swiftmq.impl.store.standard.log.CommitLogRecord)8 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)6 SwapAddress (com.swiftmq.impl.store.standard.swap.SwapAddress)4 QueueIndexEntry (com.swiftmq.impl.store.standard.index.QueueIndexEntry)3 AbortLogRecord (com.swiftmq.impl.store.standard.log.AbortLogRecord)3 AsyncCompletionCallback (com.swiftmq.tools.concurrent.AsyncCompletionCallback)3 MessagePageReference (com.swiftmq.impl.store.standard.index.MessagePageReference)2 PrepareLogRecordImpl (com.swiftmq.impl.store.standard.xa.PrepareLogRecordImpl)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 SwapFile (com.swiftmq.impl.store.standard.swap.SwapFile)1 DurableStoreEntry (com.swiftmq.swiftlet.store.DurableStoreEntry)1 StoreEntry (com.swiftmq.swiftlet.store.StoreEntry)1 Semaphore (com.swiftmq.tools.concurrent.Semaphore)1