Search in sources :

Example 11 with StoreException

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

the class CompositeStoreTransactionImpl method commitTransaction.

public void commitTransaction(AsyncCompletionCallback callback) {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/commit (callback) ...");
    AsyncCompletionCallback localCallback = createLocalCallback(callback);
    checkClosedAsync(localCallback);
    if (localCallback.isNotified())
        return;
    try {
        List<MessagePageReference> messagePageRefs = processRemovedKeys();
        if (journal != null && journal.size() > 0)
            ctx.recoveryManager.commit(new CommitLogRecord(txId, null, journal, this, localCallback, messagePageRefs));
        else {
            localCallback.notifyCallbackStack(true);
            removeTxId();
        }
    } catch (Exception e) {
        localCallback.setException(new StoreException(e.toString()));
        localCallback.notifyCallbackStack(false);
        removeTxId();
    }
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/commit (callback) ... done.");
}
Also used : MessagePageReference(com.swiftmq.impl.store.standard.index.MessagePageReference) AsyncCompletionCallback(com.swiftmq.tools.concurrent.AsyncCompletionCallback) CommitLogRecord(com.swiftmq.impl.store.standard.log.CommitLogRecord) StoreException(com.swiftmq.swiftlet.store.StoreException) StoreException(com.swiftmq.swiftlet.store.StoreException)

Example 12 with StoreException

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

the class DurableSubscriberStoreImpl method insertDurableStoreEntry.

public synchronized void insertDurableStoreEntry(DurableStoreEntry durableStoreEntry) throws StoreException {
    Map map = new HashMap();
    map.put("topicName", durableStoreEntry.getTopicName());
    if (durableStoreEntry.getSelector() != null)
        map.put("selector", durableStoreEntry.getSelector());
    if (durableStoreEntry.isNoLocal())
        map.put("noLocal", "true");
    try {
        String filename = getDurableFilename(durableStoreEntry.getClientId(), durableStoreEntry.getDurableName());
        File f = new File(dir, filename);
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(f));
        oos.writeObject(map);
        oos.close();
    } catch (Exception e) {
        e.printStackTrace();
        throw new StoreException(e.toString());
    }
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) StoreException(com.swiftmq.swiftlet.store.StoreException) StoreException(com.swiftmq.swiftlet.store.StoreException)

Example 13 with StoreException

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

the class DurableSubscriberStoreImpl method getDurableStoreEntry.

public synchronized DurableStoreEntry getDurableStoreEntry(String clientId, String durableName) throws StoreException {
    String filename = getDurableFilename(clientId, durableName);
    File f = new File(dir, filename);
    if (!f.exists())
        throw new StoreException(f.getAbsolutePath() + " does not exists");
    Map map = null;
    try {
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(f));
        map = (HashMap) ois.readObject();
        ois.close();
    } catch (Exception e) {
        throw new StoreException(e.toString());
    }
    DurableStoreEntry entry = new DurableStoreEntry(clientId, durableName, (String) map.get("topicName"), (String) map.get("selector"), map.get("noLocal") != null);
    return entry;
}
Also used : Map(java.util.Map) HashMap(java.util.HashMap) DurableStoreEntry(com.swiftmq.swiftlet.store.DurableStoreEntry) StoreException(com.swiftmq.swiftlet.store.StoreException) StoreException(com.swiftmq.swiftlet.store.StoreException)

Example 14 with StoreException

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

the class NonPersistentStoreImpl method delete.

public void delete(Object key) throws StoreException {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/delete, key=" + key);
    try {
        SwapAddress sa = (SwapAddress) key;
        sa.swapFile.remove(sa.filePointer);
        if (sa.swapFile.getNumberMessages() == 0) {
            sa.swapFile.close();
            swapFiles.remove(sa.swapFile);
            if (actSwapFile == sa.swapFile)
                actSwapFile = null;
        }
    } catch (Exception e) {
        throw new StoreException(e.getMessage());
    }
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/delete done, key=" + key);
}
Also used : SwapAddress(com.swiftmq.impl.store.standard.swap.SwapAddress) StoreException(com.swiftmq.swiftlet.store.StoreException) StoreException(com.swiftmq.swiftlet.store.StoreException)

Example 15 with StoreException

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

the class NonPersistentStoreImpl method updateDeliveryCount.

public void updateDeliveryCount(Object key, int deliveryCount) throws StoreException {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/updateDeliveryCount, key=" + key + ", deliveryCount=" + deliveryCount);
    try {
        SwapAddress sa = (SwapAddress) key;
        sa.swapFile.updateDeliveryCount(sa.filePointer, deliveryCount);
    } catch (Exception e) {
        throw new StoreException(e.getMessage());
    }
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/updateDeliveryCount done, key=" + key + ", deliveryCount=" + deliveryCount);
}
Also used : SwapAddress(com.swiftmq.impl.store.standard.swap.SwapAddress) 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