use of com.sleepycat.je.Transaction in project GeoGig by boundlessgeo.
the class JEObjectDatabase method delete.
@Override
public boolean delete(final ObjectId id) {
checkWritable();
final byte[] rawKey = id.getRawValue();
final DatabaseEntry key = new DatabaseEntry(rawKey);
final Transaction transaction = newTransaction();
final OperationStatus status;
try {
status = objectDb.delete(transaction, key);
commit(transaction);
} catch (RuntimeException e) {
abort(transaction);
throw e;
}
return SUCCESS.equals(status);
}
use of com.sleepycat.je.Transaction in project GeoGig by boundlessgeo.
the class JEObjectDatabase method putInternal.
@Override
protected boolean putInternal(final ObjectId id, final byte[] rawData) {
checkWritable();
final Transaction transaction = newTransaction();
final OperationStatus status;
try {
status = putInternal(id, rawData, transaction);
commit(transaction);
} catch (RuntimeException e) {
abort(transaction);
throw e;
}
final boolean didntExist = SUCCESS.equals(status);
return didntExist;
}
use of com.sleepycat.je.Transaction in project qpid-broker-j by apache.
the class UpgradeFrom4to5Test method assertContentForQueue.
private void assertContentForQueue(String queueName, int expectedQueueSize, final Set<Long> messageIdsForQueue) {
final AtomicInteger contentCounter = new AtomicInteger();
final MessageContentKeyBinding keyBinding = new MessageContentKeyBinding();
CursorOperation cursorOperation = new CursorOperation() {
private long _prevMsgId = -1;
@Override
public void processEntry(Database sourceDatabase, Database targetDatabase, Transaction transaction, DatabaseEntry key, DatabaseEntry value) {
MessageContentKey contentKey = keyBinding.entryToObject(key);
long msgId = contentKey.getMessageId();
if (_prevMsgId != msgId && messageIdsForQueue.contains(msgId)) {
contentCounter.incrementAndGet();
}
_prevMsgId = msgId;
}
};
new DatabaseTemplate(_environment, MESSAGE_CONTENT_DB_NAME, null).run(cursorOperation);
assertEquals("Unxpected number of entries in content db for queue " + queueName, expectedQueueSize, contentCounter.get());
}
use of com.sleepycat.je.Transaction in project qpid-broker-j by apache.
the class UpgradeFrom4to5Test method loadBindings.
private List<BindingRecord> loadBindings() {
final BindingTuple bindingTuple = new BindingTuple();
final List<BindingRecord> queueBindings = new ArrayList<BindingRecord>();
CursorOperation databaseOperation = new CursorOperation() {
@Override
public void processEntry(Database sourceDatabase, Database targetDatabase, Transaction transaction, DatabaseEntry key, DatabaseEntry value) {
BindingRecord bindingRecord = bindingTuple.entryToObject(key);
AMQShortString queueName = bindingRecord.getQueueName();
AMQShortString exchangeName = bindingRecord.getExchangeName();
AMQShortString routingKey = bindingRecord.getRoutingKey();
FieldTable arguments = bindingRecord.getArguments();
queueBindings.add(new BindingRecord(exchangeName, queueName, routingKey, arguments));
}
};
new DatabaseTemplate(_environment, BINDING_DB_NAME, null).run(databaseOperation);
return queueBindings;
}
use of com.sleepycat.je.Transaction in project qpid-broker-j by apache.
the class UpgradeFrom4to5Test method assertMetadataForQueue.
private void assertMetadataForQueue(final String queueName, final int expectedQueueSize, final Set<Long> messageIdsForQueue) {
final AtomicInteger metadataCounter = new AtomicInteger();
CursorOperation databaseOperation = new CursorOperation() {
@Override
public void processEntry(Database sourceDatabase, Database targetDatabase, Transaction transaction, DatabaseEntry key, DatabaseEntry value) {
Long messageId = LongBinding.entryToLong(key);
boolean messageIsForTheRightQueue = messageIdsForQueue.contains(messageId);
if (messageIsForTheRightQueue) {
metadataCounter.incrementAndGet();
}
}
};
new DatabaseTemplate(_environment, MESSAGE_META_DATA_DB_NAME, null).run(databaseOperation);
assertEquals("Unxpected number of entries in metadata db for queue " + queueName, expectedQueueSize, metadataCounter.get());
}
Aggregations