qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject svn commit: r1355994 - in /qpid/trunk/qpid/java: bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/ bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/upgrade/ broker/src/main/java/org/apache/qpid/server/binding/ broker...
Date Sun, 01 Jul 2012 20:01:01 GMT
Author: robbie
Date: Sun Jul  1 20:00:59 2012
New Revision: 1355994

URL: http://svn.apache.org/viewvc?rev=1355994&view=rev
Log:
QPID-3923: update ID generation to be consistent across all queues/exchanges/bindings as opposed
to deterministic for some and not for others

Added:
    qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/model/
    qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/model/UUIDGeneratorTest.java
Modified:
    qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom5To6.java
    qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom5To6Test.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/binding/BindingFactory.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/UUIDGenerator.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/ExchangeAdapter.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSessionDelegate.java

Modified: qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom5To6.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom5To6.java?rev=1355994&r1=1355993&r2=1355994&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom5To6.java
(original)
+++ qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom5To6.java
Sun Jul  1 20:00:59 2012
@@ -383,7 +383,7 @@ public class UpgradeFrom5To6 extends Abs
                         for (int i = 0; i < newDequeues.length; i++)
                         {
                             OldRecordImpl dequeue = oldDequeues[i];
-                            UUID id = UUIDGenerator.generateUUID(dequeue.getQueueName(),
virtualHostName);
+                            UUID id = UUIDGenerator.generateQueueUUID(dequeue.getQueueName(),
virtualHostName);
                             newDequeues[i] = new NewRecordImpl(id, dequeue.getMessageNumber());
                         }
                     }
@@ -393,7 +393,7 @@ public class UpgradeFrom5To6 extends Abs
                         for (int i = 0; i < newEnqueues.length; i++)
                         {
                             OldRecordImpl enqueue = oldEnqueues[i];
-                            UUID id = UUIDGenerator.generateUUID(enqueue.getQueueName(),
virtualHostName);
+                            UUID id = UUIDGenerator.generateQueueUUID(enqueue.getQueueName(),
virtualHostName);
                             newEnqueues[i] = new NewRecordImpl(id, enqueue.getMessageNumber());
                         }
                     }
