Minor change, removed redundant parameter in method addNewSubscription of session storage
This commit is contained in:
@@ -30,7 +30,7 @@ public interface ISessionsStore {
|
||||
/**
|
||||
* Add a new subscription to the session
|
||||
*/
|
||||
void addNewSubscription(Subscription newSubscription, String clientID);
|
||||
void addNewSubscription(Subscription newSubscription);
|
||||
|
||||
/**
|
||||
* Remove all the subscriptions of the session
|
||||
|
||||
@@ -159,7 +159,8 @@ public class MemoryStorageService implements IMessagesStore, ISessionsStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNewSubscription(Subscription newSubscription, String clientID) {
|
||||
public void addNewSubscription(Subscription newSubscription) {
|
||||
final String clientID = newSubscription.getClientId();
|
||||
if (!m_persistentSubscriptions.containsKey(clientID)) {
|
||||
m_persistentSubscriptions.put(clientID, new HashSet<Subscription>());
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ class ProtocolProcessor implements EventHandler<ValueEvent> {
|
||||
session.write(okResp);
|
||||
|
||||
LOG.info("Create persistent session for clientID <{}>", msg.getClientID());
|
||||
m_sessionsStore.addNewSubscription(Subscription.createEmptySubscription(msg.getClientID(), true), msg.getClientID()); //null means EmptySubscription
|
||||
m_sessionsStore.addNewSubscription(Subscription.createEmptySubscription(msg.getClientID(), true)); //null means EmptySubscription
|
||||
LOG.info("Connected client ID <{}> with clean session {}", msg.getClientID(), msg.isCleanSession());
|
||||
if (!msg.isCleanSession()) {
|
||||
//force the republish of stored QoS1 and QoS2
|
||||
@@ -621,13 +621,12 @@ class ProtocolProcessor implements EventHandler<ValueEvent> {
|
||||
LOG.info("<{}> subscribed to topic <{}> with QoS {}",
|
||||
newSubscription.getClientId(), topic,
|
||||
AbstractMessage.QOSType.formatQoS(newSubscription.getRequestedQos()));
|
||||
String clientID = newSubscription.getClientId();
|
||||
boolean validTopic = SubscriptionsStore.validate(newSubscription);
|
||||
if (!validTopic) {
|
||||
//send SUBACK with 0x80 for this topic filter
|
||||
return false;
|
||||
}
|
||||
m_sessionsStore.addNewSubscription(newSubscription, clientID);
|
||||
m_sessionsStore.addNewSubscription(newSubscription);
|
||||
subscriptions.add(newSubscription);
|
||||
|
||||
//scans retained messages to be published to the new subscription
|
||||
|
||||
@@ -221,8 +221,9 @@ public class MapDBPersistentStore implements IMessagesStore, ISessionsStore {
|
||||
return nextPacketId;
|
||||
}
|
||||
|
||||
public void addNewSubscription(Subscription newSubscription, String clientID) {
|
||||
LOG.debug("addNewSubscription invoked with subscription {} for client {}", newSubscription, clientID);
|
||||
public void addNewSubscription(Subscription newSubscription) {
|
||||
LOG.debug("addNewSubscription invoked with subscription {}", newSubscription);
|
||||
final String clientID = newSubscription.getClientId();
|
||||
if (!m_persistentSubscriptions.containsKey(clientID)) {
|
||||
LOG.debug("clientID {} is a newcome, creating it's subscriptions set", clientID);
|
||||
m_persistentSubscriptions.put(clientID, new HashSet<Subscription>());
|
||||
|
||||
@@ -61,9 +61,9 @@ public class MapDBPersistentStoreTest {
|
||||
@Test
|
||||
public void overridingSubscriptions() {
|
||||
Subscription oldSubscription = new Subscription("FAKE_CLI_ID_1", "/topic", AbstractMessage.QOSType.MOST_ONE, false);
|
||||
m_storageService.addNewSubscription(oldSubscription, oldSubscription.getClientId());
|
||||
m_storageService.addNewSubscription(oldSubscription);
|
||||
Subscription overrindingSubscription = new Subscription("FAKE_CLI_ID_1", "/topic", AbstractMessage.QOSType.EXACTLY_ONCE, false);
|
||||
m_storageService.addNewSubscription(overrindingSubscription, overrindingSubscription.getClientId());
|
||||
m_storageService.addNewSubscription(overrindingSubscription);
|
||||
|
||||
//Verify
|
||||
List<Subscription> subscriptions = m_storageService.listAllSubscriptions();
|
||||
|
||||
Reference in New Issue
Block a user