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.");
}
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());
}
}
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;
}
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);
}
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);
}
Aggregations