@@ -423,7 +423,7 @@ public class UpgradeFrom5To6 extends Abs
                         Transaction transaction, DatabaseEntry key, DatabaseEntry value)
                 {
                     OldQueueEntryKey oldEntryRecord = oldBinding.entryToObject(key);
-                    UUID queueId = UUIDGenerator.generateUUID(oldEntryRecord.getQueueName().asString(),
virtualHostName);
+                    UUID queueId = UUIDGenerator.generateQueueUUID(oldEntryRecord.getQueueName().asString(),
virtualHostName);
 
                     NewQueueEntryKey newEntryRecord = new NewQueueEntryKey(queueId, oldEntryRecord.getMessageId());
                     DatabaseEntry newKey = new DatabaseEntry();
@@ -458,7 +458,7 @@ public class UpgradeFrom5To6 extends Abs
                     String routingKey = bindingRecord.getRoutingKey().asString();
                     FieldTable arguments = bindingRecord.getArguments();
 
-                    UUID bindingId = UUIDGenerator.generateUUID();
+                    UUID bindingId = UUIDGenerator.generateBindingUUID(exchangeName, queueName,
routingKey, virtualHostName);
                     UpgradeConfiguredObjectRecord configuredObject = createBindingConfiguredObjectRecord(exchangeName,
queueName,
                             routingKey, arguments, virtualHostName);
                     storeConfiguredObjectEntry(configuredObjectsDatabase, bindingId, configuredObject,
transaction);
@@ -492,7 +492,7 @@ public class UpgradeFrom5To6 extends Abs
                         String exchangeType = exchangeRecord.getType().asString();
                         boolean autoDelete = exchangeRecord.isAutoDelete();
 
-                        UUID exchangeId = UUIDGenerator.generateUUID(exchangeName, virtualHostName);
+                        UUID exchangeId = UUIDGenerator.generateExchangeUUID(exchangeName,
virtualHostName);
 
                         UpgradeConfiguredObjectRecord configuredObject = createExchangeConfiguredObjectRecord(exchangeName,
                                 exchangeType, autoDelete);
@@ -529,7 +529,7 @@ public class UpgradeFrom5To6 extends Abs
                     boolean exclusive = queueRecord.isExclusive();
                     FieldTable arguments = queueRecord.getArguments();
 
-                    UUID queueId = UUIDGenerator.generateUUID(queueName, virtualHostName);
+                    UUID queueId = UUIDGenerator.generateQueueUUID(queueName, virtualHostName);
                     UpgradeConfiguredObjectRecord configuredObject = createQueueConfiguredObjectRecord(queueName,
owner, exclusive,
                             arguments);
                     storeConfiguredObjectEntry(configuredObjectsDatabase, queueId, configuredObject,
transaction);
@@ -620,8 +620,8 @@ public class UpgradeFrom5To6 extends Abs
     {
         Map<String, Object> attributesMap = new HashMap<String, Object>();
         attributesMap.put(Binding.NAME, routingKey);
-        attributesMap.put(Binding.EXCHANGE, UUIDGenerator.generateUUID(exchangeName, virtualHostName));
-        attributesMap.put(Binding.QUEUE, UUIDGenerator.generateUUID(queueName, virtualHostName));
+        attributesMap.put(Binding.EXCHANGE, UUIDGenerator.generateExchangeUUID(exchangeName,
virtualHostName));
+        attributesMap.put(Binding.QUEUE, UUIDGenerator.generateQueueUUID(queueName, virtualHostName));
         if (arguments != null)
         {
             attributesMap.put(Binding.ARGUMENTS, FieldTable.convertToMap(arguments));

Modified: qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom5To6Test.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom5To6Test.java?rev=1355994&r1=1355993&r2=1355994&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom5To6Test.java
(original)
+++ qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom5To6Test.java
Sun Jul  1 20:00:59 2012
@@ -29,9 +29,11 @@ import static org.apache.qpid.server.sto
 import static org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.OLD_XID_DB_NAME;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
@@ -165,11 +167,11 @@ public class UpgradeFrom5To6Test extends
         NewRecordImpl[] newDequeues = newTransaction.getDequeues();
         assertEquals("Unxpected new enqueus number", 1, newEnqueues.length);
         NewRecordImpl enqueue = newEnqueues[0];
-        assertEquals("Unxpected queue id", UUIDGenerator.generateUUID("TEST1", getVirtualHostName()),
enqueue.getId());
+        assertEquals("Unxpected queue id", UUIDGenerator.generateQueueUUID("TEST1", getVirtualHostName()),
enqueue.getId());
         assertEquals("Unxpected message id", 1, enqueue.getMessageNumber());
         assertEquals("Unxpected new dequeues number", 1, newDequeues.length);
         NewRecordImpl dequeue = newDequeues[0];
-        assertEquals("Unxpected queue id", UUIDGenerator.generateUUID("TEST2", getVirtualHostName()),
dequeue.getId());
+        assertEquals("Unxpected queue id", UUIDGenerator.generateQueueUUID("TEST2", getVirtualHostName()),
dequeue.getId());
         assertEquals("Unxpected message id", 2, dequeue.getMessageNumber());
     }
 
@@ -275,22 +277,24 @@ public class UpgradeFrom5To6Test extends
         assertEquals("Unexpected number of configured objects", 12, 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));
         expected.add(createExpectedQueueMap("nonexclusive-with-erroneous-owner", Boolean.FALSE,
null,
                      Collections.singletonMap(AMQQueueFactory.X_QPID_DESCRIPTION, "misused-owner-as-description")));
 
-        expected.add(createExpectedQueueBindingMap("myUpgradeQueue","myUpgradeQueue", "<<default>>",
null));
-        expected.add(createExpectedQueueBindingMap("myUpgradeQueue", "myUpgradeQueue", "amq.direct",
null));
-        expected.add(createExpectedQueueBindingMap("clientid:myDurSubName", "myUpgradeTopic",
"amq.topic",
-                Collections.singletonMap("x-filter-jms-selector", "")));
-        expected.add(createExpectedQueueBindingMap("clientid:mySelectorDurSubName", "mySelectorUpgradeTopic",
"amq.topic",
-                Collections.singletonMap("x-filter-jms-selector", "testprop='true'")));
-        expected.add(createExpectedQueueBindingMap("clientid:myDurSubName", "clientid:myDurSubName",
"<<default>>", null));
-        expected.add(createExpectedQueueBindingMap("clientid:mySelectorDurSubName", "clientid:mySelectorDurSubName",
"<<default>>", null));
-        expected.add(createExpectedQueueBindingMap("nonexclusive-with-erroneous-owner", "nonexclusive-with-erroneous-owner",
"amq.direct", null));
-        expected.add(createExpectedQueueBindingMap("nonexclusive-with-erroneous-owner","nonexclusive-with-erroneous-owner",
"<<default>>", null));
+        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));
 
         Set<String> expectedTypes = new HashSet<String>();
         expectedTypes.add(Queue.class.getName());
