use of com.sleepycat.je.OperationStatus in project qpid-broker-j by apache.
the class AbstractBDBMessageStore method getAllContent.
QpidByteBuffer getAllContent(long messageId) throws StoreException {
DatabaseEntry contentKeyEntry = new DatabaseEntry();
LongBinding.longToEntry(messageId, contentKeyEntry);
DatabaseEntry value = new DatabaseEntry();
getLogger().debug("Message Id: {} Getting content body", messageId);
try {
OperationStatus status = getMessageContentDb().get(null, contentKeyEntry, value, LockMode.READ_UNCOMMITTED);
if (status == OperationStatus.SUCCESS) {
byte[] data = value.getData();
int offset = value.getOffset();
int length = value.getSize();
QpidByteBuffer buf = QpidByteBuffer.allocateDirect(length);
buf.put(data, offset, length);
buf.flip();
return buf;
} else {
throw new StoreException("Unable to find message with id " + messageId);
}
} catch (RuntimeException e) {
throw getEnvironmentFacade().handleDatabaseException("Error getting AMQMessage with id " + messageId + " to database: " + e.getMessage(), e);
}
}
use of com.sleepycat.je.OperationStatus in project qpid-broker-j by apache.
the class BDBConfigurationStore method update.
private void update(boolean createIfNecessary, ConfiguredObjectRecord record, com.sleepycat.je.Transaction txn) throws StoreException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Updating, creating " + createIfNecessary + " : " + record);
}
DatabaseEntry key = new DatabaseEntry();
UUIDTupleBinding keyBinding = UUIDTupleBinding.getInstance();
keyBinding.objectToEntry(record.getId(), key);
DatabaseEntry value = new DatabaseEntry();
DatabaseEntry newValue = new DatabaseEntry();
ConfiguredObjectBinding configuredObjectBinding = ConfiguredObjectBinding.getInstance();
OperationStatus status = getConfiguredObjectsDb().get(txn, key, value, LockMode.DEFAULT);
final boolean isNewRecord = status == OperationStatus.NOTFOUND;
if (status == OperationStatus.SUCCESS || (createIfNecessary && isNewRecord)) {
// write the updated entry to the store
configuredObjectBinding.objectToEntry(record, newValue);
status = getConfiguredObjectsDb().put(txn, key, newValue);
if (status != OperationStatus.SUCCESS) {
throw new StoreException("Error updating configuration details within the store: " + status);
}
if (isNewRecord) {
writeHierarchyRecords(txn, record);
}
} else if (status != OperationStatus.NOTFOUND) {
throw new StoreException("Error finding configuration details within the store: " + status);
}
}
use of com.sleepycat.je.OperationStatus in project qpid-broker-j by apache.
the class BDBConfigurationStore method removeConfiguredObject.
private OperationStatus removeConfiguredObject(Transaction tx, ConfiguredObjectRecord record) throws StoreException {
UUID id = record.getId();
Map<String, UUID> parents = record.getParents();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Removing configured object: " + id);
}
DatabaseEntry key = new DatabaseEntry();
UUIDTupleBinding uuidBinding = UUIDTupleBinding.getInstance();
uuidBinding.objectToEntry(id, key);
OperationStatus status = getConfiguredObjectsDb().delete(tx, key);
if (status == OperationStatus.SUCCESS) {
for (String parentType : parents.keySet()) {
DatabaseEntry hierarchyKey = new DatabaseEntry();
HierarchyKeyBinding keyBinding = HierarchyKeyBinding.getInstance();
keyBinding.objectToEntry(new HierarchyKey(record.getId(), parentType), hierarchyKey);
getConfiguredObjectHierarchyDb().delete(tx, hierarchyKey);
}
}
return status;
}
use of com.sleepycat.je.OperationStatus in project bboxdb by jnidzwetzki.
the class FileLineIndex method locateLine.
/**
* Get the content of the line
* @param lineNumber
* @return
*/
public long locateLine(final long line) {
if (database == null) {
throw new IllegalArgumentException("No database is open, please index file first");
}
if (line >= indexedLines) {
throw new IllegalArgumentException("Line " + line + " is higher then indexedLines: " + (indexedLines - 1));
}
final DatabaseEntry key = buildDatabaseEntry(line);
final DatabaseEntry value = new DatabaseEntry();
final OperationStatus result = database.get(null, key, value, LockMode.DEFAULT);
if (result != OperationStatus.SUCCESS) {
throw new RuntimeException("Data fetch got status " + result + " for " + line);
}
final long bytePos = DataEncoderHelper.readLongFromByte(value.getData());
return bytePos;
}
use of com.sleepycat.je.OperationStatus in project bboxdb by jnidzwetzki.
the class FileLineIndex method registerLine.
/**
* Register a new line in the index file
* @param line
* @param pos
*/
protected void registerLine(final long line, final long bytePos) {
final DatabaseEntry key = buildDatabaseEntry(line);
final DatabaseEntry value = buildDatabaseEntry(bytePos);
final OperationStatus status = database.put(null, key, value);
if (status != OperationStatus.SUCCESS) {
throw new RuntimeException("Data insertion, got status " + status);
}
}
Aggregations