Search in sources :

Example 1 with MessageContentKey

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

the class UpgradeFrom4to5Test method assertContentForQueue.

private void assertContentForQueue(String queueName, int expectedQueueSize, final Set<Long> messageIdsForQueue) {
    final AtomicInteger contentCounter = new AtomicInteger();
    final MessageContentKeyBinding keyBinding = new MessageContentKeyBinding();
    CursorOperation cursorOperation = new CursorOperation() {

        private long _prevMsgId = -1;

        @Override
        public void processEntry(Database sourceDatabase, Database targetDatabase, Transaction transaction, DatabaseEntry key, DatabaseEntry value) {
            MessageContentKey contentKey = keyBinding.entryToObject(key);
            long msgId = contentKey.getMessageId();
            if (_prevMsgId != msgId && messageIdsForQueue.contains(msgId)) {
                contentCounter.incrementAndGet();
            }
            _prevMsgId = msgId;
        }
    };
    new DatabaseTemplate(_environment, MESSAGE_CONTENT_DB_NAME, null).run(cursorOperation);
    assertEquals("Unxpected number of entries in content db for queue " + queueName, expectedQueueSize, contentCounter.get());
}
Also used : MessageContentKeyBinding(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom4To5.MessageContentKeyBinding) Transaction(com.sleepycat.je.Transaction) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Database(com.sleepycat.je.Database) DatabaseEntry(com.sleepycat.je.DatabaseEntry) MessageContentKey(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom4To5.MessageContentKey)

Aggregations

Database (com.sleepycat.je.Database)1 DatabaseEntry (com.sleepycat.je.DatabaseEntry)1 Transaction (com.sleepycat.je.Transaction)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 MessageContentKey (org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom4To5.MessageContentKey)1 MessageContentKeyBinding (org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom4To5.MessageContentKeyBinding)1