Search in sources :

Example 11 with CommitLogRecord

use of com.swiftmq.impl.store.standard.log.CommitLogRecord 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)

Example 12 with CommitLogRecord

use of com.swiftmq.impl.store.standard.log.CommitLogRecord in project swiftmq-ce by iitsoftware.

the class PreparedLogQueue method remove.

public synchronized void remove(PrepareLogRecordImpl logRecord) throws IOException {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/remove, logRecord: " + logRecord);
    int address = (int) logRecord.getAddress();
    CacheEntry cacheEntry = (CacheEntry) cache.get(address);
    if (cacheEntry == null)
        throw new EOFException("No CacheEntry found at index: " + address);
    cache.set(address, null);
    long txId = ctx.transactionManager.createTxId(false);
    List journal = new ArrayList();
    queueIndex.setJournal(journal);
    Semaphore sem = new Semaphore();
    try {
        queueIndex.remove(cacheEntry.indexEntry);
        ctx.recoveryManager.commit(new CommitLogRecord(txId, sem, journal, this, null));
    } catch (Exception e) {
        throw new IOException(e.toString());
    }
    sem.waitHere();
    ctx.transactionManager.removeTxId(txId);
}
Also used : CommitLogRecord(com.swiftmq.impl.store.standard.log.CommitLogRecord) EOFException(java.io.EOFException) 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)

Aggregations

CommitLogRecord (com.swiftmq.impl.store.standard.log.CommitLogRecord)12 StoreException (com.swiftmq.swiftlet.store.StoreException)8 ArrayList (java.util.ArrayList)8 List (java.util.List)6 Semaphore (com.swiftmq.tools.concurrent.Semaphore)5 IOException (java.io.IOException)5 AsyncCompletionCallback (com.swiftmq.tools.concurrent.AsyncCompletionCallback)3 MessagePageReference (com.swiftmq.impl.store.standard.index.MessagePageReference)2 QueueIndexEntry (com.swiftmq.impl.store.standard.index.QueueIndexEntry)2 AbortLogRecord (com.swiftmq.impl.store.standard.log.AbortLogRecord)2 EOFException (java.io.EOFException)2 DeleteLogAction (com.swiftmq.impl.store.standard.log.DeleteLogAction)1 InsertLogAction (com.swiftmq.impl.store.standard.log.InsertLogAction)1 PrepareLogRecordImpl (com.swiftmq.impl.store.standard.xa.PrepareLogRecordImpl)1 BytesMessageImpl (com.swiftmq.jms.BytesMessageImpl)1 StoreEntry (com.swiftmq.swiftlet.store.StoreEntry)1 Iterator (java.util.Iterator)1