Search in sources :

Example 1 with QueueRecord

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

the class UpgradeFrom4to5Test method assertQueues.

private void assertQueues(Set<String> expectedQueueNames) {
    List<AMQShortString> durableSubNames = Collections.emptyList();
    final UpgradeFrom4To5.QueueRecordBinding binding = new UpgradeFrom4To5.QueueRecordBinding(durableSubNames);
    final Set<String> actualQueueNames = new HashSet<String>();
    CursorOperation queueNameCollector = new CursorOperation() {

        @Override
        public void processEntry(Database sourceDatabase, Database targetDatabase, Transaction transaction, DatabaseEntry key, DatabaseEntry value) {
            QueueRecord record = binding.entryToObject(value);
            String queueName = record.getNameShortString().toString();
            actualQueueNames.add(queueName);
        }
    };
    new DatabaseTemplate(_environment, "queueDb_v5", null).run(queueNameCollector);
    assertEquals("Unexpected queue names", expectedQueueNames, actualQueueNames);
}
Also used : AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) DatabaseEntry(com.sleepycat.je.DatabaseEntry) Transaction(com.sleepycat.je.Transaction) QueueRecord(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom4To5.QueueRecord) Database(com.sleepycat.je.Database) HashSet(java.util.HashSet)

Example 2 with QueueRecord

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

the class UpgradeFrom4to5Test method assertQueueHasOwner.

private void assertQueueHasOwner(String queueName, final String expectedOwner) {
    List<AMQShortString> durableSubNames = Collections.emptyList();
    final UpgradeFrom4To5.QueueRecordBinding binding = new UpgradeFrom4To5.QueueRecordBinding(durableSubNames);
    final AtomicReference<String> actualOwner = new AtomicReference<String>();
    final AtomicBoolean foundQueue = new AtomicBoolean(false);
    CursorOperation queueNameCollector = new CursorOperation() {

        @Override
        public void processEntry(Database sourceDatabase, Database targetDatabase, Transaction transaction, DatabaseEntry key, DatabaseEntry value) {
            QueueRecord record = binding.entryToObject(value);
            String queueName = record.getNameShortString().toString();
            if (queueName.equals(queueName)) {
                foundQueue.set(true);
                actualOwner.set(AMQShortString.toString(record.getOwner()));
            }
        }
    };
    new DatabaseTemplate(_environment, "queueDb_v5", null).run(queueNameCollector);
    assertTrue("Could not find queue in database", foundQueue.get());
    assertEquals("Queue has unexpected owner", expectedOwner, actualOwner.get());
}
Also used : AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) AtomicReference(java.util.concurrent.atomic.AtomicReference) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) DatabaseEntry(com.sleepycat.je.DatabaseEntry) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Transaction(com.sleepycat.je.Transaction) QueueRecord(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom4To5.QueueRecord) Database(com.sleepycat.je.Database)

Aggregations

Database (com.sleepycat.je.Database)2 DatabaseEntry (com.sleepycat.je.DatabaseEntry)2 Transaction (com.sleepycat.je.Transaction)2 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)2 QueueRecord (org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom4To5.QueueRecord)2 HashSet (java.util.HashSet)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1