@@ -305,28 +309,44 @@ public class UpgradeFrom5To6Test extends
             String type = object.getType();
             assertTrue("Unexpected type:" + type, expectedTypes.contains(type));
             UUID key = entry.getKey();
-            if (type.equals(Exchange.class.getName()) || type.equals(Queue.class.getName()))
+
+            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,
getVirtualHostName()));
+            }
+            else if (type.equals(Queue.class.getName()))
             {
-                assertEquals("Unexpected key", key, UUIDGenerator.generateUUID(((String)
deserialized.get("name")), getVirtualHostName()));
+                String queueName = (String) deserialized.get(Queue.NAME);
+                assertNotNull(queueName);
+                assertEquals("Unexpected key", key, UUIDGenerator.generateQueueUUID(queueName,
getVirtualHostName()));
             }
-            else
+            else if (type.equals(Binding.class.getName()))
             {
-                assertNotNull("Key cannot be null", key);
+                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());
     }
 
-    private Map<String, Object> createExpectedQueueBindingMap(String queue, String
bindingName, String exchangeName, Map<String, String> argumentMap)
+    private Map<String, Object> createExpectedQueueBindingMapAndID(String queue, String
bindingName, String exchangeName, Map<String, String> argumentMap, List<UUID>
expectedBindingIDs)
     {
         Map<String, Object> expectedQueueBinding = new HashMap<String, Object>();
-        expectedQueueBinding.put(Binding.QUEUE, UUIDGenerator.generateUUID(queue, getVirtualHostName()).toString());
+        expectedQueueBinding.put(Binding.QUEUE, UUIDGenerator.generateQueueUUID(queue, getVirtualHostName()).toString());
         expectedQueueBinding.put(Binding.NAME, bindingName);
-        expectedQueueBinding.put(Binding.EXCHANGE, UUIDGenerator.generateUUID(exchangeName,
getVirtualHostName()).toString());
+        expectedQueueBinding.put(Binding.EXCHANGE, UUIDGenerator.generateExchangeUUID(exchangeName,
getVirtualHostName()).toString());
         if (argumentMap != null)
         {
             expectedQueueBinding.put(Binding.ARGUMENTS, argumentMap);
         }
+
+        expectedBindingIDs.add(UUIDGenerator.generateBindingUUID(exchangeName, queue, bindingName,
getVirtualHostName()));
+
         return expectedQueueBinding;
     }
 

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/binding/BindingFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/binding/BindingFactory.java?rev=1355994&r1=1355993&r2=1355994&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/binding/BindingFactory.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/binding/BindingFactory.java
Sun Jul  1 20:00:59 2012
@@ -166,7 +166,7 @@ public class BindingFactory
 
         if (id == null)
         {
-            id = UUIDGenerator.generateUUID();
+            id = UUIDGenerator.generateBindingUUID(exchange.getName(), queue.getName(), bindingKey,
_virtualHost.getName());
         }
         BindingImpl b = new BindingImpl(id, bindingKey, queue, exchange, arguments);
         BindingImpl existingMapping = _bindings.putIfAbsent(b, b);

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java?rev=1355994&r1=1355993&r2=1355994&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java
Sun Jul  1 20:00:59 2012
@@ -225,7 +225,10 @@ public class QueueDeclareHandler impleme
         String owner = body.getExclusive() ? AMQShortString.toString(session.getContextKey())
