Search in sources :

Example 1 with UpgradeConfiguredObjectRecord

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

the class UpgradeFrom5To6Test method assertConfiguredObjects.

private void assertConfiguredObjects() throws Exception {
    Map<UUID, UpgradeConfiguredObjectRecord> configuredObjects = loadConfiguredObjects();
    assertEquals("Unexpected number of configured objects", 21, configuredObjects.size());
    Set<Map<String, Object>> expected = new HashSet<Map<String, Object>>(12);
    List<UUID> expectedBindingIDs = new ArrayList<UUID>();
    expected.add(createExpectedQueueMap("myUpgradeQueue", Boolean.FALSE, null, null));
    expected.add(createExpectedQueueMap("clientid:mySelectorDurSubName", Boolean.TRUE, "clientid", null));
    expected.add(createExpectedQueueMap("clientid:myDurSubName", Boolean.TRUE, "clientid", null));
    final Map<String, Object> queueWithOwnerArguments = new HashMap<String, Object>();
    queueWithOwnerArguments.put(QueueArgumentsConverter.X_QPID_PRIORITIES, 10);
    queueWithOwnerArguments.put(QueueArgumentsConverter.X_QPID_DESCRIPTION, "misused-owner-as-description");
    expected.add(createExpectedQueueMap("nonexclusive-with-erroneous-owner", Boolean.FALSE, null, queueWithOwnerArguments));
    final Map<String, Object> priorityQueueArguments = new HashMap<String, Object>();
    priorityQueueArguments.put(QueueArgumentsConverter.X_QPID_PRIORITIES, 10);
    expected.add(createExpectedQueueMap(PRIORITY_QUEUE_NAME, Boolean.FALSE, null, priorityQueueArguments));
    final Map<String, Object> queueWithDLQArguments = new HashMap<String, Object>();
    queueWithDLQArguments.put("x-qpid-dlq-enabled", true);
    queueWithDLQArguments.put("x-qpid-maximum-delivery-count", 2);
    expected.add(createExpectedQueueMap(QUEUE_WITH_DLQ_NAME, Boolean.FALSE, null, queueWithDLQArguments));
    final Map<String, Object> dlqArguments = new HashMap<String, Object>();
    dlqArguments.put("x-qpid-dlq-enabled", false);
    dlqArguments.put("x-qpid-maximum-delivery-count", 0);
    expected.add(createExpectedQueueMap(QUEUE_WITH_DLQ_NAME + "_DLQ", Boolean.FALSE, null, dlqArguments));
    expected.add(createExpectedExchangeMap(QUEUE_WITH_DLQ_NAME + "_DLE", "fanout"));
    expected.add(createExpectedQueueBindingMapAndID("myUpgradeQueue", "myUpgradeQueue", "<<default>>", null, expectedBindingIDs));
    expected.add(createExpectedQueueBindingMapAndID("myUpgradeQueue", "myUpgradeQueue", "amq.direct", null, expectedBindingIDs));
    expected.add(createExpectedQueueBindingMapAndID("clientid:myDurSubName", "myUpgradeTopic", "amq.topic", Collections.singletonMap("x-filter-jms-selector", ""), expectedBindingIDs));
    expected.add(createExpectedQueueBindingMapAndID("clientid:mySelectorDurSubName", "mySelectorUpgradeTopic", "amq.topic", Collections.singletonMap("x-filter-jms-selector", "testprop='true'"), expectedBindingIDs));
    expected.add(createExpectedQueueBindingMapAndID("clientid:myDurSubName", "clientid:myDurSubName", "<<default>>", null, expectedBindingIDs));
    expected.add(createExpectedQueueBindingMapAndID("clientid:mySelectorDurSubName", "clientid:mySelectorDurSubName", "<<default>>", null, expectedBindingIDs));
    expected.add(createExpectedQueueBindingMapAndID("nonexclusive-with-erroneous-owner", "nonexclusive-with-erroneous-owner", "amq.direct", null, expectedBindingIDs));
    expected.add(createExpectedQueueBindingMapAndID("nonexclusive-with-erroneous-owner", "nonexclusive-with-erroneous-owner", "<<default>>", null, expectedBindingIDs));
    expected.add(createExpectedQueueBindingMapAndID(PRIORITY_QUEUE_NAME, PRIORITY_QUEUE_NAME, "<<default>>", null, expectedBindingIDs));
    expected.add(createExpectedQueueBindingMapAndID(PRIORITY_QUEUE_NAME, PRIORITY_QUEUE_NAME, "amq.direct", null, expectedBindingIDs));
    expected.add(createExpectedQueueBindingMapAndID(QUEUE_WITH_DLQ_NAME, QUEUE_WITH_DLQ_NAME, "<<default>>", null, expectedBindingIDs));
    expected.add(createExpectedQueueBindingMapAndID(QUEUE_WITH_DLQ_NAME, QUEUE_WITH_DLQ_NAME, "amq.direct", null, expectedBindingIDs));
    expected.add(createExpectedQueueBindingMapAndID(QUEUE_WITH_DLQ_NAME + "_DLQ", "dlq", QUEUE_WITH_DLQ_NAME + "_DLE", null, expectedBindingIDs));
    Set<String> expectedTypes = new HashSet<String>();
    expectedTypes.add(Queue.class.getName());
    expectedTypes.add(Exchange.class.getName());
    expectedTypes.add(Binding.class.getName());
    MapJsonSerializer jsonSerializer = new MapJsonSerializer();
    for (Entry<UUID, UpgradeConfiguredObjectRecord> entry : configuredObjects.entrySet()) {
        UpgradeConfiguredObjectRecord object = entry.getValue();
        Map<String, Object> deserialized = jsonSerializer.deserialize(object.getAttributes());
        assertTrue("Unexpected entry in a store - json [" + object.getAttributes() + "], map [" + deserialized + "]", expected.remove(deserialized));
        String type = object.getType();
        assertTrue("Unexpected type:" + type, expectedTypes.contains(type));
        UUID key = entry.getKey();
        assertNotNull("Key cannot be null", key);
        if (type.equals(Exchange.class.getName())) {
            String exchangeName = (String) deserialized.get(Exchange.NAME);
            assertNotNull(exchangeName);
            assertEquals("Unexpected key", key, UUIDGenerator.generateExchangeUUID(exchangeName, getVirtualHost().getName()));
        } else if (type.equals(Queue.class.getName())) {
            String queueName = (String) deserialized.get(Queue.NAME);
            assertNotNull(queueName);
            assertEquals("Unexpected key", key, UUIDGenerator.generateQueueUUID(queueName, getVirtualHost().getName()));
        } else if (type.equals(Binding.class.getName())) {
            assertTrue("unexpected binding id", expectedBindingIDs.remove(key));
        }
    }
    assertTrue("Not all expected configured objects found:" + expected, expected.isEmpty());
    assertTrue("Not all expected bindings found:" + expectedBindingIDs, expectedBindingIDs.isEmpty());
}
Also used : LongBinding(com.sleepycat.bind.tuple.LongBinding) NewPreparedTransactionBinding(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.NewPreparedTransactionBinding) Binding(org.apache.qpid.server.model.Binding) ConfiguredObjectBinding(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.ConfiguredObjectBinding) XidBinding(org.apache.qpid.server.store.berkeleydb.tuple.XidBinding) UpgradeUUIDBinding(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.UpgradeUUIDBinding) CompoundKeyBinding(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.CompoundKeyBinding) OldPreparedTransactionBinding(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.OldPreparedTransactionBinding) NewDataBinding(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.NewDataBinding) NewQueueEntryBinding(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.NewQueueEntryBinding) UpgradeConfiguredObjectRecord(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.UpgradeConfiguredObjectRecord) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Exchange(org.apache.qpid.server.model.Exchange) UUID(java.util.UUID) Map(java.util.Map) HashMap(java.util.HashMap) Queue(org.apache.qpid.server.model.Queue) HashSet(java.util.HashSet)

