Search in sources :

Example 26 with Transaction

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;
}
Also used : Transaction(com.sleepycat.je.Transaction) HashMap(java.util.HashMap) Database(com.sleepycat.je.Database) DatabaseEntry(com.sleepycat.je.DatabaseEntry) UUID(java.util.UUID)

Example 27 with Transaction

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();
}
Also used : Transaction(com.sleepycat.je.Transaction)

Example 28 with Transaction

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();
}
Also used : Transaction(com.sleepycat.je.Transaction)

Example 29 with Transaction

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");
    }
}
Also used : DatabaseEntry(com.sleepycat.je.DatabaseEntry) Transaction(com.sleepycat.je.Transaction) Database(com.sleepycat.je.Database) UUID(java.util.UUID)

Example 30 with Transaction

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");
    }
}
Also used : Transaction(com.sleepycat.je.Transaction) Database(com.sleepycat.je.Database) DatabaseEntry(com.sleepycat.je.DatabaseEntry) UUID(java.util.UUID)

Aggregations

Transaction (com.sleepycat.je.Transaction)74 DatabaseEntry (com.sleepycat.je.DatabaseEntry)55 Database (com.sleepycat.je.Database)35 OperationStatus (com.sleepycat.je.OperationStatus)20 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)12 UUID (java.util.UUID)11 Cursor (com.sleepycat.je.Cursor)10 DatabaseConfig (com.sleepycat.je.DatabaseConfig)7 DatabaseException (com.sleepycat.je.DatabaseException)6 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)6 Environment (com.sleepycat.je.Environment)5 HashMap (java.util.HashMap)5 FieldTable (org.apache.qpid.server.protocol.v0_8.FieldTable)5 NewPreparedTransaction (org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.NewPreparedTransaction)5 OldPreparedTransaction (org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.OldPreparedTransaction)5 EnvironmentConfig (com.sleepycat.je.EnvironmentConfig)4 StoreException (org.apache.qpid.server.store.StoreException)4 TupleOutput (com.sleepycat.bind.tuple.TupleOutput)3 LockMode (com.sleepycat.je.LockMode)3