: null;
 
         Map<String, Object> arguments = FieldTable.convertToMap(body.getArguments());
-        final AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateUUID(),
AMQShortString.toString(queueName), body.getDurable(), owner, body.getAutoDelete(),
+        String queueNameString = AMQShortString.toString(queueName);
+
+        final AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateQueueUUID(queueNameString,
virtualHost.getName()),
+                                                                  queueNameString, body.getDurable(),
owner, body.getAutoDelete(),
                                                                   body.getExclusive(),virtualHost,
arguments);
 
         if (body.getExclusive() && !body.getDurable())

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/UUIDGenerator.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/UUIDGenerator.java?rev=1355994&r1=1355993&r2=1355994&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/UUIDGenerator.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/UUIDGenerator.java
Sun Jul  1 20:00:59 2012
@@ -22,33 +22,36 @@ package org.apache.qpid.server.model;
 
 import java.util.UUID;
 
-import org.apache.qpid.exchange.ExchangeDefaults;
-
-
 public class UUIDGenerator
 {
-
     public static UUID generateUUID()
     {
         return UUID.randomUUID();
     }
 
-    public static UUID generateUUID(String objectName, String virtualHostName)
+    public static UUID generateExchangeUUID(String exchangeName, String virtualHostName)
+    {
+        return generateUUID(exchangeName, virtualHostName, Exchange.class.getName());
+    }
+
+    public static UUID generateQueueUUID(String queueName, String virtualHostName)
+    {
+        return generateUUID(queueName, virtualHostName, Queue.class.getName());
+    }
+
+    private static UUID generateUUID(String objectName, String virtualHostName, String objectType)
     {
         StringBuilder sb = new StringBuilder();
-        sb.append(virtualHostName).append(objectName);
+        sb.append(virtualHostName).append(objectName).append(objectType);
+
         return UUID.nameUUIDFromBytes(sb.toString().getBytes());
     }
 
-    public static UUID generateExchangeUUID(String exchangeName, String virtualHostName)
+    public static UUID generateBindingUUID(String exchangeName, String queueName, String
bindingKey, String virtualHostName)
     {
-        if(ExchangeDefaults.DEFAULT_EXCHANGE_NAME.asString().equals(exchangeName) || exchangeName.startsWith("amq.")
|| exchangeName.startsWith("qpid."))
-        {
-            return generateUUID(exchangeName, virtualHostName);
-        }
-        else
-        {
-            return generateUUID();
-        }
+        StringBuilder sb = new StringBuilder();
+        sb.append(exchangeName).append(queueName).append(bindingKey).append(virtualHostName).append(Binding.class.getName());
+
+        return UUID.nameUUIDFromBytes(sb.toString().getBytes());
     }
 }

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/ExchangeAdapter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/ExchangeAdapter.java?rev=1355994&r1=1355993&r2=1355994&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/ExchangeAdapter.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/ExchangeAdapter.java
Sun Jul  1 20:00:59 2012
@@ -26,6 +26,8 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.UUID;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQInternalException;
 import org.apache.qpid.AMQSecurityException;