Example 2 with UpgradeConfiguredObjectRecord

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

the class UpgradeFrom5To6Test method loadConfiguredObjects.

private Map<UUID, UpgradeConfiguredObjectRecord> loadConfiguredObjects() {
    final Map<UUID, UpgradeConfiguredObjectRecord> configuredObjectsRecords = new HashMap<UUID, UpgradeConfiguredObjectRecord>();
    final ConfiguredObjectBinding binding = new ConfiguredObjectBinding();
    final UpgradeUUIDBinding uuidBinding = new UpgradeUUIDBinding();
    CursorOperation configuredObjectsCursor = new CursorOperation() {

        @Override
        public void processEntry(Database sourceDatabase, Database targetDatabase, Transaction transaction, DatabaseEntry key, DatabaseEntry value) {
            UUID id = uuidBinding.entryToObject(key);
            UpgradeConfiguredObjectRecord object = binding.entryToObject(value);
            configuredObjectsRecords.put(id, object);
        }
    };
    new DatabaseTemplate(_environment, CONFIGURED_OBJECTS_DB_NAME, null).run(configuredObjectsCursor);
    return configuredObjectsRecords;
}
Also used : UpgradeUUIDBinding(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.UpgradeUUIDBinding) ConfiguredObjectBinding(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.ConfiguredObjectBinding) NewPreparedTransaction(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.NewPreparedTransaction) OldPreparedTransaction(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.OldPreparedTransaction) Transaction(com.sleepycat.je.Transaction) UpgradeConfiguredObjectRecord(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.UpgradeConfiguredObjectRecord) HashMap(java.util.HashMap) Database(com.sleepycat.je.Database) DatabaseEntry(com.sleepycat.je.DatabaseEntry) UUID(java.util.UUID)

