From 1afa7601c93e51a0edc7ea6ad37561e17a9df73f Mon Sep 17 00:00:00 2001 From: "selva.andre" Date: Mon, 30 Jun 2014 22:21:52 +0200 Subject: [PATCH] Minor change, renamed topic to topicFilter in Subscription --- .../spi/impl/HawtDBStorageService.java | 2 +- .../messaging/spi/impl/ProtocolProcessor.java | 2 +- .../spi/impl/subscriptions/Subscription.java | 20 +++++++++---------- .../subscriptions/SubscriptionsStore.java | 10 +++++----- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/HawtDBStorageService.java b/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/HawtDBStorageService.java index ac9f149e..ce8e0900 100644 --- a/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/HawtDBStorageService.java +++ b/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/HawtDBStorageService.java @@ -246,7 +246,7 @@ public class HawtDBStorageService implements IStorageService { //TODO check the subs doesn't contain another subscription to the same topic with different Subscription existingSubscription = null; for (Subscription scanSub : subs) { - if (newSubscription.getTopic().equals(scanSub.getTopic())) { + if (newSubscription.getTopicFilter().equals(scanSub.getTopicFilter())) { existingSubscription = scanSub; break; } diff --git a/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/ProtocolProcessor.java b/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/ProtocolProcessor.java index 248334bf..9d375f46 100644 --- a/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/ProtocolProcessor.java +++ b/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/ProtocolProcessor.java @@ -308,7 +308,7 @@ class ProtocolProcessor implements EventHandler { ByteBuffer message = origMessage.duplicate(); LOG.debug("Broker republishing to client <{}> topic <{}> qos <{}>, active {}", - sub.getClientId(), sub.getTopic(), qos, sub.isActive()); + sub.getClientId(), sub.getTopicFilter(), qos, sub.isActive()); if (qos == AbstractMessage.QOSType.MOST_ONE && sub.isActive()) { //QoS 0 diff --git a/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/subscriptions/Subscription.java b/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/subscriptions/Subscription.java index 83fc78d9..cbc96858 100644 --- a/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/subscriptions/Subscription.java +++ b/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/subscriptions/Subscription.java @@ -27,16 +27,16 @@ import org.dna.mqtt.moquette.proto.messages.AbstractMessage.QOSType; */ public class Subscription implements Serializable { - QOSType requestedQos; + QOSType requestedQos; //max QoS acceptable String clientId; - String topic; + String topicFilter; boolean cleanSession; boolean active = true; - public Subscription(String clientId, String topic, QOSType requestedQos, boolean cleanSession) { + public Subscription(String clientId, String topicFilter, QOSType requestedQos, boolean cleanSession) { this.requestedQos = requestedQos; this.clientId = clientId; - this.topic = topic; + this.topicFilter = topicFilter; this.cleanSession = cleanSession; } @@ -48,8 +48,8 @@ public class Subscription implements Serializable { return requestedQos; } - public String getTopic() { - return topic; + public String getTopicFilter() { + return topicFilter; } public boolean isCleanSession() { @@ -79,7 +79,7 @@ public class Subscription implements Serializable { if ((this.clientId == null) ? (other.clientId != null) : !this.clientId.equals(other.clientId)) { return false; } - if ((this.topic == null) ? (other.topic != null) : !this.topic.equals(other.topic)) { + if ((this.topicFilter == null) ? (other.topicFilter != null) : !this.topicFilter.equals(other.topicFilter)) { return false; } return true; @@ -90,7 +90,7 @@ public class Subscription implements Serializable { int hash = 3; hash = 37 * hash + (this.requestedQos != null ? this.requestedQos.hashCode() : 0); hash = 37 * hash + (this.clientId != null ? this.clientId.hashCode() : 0); - hash = 37 * hash + (this.topic != null ? this.topic.hashCode() : 0); + hash = 37 * hash + (this.topicFilter != null ? this.topicFilter.hashCode() : 0); return hash; } @@ -98,11 +98,11 @@ public class Subscription implements Serializable { * Trivial match method */ boolean match(String topic) { - return this.topic.equals(topic); + return this.topicFilter.equals(topic); } @Override public String toString() { - return String.format("[t:%s, cliID: %s, qos: %s, active: %s]", this.topic, this.clientId, this.requestedQos, this.active); + return String.format("[filter:%s, cliID: %s, qos: %s, active: %s]", this.topicFilter, this.clientId, this.requestedQos, this.active); } } diff --git a/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/subscriptions/SubscriptionsStore.java b/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/subscriptions/SubscriptionsStore.java index 645d02f4..d9534390 100644 --- a/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/subscriptions/SubscriptionsStore.java +++ b/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/subscriptions/SubscriptionsStore.java @@ -90,7 +90,7 @@ public class SubscriptionsStore { } for (Subscription subscription : m_storageService.retrieveAllSubscriptions()) { - LOG.debug("Re-subscribing {} to topic {}", subscription.getClientId(), subscription.getTopic()); + LOG.debug("Re-subscribing {} to topic {}", subscription.getClientId(), subscription.getTopicFilter()); addDirect(subscription); } if (LOG.isDebugEnabled()) { @@ -99,7 +99,7 @@ public class SubscriptionsStore { } protected void addDirect(Subscription newSubscription) { - TreeNode current = findMatchingNode(newSubscription.topic); + TreeNode current = findMatchingNode(newSubscription.topicFilter); current.addSubscription(newSubscription); } @@ -146,7 +146,7 @@ public class SubscriptionsStore { //search for the subscription to remove Subscription toBeRemoved = null; for (Subscription sub : matchNode.subscriptions()) { - if (sub.topic.equals(topic) && sub.getClientId().equals(clientID)) { + if (sub.topicFilter.equals(topic) && sub.getClientId().equals(clientID)) { toBeRemoved = sub; break; } @@ -166,7 +166,7 @@ public class SubscriptionsStore { List allSubscriptions = subsCollector.getResult(); for (Subscription subscription : allSubscriptions) { - removeSubscription(subscription.getTopic(), subscription.getClientId()); + removeSubscription(subscription.getTopicFilter(), subscription.getClientId()); } } @@ -211,7 +211,7 @@ public class SubscriptionsStore { } public boolean contains(Subscription sub) { - return !matches(sub.topic).isEmpty(); + return !matches(sub.topicFilter).isEmpty(); } public int size() {