use of com.sleepycat.je.Transaction in project qpid-broker-j by apache.
the class UpgradeFrom7To8Test method loadConfiguredObjectHierarchy.
private Map<UpgradeHierarchyKey, UUID> loadConfiguredObjectHierarchy() {
final Map<UpgradeHierarchyKey, UUID> hierarchyRecords = new HashMap<UpgradeHierarchyKey, UUID>();
final UpgradeHierarchyKeyBinding hierarchyKeyBinding = new UpgradeHierarchyKeyBinding();
final UpgradeUUIDBinding uuidParentBinding = new UpgradeUUIDBinding();
CursorOperation hierarchyCursor = new CursorOperation() {
@Override
public void processEntry(Database sourceDatabase, Database targetDatabase, Transaction transaction, DatabaseEntry key, DatabaseEntry value) {
UpgradeHierarchyKey hierarchyKey = hierarchyKeyBinding.entryToObject(key);
UUID parentId = uuidParentBinding.entryToObject(value);
hierarchyRecords.put(hierarchyKey, parentId);
}
};
new DatabaseTemplate(_environment, CONFIGURED_OBJECT_HIERARCHY_DB_NAME, null).run(hierarchyCursor);
return hierarchyRecords;
}
use of com.sleepycat.je.Transaction in project qpid-broker-j by apache.
the class UpgradeFrom5To6 method upgradeMessages.
private void upgradeMessages(final Environment environment, final UpgradeInteractionHandler handler) {
Transaction transaction = null;
transaction = environment.beginTransaction(null, null);
upgradeMessages(environment, handler, transaction);
transaction.commit();
}
use of com.sleepycat.je.Transaction in project qpid-broker-j by apache.
the class UpgradeFrom5To6 method upgradeConfiguredObjectsAndDependencies.
private void upgradeConfiguredObjectsAndDependencies(Environment environment, UpgradeInteractionHandler handler, String virtualHostName) {
Transaction transaction = null;
transaction = environment.beginTransaction(null, null);
upgradeConfiguredObjects(environment, handler, transaction, virtualHostName);
upgradeQueueEntries(environment, transaction, virtualHostName);
upgradeXidEntries(environment, transaction, virtualHostName);
transaction.commit();
}
use of com.sleepycat.je.Transaction in project qpid-broker-j by apache.
the class UpgradeFrom5To6 method upgradeXidEntries.
private void upgradeXidEntries(Environment environment, Transaction transaction, final String virtualHostName) {
if (environment.getDatabaseNames().contains(OLD_XID_DB_NAME)) {
LOGGER.info("Xid Records");
final OldPreparedTransactionBinding oldTransactionBinding = new OldPreparedTransactionBinding();
final NewPreparedTransactionBinding newTransactionBinding = new NewPreparedTransactionBinding();
CursorOperation xidEntriesCursor = new CursorOperation() {
@Override
public void processEntry(Database oldXidDatabase, Database newXidDatabase, Transaction transaction, DatabaseEntry key, DatabaseEntry value) {
OldPreparedTransaction oldPreparedTransaction = oldTransactionBinding.entryToObject(value);
OldRecordImpl[] oldDequeues = oldPreparedTransaction.getDequeues();
OldRecordImpl[] oldEnqueues = oldPreparedTransaction.getEnqueues();
NewRecordImpl[] newEnqueues = null;
NewRecordImpl[] newDequeues = null;
if (oldDequeues != null) {
newDequeues = new NewRecordImpl[oldDequeues.length];
for (int i = 0; i < newDequeues.length; i++) {
OldRecordImpl dequeue = oldDequeues[i];
UUID id = UUIDGenerator.generateQueueUUID(dequeue.getQueueName(), virtualHostName);
newDequeues[i] = new NewRecordImpl(id, dequeue.getMessageNumber());
}
}
if (oldEnqueues != null) {
newEnqueues = new NewRecordImpl[oldEnqueues.length];
for (int i = 0; i < newEnqueues.length; i++) {
OldRecordImpl enqueue = oldEnqueues[i];
UUID id = UUIDGenerator.generateQueueUUID(enqueue.getQueueName(), virtualHostName);
newEnqueues[i] = new NewRecordImpl(id, enqueue.getMessageNumber());
}
}
NewPreparedTransaction newPreparedTransaction = new NewPreparedTransaction(newEnqueues, newDequeues);
DatabaseEntry newValue = new DatabaseEntry();
newTransactionBinding.objectToEntry(newPreparedTransaction, newValue);
put(newXidDatabase, transaction, key, newValue);
}
};
new DatabaseTemplate(environment, OLD_XID_DB_NAME, NEW_XID_DB_NAME, transaction).run(xidEntriesCursor);
environment.removeDatabase(transaction, OLD_XID_DB_NAME);
LOGGER.info(xidEntriesCursor.getRowCount() + " Xid Entries");
}
}
use of com.sleepycat.je.Transaction in project qpid-broker-j by apache.
the class UpgradeFrom5To6 method upgradeQueueEntries.
private void upgradeQueueEntries(Environment environment, Transaction transaction, final String virtualHostName) {
LOGGER.info("Queue Delivery Records");
if (environment.getDatabaseNames().contains(OLD_DELIVERY_DB_NAME)) {
final OldQueueEntryBinding oldBinding = new OldQueueEntryBinding();
final NewQueueEntryBinding newBinding = new NewQueueEntryBinding();
CursorOperation queueEntriesCursor = new CursorOperation() {
@Override
public void processEntry(Database oldDeliveryDatabase, Database newDeliveryDatabase, Transaction transaction, DatabaseEntry key, DatabaseEntry value) {
OldQueueEntryKey oldEntryRecord = oldBinding.entryToObject(key);
UUID queueId = UUIDGenerator.generateQueueUUID(oldEntryRecord.getQueueName().toString(), virtualHostName);
NewQueueEntryKey newEntryRecord = new NewQueueEntryKey(queueId, oldEntryRecord.getMessageId());
DatabaseEntry newKey = new DatabaseEntry();
newBinding.objectToEntry(newEntryRecord, newKey);
put(newDeliveryDatabase, transaction, newKey, value);
}
};
new DatabaseTemplate(environment, OLD_DELIVERY_DB_NAME, NEW_DELIVERY_DB_NAME, transaction).run(queueEntriesCursor);
environment.removeDatabase(transaction, OLD_DELIVERY_DB_NAME);
LOGGER.info(queueEntriesCursor.getRowCount() + " Queue Delivery Record Entries");
}
}
Aggregations