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