use of org.apache.qpid.server.store.berkeleydb.tuple.HierarchyKeyBinding in project qpid-broker-j by apache.
the class BDBConfigurationStore method writeHierarchyRecords.
private void writeHierarchyRecords(final Transaction txn, final ConfiguredObjectRecord configuredObject) {
OperationStatus status;
HierarchyKeyBinding hierarchyBinding = HierarchyKeyBinding.getInstance();
DatabaseEntry hierarchyKey = new DatabaseEntry();
DatabaseEntry hierarchyValue = new DatabaseEntry();
for (Map.Entry<String, UUID> parent : configuredObject.getParents().entrySet()) {
hierarchyBinding.objectToEntry(new HierarchyKey(configuredObject.getId(), parent.getKey()), hierarchyKey);
UUIDTupleBinding.getInstance().objectToEntry(parent.getValue(), hierarchyValue);
status = getConfiguredObjectHierarchyDb().put(txn, hierarchyKey, hierarchyValue);
if (status != OperationStatus.SUCCESS) {
throw new StoreException("Error writing configured object " + configuredObject + " parent record to database: " + status);
}
}
}
use of org.apache.qpid.server.store.berkeleydb.tuple.HierarchyKeyBinding 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;
}
Aggregations