Example 3 with UpgradeConfiguredObjectRecord

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

the class UpgradeFrom5To6Test method assertQueueEntries.

private void assertQueueEntries() {
    final Map<UUID, UpgradeConfiguredObjectRecord> configuredObjects = loadConfiguredObjects();
    final NewQueueEntryBinding newBinding = new NewQueueEntryBinding();
    CursorOperation cursorOperation = new CursorOperation() {

        @Override
        public void processEntry(Database sourceDatabase, Database targetDatabase, Transaction transaction, DatabaseEntry key, DatabaseEntry value) {
            NewQueueEntryKey newEntryRecord = newBinding.entryToObject(key);
            assertTrue("Unexpected queue id", configuredObjects.containsKey(newEntryRecord.getQueueId()));
        }
    };
    new DatabaseTemplate(_environment, NEW_DELIVERY_DB_NAME, null).run(cursorOperation);
}
Also used : NewPreparedTransaction(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.NewPreparedTransaction) OldPreparedTransaction(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.OldPreparedTransaction) Transaction(com.sleepycat.je.Transaction) UpgradeConfiguredObjectRecord(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.UpgradeConfiguredObjectRecord) NewQueueEntryKey(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.NewQueueEntryKey) Database(com.sleepycat.je.Database) DatabaseEntry(com.sleepycat.je.DatabaseEntry) UUID(java.util.UUID) NewQueueEntryBinding(org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.NewQueueEntryBinding)

Aggregations

UUID (java.util.UUID)3 UpgradeConfiguredObjectRecord (org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.UpgradeConfiguredObjectRecord)3 Database (com.sleepycat.je.Database)2 DatabaseEntry (com.sleepycat.je.DatabaseEntry)2 Transaction (com.sleepycat.je.Transaction)2 HashMap (java.util.HashMap)2 ConfiguredObjectBinding (org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.ConfiguredObjectBinding)2 NewPreparedTransaction (org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.NewPreparedTransaction)2 NewQueueEntryBinding (org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.NewQueueEntryBinding)2 OldPreparedTransaction (org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.OldPreparedTransaction)2 UpgradeUUIDBinding (org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.UpgradeUUIDBinding)2 LongBinding (com.sleepycat.bind.tuple.LongBinding)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Binding (org.apache.qpid.server.model.Binding)1 Exchange (org.apache.qpid.server.model.Exchange)1 Queue (org.apache.qpid.server.model.Queue)1 XidBinding (org.apache.qpid.server.store.berkeleydb.tuple.XidBinding)1 CompoundKeyBinding (org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.CompoundKeyBinding)1