use of com.swiftmq.impl.store.standard.index.QueueIndexEntry in project swiftmq-ce by iitsoftware.
the class PersistentStoreImpl method getStoreEntries.
public List getStoreEntries() throws StoreException {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$store", toString() + "/getStoreEntries...");
if (closed)
throw new StoreException("Store is closed");
List entries = null;
try {
List qiEntries = queueIndex.getEntries();
queueIndex.unloadPages();
entries = new ArrayList(qiEntries.size());
for (int i = 0; i < qiEntries.size(); i++) {
QueueIndexEntry entry = (QueueIndexEntry) qiEntries.get(i);
StoreEntry storeEntry = new StoreEntry();
storeEntry.key = entry;
storeEntry.priority = entry.getPriority();
storeEntry.deliveryCount = entry.getDeliveryCount();
storeEntry.expirationTime = entry.getExpirationTime();
storeEntry.message = null;
entries.add(storeEntry);
}
} catch (Exception e) {
throw new StoreException(e.getMessage());
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$store", toString() + "/getStoreEntries done, entries.size()=" + entries.size());
return entries;
}
use of com.swiftmq.impl.store.standard.index.QueueIndexEntry 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.impl.store.standard.index.QueueIndexEntry in project swiftmq-ce by iitsoftware.
the class PrepareLogRecordImpl method readEntry.
private QueueIndexEntry readEntry(DataInput in) throws IOException {
int len = in.readInt();
if (buffer == null || buffer.length < len)
buffer = new byte[len];
in.readFully(buffer, 0, len);
QueueIndexEntry entry = new QueueIndexEntry();
entry.readContent(buffer, 0);
return entry;
}
use of com.swiftmq.impl.store.standard.index.QueueIndexEntry in project swiftmq-ce by iitsoftware.
the class PreparedLogQueue method preload.
private void preload() throws Exception {
List qiEntries = queueIndex.getEntries();
queueIndex.unloadPages();
for (int i = 0; i < qiEntries.size(); i++) {
QueueIndexEntry entry = (QueueIndexEntry) qiEntries.get(i);
StoreEntry storeEntry = queueIndex.get(entry);
BytesMessageImpl msg = (BytesMessageImpl) storeEntry.message;
byte[] b = new byte[(int) msg.getBodyLength()];
msg.readBytes(b);
inStream.setBuffer(b, 0, b.length);
PrepareLogRecordImpl logRecord = new PrepareLogRecordImpl(0);
logRecord.readContent(inStream);
CacheEntry cacheEntry = new CacheEntry();
cacheEntry.logRecord = logRecord;
long address = (long) ArrayListTool.setFirstFreeOrExpand(cache, cacheEntry);
logRecord.setAddress(address);
cacheEntry.indexEntry = entry;
}
queueIndex.unloadPages();
}
use of com.swiftmq.impl.store.standard.index.QueueIndexEntry in project swiftmq-ce by iitsoftware.
the class StoreReadTransactionImpl method commit.
public void commit() throws StoreException {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$store", toString() + "/commit...");
if (closed)
throw new StoreException("Transaction is closed");
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();
throw new StoreException(e.getMessage());
}
keys.clear();
super.commit();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$store", toString() + "/commit...done.");
}
Aggregations