From b81dd2886e791ffc0fdf6ac3571b8a83830e6546 Mon Sep 17 00:00:00 2001 From: "Hiram R. Chirino" Date: Thu, 6 Sep 2007 22:11:43 +0000 Subject: [PATCH] Fixed ContainerId so that it also uses the container name when it compares equality. Switch back to using a single index file for the topic susbcriptions lists. git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@573395 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/activemq/kaha/ContainerId.java | 11 +++++------ .../store/kahadaptor/KahaTopicReferenceStore.java | 14 +++++++------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/kaha/ContainerId.java b/activemq-core/src/main/java/org/apache/activemq/kaha/ContainerId.java index e41ac54565..c6251988c9 100644 --- a/activemq-core/src/main/java/org/apache/activemq/kaha/ContainerId.java +++ b/activemq-core/src/main/java/org/apache/activemq/kaha/ContainerId.java @@ -68,16 +68,15 @@ public class ContainerId implements Externalizable { } public int hashCode() { - return key.hashCode(); + return key.hashCode() ^ dataContainerName.hashCode(); } public boolean equals(Object obj) { - boolean result = false; - if (obj != null && obj instanceof ContainerId) { - ContainerId other = (ContainerId)obj; - result = other.key.equals(this.key); + if (obj == null || obj.getClass() != ContainerId.class) { + return false; } - return result; + ContainerId other = (ContainerId)obj; + return other.key.equals(this.key) && other.dataContainerName.equals(this.dataContainerName); } public void writeExternal(ObjectOutput out) throws IOException { diff --git a/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaTopicReferenceStore.java b/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaTopicReferenceStore.java index 0061c2aabd..71b9b7084d 100644 --- a/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaTopicReferenceStore.java +++ b/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaTopicReferenceStore.java @@ -50,9 +50,9 @@ public class KahaTopicReferenceStore extends KahaReferenceStore implements Topic this.ackContainer = ackContainer; subscriberContainer = subsContainer; // load all the Ack containers - for (Iterator i = subscriberContainer.keySet().iterator(); i.hasNext();) { - String key = i.next(); - addSubscriberMessageContainer(key); + for (Iterator i = subscriberContainer.values().iterator(); i.hasNext();) { + SubscriptionInfo info = i.next(); + addSubscriberMessageContainer(info.getClientId(), info.getSubscriptionName()); } } @@ -108,12 +108,12 @@ public class KahaTopicReferenceStore extends KahaReferenceStore implements Topic } } - protected ListContainer addSubscriberMessageContainer(String key) throws IOException { - ListContainer container = store.getListContainer(key, "TSR-" + destination); + protected ListContainer addSubscriberMessageContainer(String clientId, String subscriptionName) throws IOException { + ListContainer container = store.getListContainer(clientId+":"+subscriptionName+":"+destination.getQualifiedName(), "topic-subs-references"); Marshaller marshaller = new ConsumerMessageRefMarshaller(); container.setMarshaller(marshaller); TopicSubContainer tsc = new TopicSubContainer(container); - subscriberMessages.put(key, tsc); + subscriberMessages.put(getSubscriptionKey(clientId, subscriptionName), tsc); return container; } @@ -156,7 +156,7 @@ public class KahaTopicReferenceStore extends KahaReferenceStore implements Topic adapter.addSubscriberState(info); } // add the subscriber - ListContainer container = addSubscriberMessageContainer(key); + ListContainer container = addSubscriberMessageContainer(info.getClientId(), info.getSubscriptionName()); if (retroactive) { /* * for(StoreEntry