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