use of org.apache.qpid.server.store.berkeleydb.entry.HierarchyKey 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.entry.HierarchyKey in project qpid-broker-j by apache.
the class BDBConfigurationStore method doVisitAllConfiguredObjectRecords.
private Collection<? extends ConfiguredObjectRecord> doVisitAllConfiguredObjectRecords() {
Map<UUID, BDBConfiguredObjectRecord> configuredObjects = new HashMap<>();
try (Cursor objectsCursor = getConfiguredObjectsDb().openCursor(null, null)) {
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry value = new DatabaseEntry();
while (objectsCursor.getNext(key, value, LockMode.READ_UNCOMMITTED) == OperationStatus.SUCCESS) {
UUID id = UUIDTupleBinding.getInstance().entryToObject(key);
BDBConfiguredObjectRecord configuredObject = (BDBConfiguredObjectRecord) new ConfiguredObjectBinding(id).entryToObject(value);
configuredObjects.put(configuredObject.getId(), configuredObject);
}
// set parents
try (Cursor hierarchyCursor = getConfiguredObjectHierarchyDb().openCursor(null, null)) {
while (hierarchyCursor.getNext(key, value, LockMode.READ_UNCOMMITTED) == OperationStatus.SUCCESS) {
HierarchyKey hk = HierarchyKeyBinding.getInstance().entryToObject(key);
UUID parentId = UUIDTupleBinding.getInstance().entryToObject(value);
BDBConfiguredObjectRecord child = configuredObjects.get(hk.getChildId());
if (child != null) {
ConfiguredObjectRecord parent = configuredObjects.get(parentId);
if (parent != null) {
child.addParent(hk.getParentType(), parent);
}
}
}
}
}
return configuredObjects.values();
}
use of org.apache.qpid.server.store.berkeleydb.entry.HierarchyKey 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 org.apache.qpid.server.store.berkeleydb.entry.HierarchyKey in project qpid-broker-j by apache.
the class HierarchyKeyBinding method entryToObject.
@Override
public HierarchyKey entryToObject(TupleInput tupleInput) {
UUID childId = new UUID(tupleInput.readLong(), tupleInput.readLong());
String parentType = tupleInput.readString();
return new HierarchyKey(childId, parentType);
}
Aggregations