use of com.swiftmq.swiftlet.store.StoreEntry in project swiftmq-ce by iitsoftware.
the class IndexAnalyzer method checkPage.
private PR checkPage(QueueIndexPage p) throws Exception {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$store", toString() + "/checkPage, p=" + p + " ...");
PR pagePR = new PR();
List entries = new ArrayList();
for (Iterator iter = p.iterator(); iter.hasNext(); ) {
IndexEntry entry = (IndexEntry) iter.next();
if (entry.isValid())
entries.add(entry);
}
for (Iterator iter = entries.iterator(); iter.hasNext(); ) {
QueueIndexEntry entry = (QueueIndexEntry) iter.next();
try {
PR elementPR = new PR();
PageInputStream pis = new PageInputStream(ctx);
pis.setPageRecorder(elementPR);
pis.setRootPageNo(entry.getRootPageNo());
StoreEntry storeEntry = new StoreEntry();
storeEntry.key = entry;
storeEntry.priority = entry.getPriority();
storeEntry.deliveryCount = entry.getDeliveryCount();
storeEntry.expirationTime = entry.getExpirationTime();
storeEntry.message = MessageImpl.createInstance(pis.readInt());
storeEntry.message.readContent(pis);
pis.unloadPages();
pis.reset();
pagePR.addAll(elementPR);
} catch (Exception e) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$store", toString() + "/checkPage, p=" + p + ", entry=" + entry + ", exception=" + e);
throw e;
}
}
try {
ctx.cacheManager.shrink();
} catch (Exception e) {
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$store", toString() + "/checkPage, p=" + p + " done");
return pagePR;
}
use of com.swiftmq.swiftlet.store.StoreEntry in project swiftmq-ce by iitsoftware.
the class CacheImpl method put.
public void put(StoreId storeId, MessageImpl message) throws Exception {
long msgSize = message.getMessageLength();
storeId.setMsgSize(msgSize);
if (cacheTable.size() < maxMessages && currentBytes + msgSize < maxBytes) {
cacheTable.put(storeId, new MessageEntry(storeId, message));
currentBytes += msgSize;
} else {
// rollback, it is!)
if (!storeId.isPersistent() && cacheTable.get(storeId) == null) {
StoreEntry se = new StoreEntry();
se.priority = storeId.getPriority();
se.deliveryCount = storeId.getDeliveryCount();
se.expirationTime = storeId.getExpirationTime();
se.message = message;
swapStore.insert(se);
se.message = null;
storeId.setPersistentKey(se);
}
}
}
use of com.swiftmq.swiftlet.store.StoreEntry in project swiftmq-ce by iitsoftware.
the class CacheImpl method get.
public MessageEntry get(StoreId storeId) throws Exception {
MessageEntry me = (MessageEntry) cacheTable.get(storeId);
if (me == null) {
me = new MessageEntry();
me.setMessageIndex(storeId);
if (storeId.isPersistent())
me.setMessage(((StoreEntry) pStore.get(((StoreEntry) storeId.getPersistentKey()).key)).message);
else
me.setMessage(((StoreEntry) swapStore.get(((StoreEntry) storeId.getPersistentKey()).key)).message);
storeId.setMsgSize(me.getMessage().getMessageLength());
}
return me;
}
Aggregations