use of com.swiftmq.swiftlet.store.StoreEntry 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.StoreEntry 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.swiftlet.store.StoreEntry in project swiftmq-ce by iitsoftware.
the class PreparedLogQueue method add.
public synchronized long add(PrepareLogRecordImpl logRecord) throws IOException {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$store", toString() + "/add, logRecord: " + logRecord);
CacheEntry cacheEntry = new CacheEntry();
cacheEntry.logRecord = logRecord;
long address = (long) ArrayListTool.setFirstFreeOrExpand(cache, cacheEntry);
logRecord.setAddress(address);
outStream.rewind();
logRecord.writeContent(outStream);
try {
BytesMessageImpl msg = new BytesMessageImpl();
msg.writeBytes(outStream.getBuffer(), 0, outStream.getCount());
StoreEntry storeEntry = new StoreEntry();
storeEntry.message = msg;
long txId = ctx.transactionManager.createTxId(false);
List journal = new ArrayList();
queueIndex.setJournal(journal);
cacheEntry.indexEntry = queueIndex.add(storeEntry);
Semaphore sem = new Semaphore();
ctx.recoveryManager.commit(new CommitLogRecord(txId, sem, journal, this, null));
sem.waitHere();
ctx.transactionManager.removeTxId(txId);
} catch (Exception e) {
throw new IOException(e.toString());
}
return address;
}
use of com.swiftmq.swiftlet.store.StoreEntry in project swiftmq-ce by iitsoftware.
the class QueueIndex method get.
public StoreEntry get(QueueIndexEntry indexEntry) throws Exception {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$store", toString() + "/get, indexEntry=" + indexEntry);
pis.setRootPageNo(indexEntry.getRootPageNo());
StoreEntry storeEntry = new StoreEntry();
storeEntry.key = indexEntry;
storeEntry.priority = indexEntry.getPriority();
storeEntry.deliveryCount = indexEntry.getDeliveryCount();
storeEntry.expirationTime = indexEntry.getExpirationTime();
storeEntry.message = MessageImpl.createInstance(pis.readInt());
storeEntry.message.readContent(pis);
pis.unloadPages();
pis.reset();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$store", toString() + "/get, returns=" + storeEntry);
return storeEntry;
}
use of com.swiftmq.swiftlet.store.StoreEntry in project swiftmq-ce by iitsoftware.
the class SwapFileImpl method get.
public StoreEntry get(long fp) throws Exception {
file.seek(fp);
int len = file.readInt();
if (buffer.length - 1 < len) {
buffer = new byte[len];
dis.setBuffer(buffer);
}
file.read(buffer, 0, len);
StoreEntry storeEntry = new StoreEntry();
storeEntry.key = null;
storeEntry.deliveryCount = dis.readInt();
storeEntry.message = MessageImpl.createInstance(dis.readInt());
storeEntry.message.readContent(dis);
dis.reset();
return storeEntry;
}
Aggregations