@@ -140,8 +142,7 @@ final class ExchangeAdapter extends Abst
                 Map<String, Object> oldArgs = oldBinding.getArguments();
                 if((oldArgs == null && !bindingArguments.isEmpty()) || (oldArgs !=
null && !oldArgs.equals(bindingArguments)))
                 {
-                    //TODO: generate deterministic UUID
-                    virtualHost.getBindingFactory().replaceBinding(UUIDGenerator.generateUUID(),
bindingKey, amqQueue, _exchange, bindingArguments);
+                    virtualHost.getBindingFactory().replaceBinding(oldBinding.getId(), bindingKey,
amqQueue, _exchange, bindingArguments);
                 }
             }
             Binding binding = virtualHost.getBindingFactory().getBinding(bindingKey, amqQueue,
_exchange, bindingArguments);

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java?rev=1355994&r1=1355993&r2=1355994&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
Sun Jul  1 20:00:59 2012
@@ -302,7 +302,7 @@ final class VirtualHostAdapter extends A
                 throw new IllegalArgumentException("Queue with name "+name+" already exists");
             }
             AMQQueue queue =
-                    AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateUUID(name, _virtualHost.getName()),
name,
+                    AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateQueueUUID(name,
_virtualHost.getName()), name,
                                                        durable, owner, lifetime == LifetimePolicy.AUTO_DELETE,
                                                        exclusive, _virtualHost, attributes);
             _virtualHost.getBindingFactory().addBinding(name, queue, _virtualHost.getExchangeRegistry().getDefaultExchange(),
null);

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java?rev=1355994&r1=1355993&r2=1355994&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java
Sun Jul  1 20:00:59 2012
@@ -200,7 +200,7 @@ public class SendingLink_1_0 implements 
                 if(queue == null)
                 {
                     queue = AMQQueueFactory.createAMQQueueImpl(
-                                UUIDGenerator.generateUUID(),
+                                UUIDGenerator.generateQueueUUID(name, _vhost.getName()),
                                 name,
                                 isDurable,
                                 null,

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java?rev=1355994&r1=1355993&r2=1355994&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java
Sun Jul  1 20:00:59 2012
@@ -319,7 +319,7 @@ public class Session_1_0 implements Sess
                                             ? null
                                             : (LifetimePolicy) properties.get(LIFETIME_POLICY);
 
-            final AMQQueue tempQueue = queue = AMQQueueFactory.createAMQQueueImpl( UUIDGenerator.generateUUID(),
+            final AMQQueue tempQueue = queue = AMQQueueFactory.createAMQQueueImpl( UUIDGenerator.generateQueueUUID(queueName,
_vhost.getName()),
                                                                                    queueName,
                                                                                    false,
// durable
                                                                                    null,
// owner

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java?rev=1355994&r1=1355993&r2=1355994&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java
Sun Jul  1 20:00:59 2012
@@ -302,7 +302,7 @@ public class AMQQueueFactory
 
                 if(dlExchange == null)
                 {
-                    dlExchange = exchangeFactory.createExchange(UUIDGenerator.generateUUID(dlExchangeName,
virtualHost.getName()), new AMQShortString(dlExchangeName), ExchangeDefaults.FANOUT_EXCHANGE_CLASS,
true, false, 0);
+                    dlExchange = exchangeFactory.createExchange(UUIDGenerator.generateExchangeUUID(dlExchangeName,
virtualHost.getName()), new AMQShortString(dlExchangeName), ExchangeDefaults.FANOUT_EXCHANGE_CLASS,
true, false, 0);
 
                     exchangeRegistry.registerExchange(dlExchange);
 
@@ -324,7 +324,7 @@ public class AMQQueueFactory
                     args.put(X_QPID_DLQ_ENABLED, false);
                     args.put(X_QPID_MAXIMUM_DELIVERY_COUNT, 0);
 
-                    dlQueue = createAMQQueueImpl(UUIDGenerator.generateUUID(dlQueueName,
virtualHost.getName()), dlQueueName, true, owner, false, exclusive, virtualHost, args);
+                    dlQueue = createAMQQueueImpl(UUIDGenerator.generateQueueUUID(dlQueueName,
virtualHost.getName()), dlQueueName, true, owner, false, exclusive, virtualHost, args);
 
                     //enter the dlq in the persistent store
                     virtualHost.getMessageStore().createQueue(dlQueue, FieldTable.convertToFieldTable(args));
@@ -355,7 +355,7 @@ public class AMQQueueFactory
         Map<String, Object> arguments = createQueueArgumentsFromConfig(config);
 
         // we need queues that are defined in config to have deterministic ids.
-        UUID id = UUIDGenerator.generateUUID(queueName, host.getName());
+        UUID id = UUIDGenerator.generateQueueUUID(queueName, host.getName());
 
         AMQQueue q = createAMQQueueImpl(id, queueName, durable, owner, autodelete, exclusive,
host, arguments);
         q.configure(config);

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSessionDelegate.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSessionDelegate.java?rev=1355994&r1=1355993&r2=1355994&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSessionDelegate.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSessionDelegate.java
Sun Jul  1 20:00:59 2012
@@ -1385,7 +1385,7 @@ public class ServerSessionDelegate exten
     {
         String owner = body.getExclusive() ? session.getClientID() : null;
 
-        final AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateUUID(),
queueName, body.getDurable(), owner,
+        final AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateQueueUUID(queueName,
virtualHost.getName()), queueName, body.getDurable(), owner,
                                                                   body.getAutoDelete(), body.getExclusive(),
virtualHost, body.getArguments());
 
         return queue;

Added: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/model/UUIDGeneratorTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/model/UUIDGeneratorTest.java?rev=1355994&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/model/UUIDGeneratorTest.java
(added)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/model/UUIDGeneratorTest.java
Sun Jul  1 20:00:59 2012
@@ -0,0 +1,111 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.model;
+
+import java.util.UUID;
+
+import org.apache.qpid.test.utils.QpidTestCase;
+
+public class UUIDGeneratorTest extends QpidTestCase
+{
+    private static final String VIRTUAL_HOST_NAME_1 = "virtualHost1";
+    private static final String VIRTUAL_HOST_NAME_2 = "virtualHost2";
+    private static final String QUEUE_NAME_1 = "queue1";
+    private static final String QUEUE_NAME_2 = "queue2";
+    private static final String EXCHANGE_NAME_1 = "exchange1";
+    private static final String EXCHANGE_NAME_2 = "exchange2";
+    private static final String BINDING_KEY_1 = "bindingKey1";
+    private static final String BINDING_KEY_2 = "bindingKey2";
+
+    public void testDifferentObjectTypeReturnDifferentIdFromSameValues() throws Exception
+    {
+        UUID id1 = UUIDGenerator.generateQueueUUID("name", "vhost");
+        UUID id2 = UUIDGenerator.generateExchangeUUID("name", "vhost");
+        UUID id3 = UUIDGenerator.generateBindingUUID("name", "name", "name", "vhost");
+
+        assertFalse("IDs should not be equal", id1.equals(id2));
+        assertFalse("IDs should not be equal", id2.equals(id3));
+        assertFalse("IDs should not be equal", id1.equals(id3));
+    }
+
+    public void testRepeatedQueueIdGenerationIsDeterministic() throws Exception
+    {
+        UUID queueIdIteration1 = UUIDGenerator.generateQueueUUID(QUEUE_NAME_1, VIRTUAL_HOST_NAME_1);
+        UUID queueIdIteration2 = UUIDGenerator.generateQueueUUID(QUEUE_NAME_1, VIRTUAL_HOST_NAME_1);
+        assertEquals("Queue IDs should be equal", queueIdIteration1, queueIdIteration2);
+    }
+
+    public void testRepeatedExchangeIdGenerationIsDeterministic() throws Exception
+    {
+        UUID exchangeIdIteration1 = UUIDGenerator.generateExchangeUUID(EXCHANGE_NAME_1, VIRTUAL_HOST_NAME_1);
+        UUID exchangeIdIteration2 = UUIDGenerator.generateExchangeUUID(EXCHANGE_NAME_1, VIRTUAL_HOST_NAME_1);
+        assertEquals("Exchange IDs should be equal", exchangeIdIteration1, exchangeIdIteration2);
+    }
+
+    public void testRepeatedBindingIdGenerationIsDeterministic() throws Exception
+    {
+        UUID bindingIdIteration1 = UUIDGenerator.generateBindingUUID(EXCHANGE_NAME_1, QUEUE_NAME_1,
BINDING_KEY_1, VIRTUAL_HOST_NAME_1);
+        UUID bindingIdIteration2 = UUIDGenerator.generateBindingUUID(EXCHANGE_NAME_1, QUEUE_NAME_1,
BINDING_KEY_1, VIRTUAL_HOST_NAME_1);
+        assertEquals("Binding IDs should be equal", bindingIdIteration1, bindingIdIteration2);
+    }
+
+    public void testDifferentQueueNameGivesDifferentQueueId() throws Exception
+    {
+        UUID queue1 = UUIDGenerator.generateQueueUUID(QUEUE_NAME_1, VIRTUAL_HOST_NAME_1);
+        UUID queue2 = UUIDGenerator.generateQueueUUID(QUEUE_NAME_2, VIRTUAL_HOST_NAME_1);
+        assertFalse("Queue IDs should not be equal", queue1.equals(queue2));
+    }
+
+    public void testDifferentExchangeNameGivesDifferentExchangeId() throws Exception
+    {
+        UUID exchange1 = UUIDGenerator.generateExchangeUUID(EXCHANGE_NAME_1, VIRTUAL_HOST_NAME_1);
+        UUID exchange2 = UUIDGenerator.generateExchangeUUID(EXCHANGE_NAME_2, VIRTUAL_HOST_NAME_1);
+        assertFalse("Exchange IDs should not be equal", exchange1.equals(exchange2));
+    }
+
+    public void testDifferentBindingNameGivesDifferentBindingId() throws Exception
+    {
+        UUID binding1 = UUIDGenerator.generateBindingUUID(EXCHANGE_NAME_1, QUEUE_NAME_1,
BINDING_KEY_1, VIRTUAL_HOST_NAME_1);
+        UUID binding2 = UUIDGenerator.generateBindingUUID(EXCHANGE_NAME_1, QUEUE_NAME_1,
BINDING_KEY_2, VIRTUAL_HOST_NAME_1);
+        assertFalse("Binding IDs should not be equal", binding1.equals(binding2));
+    }
+
+    public void testDifferentVirtualHostNameGivesDifferentQueueId() throws Exception
+    {
+        UUID queue1 = UUIDGenerator.generateQueueUUID(QUEUE_NAME_1, VIRTUAL_HOST_NAME_1);
+        UUID queue2 = UUIDGenerator.generateQueueUUID(QUEUE_NAME_1, VIRTUAL_HOST_NAME_2);
+        assertFalse("Queue IDs should not be equal", queue1.equals(queue2));
+    }
+
+    public void testDifferentVirtualHostNameGivesDifferentExchangeId() throws Exception
+    {
+        UUID exchange1 = UUIDGenerator.generateExchangeUUID(EXCHANGE_NAME_1, VIRTUAL_HOST_NAME_1);
+        UUID exchange2 = UUIDGenerator.generateExchangeUUID(EXCHANGE_NAME_1, VIRTUAL_HOST_NAME_2);
+        assertFalse("Exchange IDs should not be equal", exchange1.equals(exchange2));
+    }
+
+    public void testDifferentVirtualHostNameGivesDifferentBindingId() throws Exception
+    {
+        UUID binding1 = UUIDGenerator.generateBindingUUID(EXCHANGE_NAME_1, QUEUE_NAME_1,
BINDING_KEY_1, VIRTUAL_HOST_NAME_1);
+        UUID binding2 = UUIDGenerator.generateBindingUUID(EXCHANGE_NAME_1, QUEUE_NAME_1,
BINDING_KEY_1, VIRTUAL_HOST_NAME_2);
+        assertFalse("Binding IDs should not be equal", binding1.equals(binding2));
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message