Search in sources :

Example 1 with QueueEntryKey

use of org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom4To5.QueueEntryKey in project qpid-broker-j by apache.

the class UpgradeFrom4to5Test method assertDeliveriesForQueue.

private Set<Long> assertDeliveriesForQueue(final String queueName, final int expectedQueueSize) {
    final QueueEntryKeyBinding queueEntryKeyBinding = new QueueEntryKeyBinding();
    final AtomicInteger deliveryCounter = new AtomicInteger();
    final Set<Long> messagesForQueue = new HashSet<Long>();
    CursorOperation deliveryDatabaseOperation = new CursorOperation() {

        @Override
        public void processEntry(Database sourceDatabase, Database targetDatabase, Transaction transaction, DatabaseEntry key, DatabaseEntry value) {
            QueueEntryKey entryKey = queueEntryKeyBinding.entryToObject(key);
            String thisQueueName = entryKey.getQueueName().toString();
            if (thisQueueName.equals(queueName)) {
                deliveryCounter.incrementAndGet();
                messagesForQueue.add(entryKey.getMessageId());
            }
        }
    };
    new DatabaseTemplate(_environment, DELIVERY_DB_NAME, null).run(deliveryDatabaseOperation);
    assertEquals("Unxpected number of entries in delivery db for queue " + queueName, expectedQueueSize, deliveryCounter.get());
    return messagesForQueue;
}
Also used : QueueEntryKey(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom4To5.QueueEntryKey) Transaction(com.sleepycat.je.Transaction) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Database(com.sleepycat.je.Database) DatabaseEntry(com.sleepycat.je.DatabaseEntry) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) QueueEntryKeyBinding(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom4To5.QueueEntryKeyBinding) HashSet(java.util.HashSet)

Aggregations

Database (com.sleepycat.je.Database)1 DatabaseEntry (com.sleepycat.je.DatabaseEntry)1 Transaction (com.sleepycat.je.Transaction)1 HashSet (java.util.HashSet)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)1 QueueEntryKey (org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom4To5.QueueEntryKey)1 QueueEntryKeyBinding (org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom4To5.QueueEntryKeyBinding)1