Search in sources :

Example 21 with StoreException

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

the class StoreWriteTransactionImpl method abort.

public void abort(XidImpl globalTxId) throws StoreException {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/abort, globalTxId: " + globalTxId);
    txId = ctx.transactionManager.createTxId();
    sem = new Semaphore();
    journal = new ArrayList();
    queueIndex.setJournal(journal);
    try {
        for (int i = 0; i < keys.size(); i++) {
            addMessagePageReference(queueIndex.remove((QueueIndexEntry) keys.get(i)));
        }
        ctx.recoveryManager.commit(new CommitLogRecord(txId, sem, journal, this, messagePageRefs));
        sem.waitHere();
        ctx.transactionManager.removeTxId(txId);
    } catch (Exception e) {
        throw new StoreException(e.toString());
    }
    if (prepareLogRecord != null) {
        try {
            ctx.preparedLog.remove(prepareLogRecord);
        } catch (IOException e) {
            throw new StoreException(e.toString());
        }
        prepareLogRecord = null;
    }
    close();
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/abort, globalTxId: " + globalTxId + ", done");
}
Also used : CommitLogRecord(com.swiftmq.impl.store.standard.log.CommitLogRecord) ArrayList(java.util.ArrayList) Semaphore(com.swiftmq.tools.concurrent.Semaphore) IOException(java.io.IOException) 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 22 with StoreException

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

the class StoreWriteTransactionImpl method prepare.

public void prepare(XidImpl globalTxId) throws StoreException {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/prepare, globalTxId=" + globalTxId);
    try {
        prepareLogRecord = new PrepareLogRecordImpl(PrepareLogRecordImpl.WRITE_TRANSACTION, queueName, globalTxId, keys);
        ctx.preparedLog.add(prepareLogRecord);
        ctx.recoveryManager.commit(new CommitLogRecord(txId, sem, journal, this, null));
        sem.waitHere();
        ctx.transactionManager.removeTxId(txId);
    } catch (Exception e) {
        throw new StoreException(e.getMessage());
    }
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/prepare, globalTxId=" + globalTxId + ", done");
}
Also used : CommitLogRecord(com.swiftmq.impl.store.standard.log.CommitLogRecord) PrepareLogRecordImpl(com.swiftmq.impl.store.standard.xa.PrepareLogRecordImpl) StoreException(com.swiftmq.swiftlet.store.StoreException) IOException(java.io.IOException) StoreException(com.swiftmq.swiftlet.store.StoreException)

Example 23 with StoreException

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

the class CompositeStoreTransactionImpl method commitTransaction.

public void commitTransaction() throws StoreException {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/commitTransaction...");
    if (closed)
        throw new StoreException("Transaction is closed");
    if (txId == -1)
        txId = ctx.transactionManager.createTxId();
    try {
        List<MessagePageReference> messagePageRefs = processRemovedKeys();
        if (journal != null && journal.size() > 0) {
            ctx.recoveryManager.commit(new CommitLogRecord(txId, sem, journal, this, messagePageRefs));
            sem.waitHere();
            removeTxId();
        } else
            removeTxId();
        close();
    } catch (Exception e) {
        throw new StoreException(e.toString());
    }
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/commitTransaction...done.");
}
Also used : MessagePageReference(com.swiftmq.impl.store.standard.index.MessagePageReference) CommitLogRecord(com.swiftmq.impl.store.standard.log.CommitLogRecord) 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