Merged topic subscription search and publish into single MessagePublisher method
First step on implementing H2 storage Minor, fixed not imported class Cleaned MessageStore interface to avoid duplication of methods used in couple. Switched from guid + message to move messages Separated ISubscriptionsStore from ISessionStore Implemented H2 queue
This commit is contained in:
@@ -17,11 +17,8 @@
|
||||
package io.moquette.spi;
|
||||
|
||||
import io.moquette.spi.IMessagesStore.StoredMessage;
|
||||
import io.moquette.spi.impl.subscriptions.Subscription;
|
||||
import io.moquette.spi.impl.subscriptions.Topic;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
|
||||
/**
|
||||
@@ -29,90 +26,12 @@ import java.util.concurrent.BlockingQueue;
|
||||
*/
|
||||
public interface ISessionsStore {
|
||||
|
||||
class ClientTopicCouple {
|
||||
|
||||
public final Topic topicFilter;
|
||||
public final String clientID;
|
||||
|
||||
public ClientTopicCouple(String clientID, Topic topicFilter) {
|
||||
this.clientID = clientID;
|
||||
this.topicFilter = topicFilter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
ClientTopicCouple that = (ClientTopicCouple) o;
|
||||
|
||||
if (topicFilter != null ? !topicFilter.equals(that.topicFilter) : that.topicFilter != null)
|
||||
return false;
|
||||
return !(clientID != null ? !clientID.equals(that.clientID) : that.clientID != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = topicFilter != null ? topicFilter.hashCode() : 0;
|
||||
result = 31 * result + (clientID != null ? clientID.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ClientTopicCouple{" + "topicFilter='" + topicFilter + '\'' + ", clientID='" + clientID + '\'' + '}';
|
||||
}
|
||||
}
|
||||
|
||||
void initStore();
|
||||
|
||||
ISubscriptionsStore subscriptionStore();
|
||||
|
||||
void updateCleanStatus(String clientID, boolean cleanSession);
|
||||
|
||||
/**
|
||||
* Add a new subscription to the session
|
||||
*
|
||||
* @param newSubscription
|
||||
* the subscription to add.
|
||||
*/
|
||||
void addNewSubscription(Subscription newSubscription);
|
||||
|
||||
/**
|
||||
* Removed a specific subscription
|
||||
*
|
||||
* @param topic
|
||||
* the topic of the subscription.
|
||||
* @param clientID
|
||||
* the session client.
|
||||
*/
|
||||
void removeSubscription(Topic topic, String clientID);
|
||||
|
||||
/**
|
||||
* Remove all the subscriptions of the session
|
||||
*
|
||||
* @param sessionID
|
||||
* the client ID
|
||||
*/
|
||||
void wipeSubscriptions(String sessionID);
|
||||
|
||||
/**
|
||||
* Return all topic filters to recreate the subscription tree.
|
||||
*/
|
||||
List<ClientTopicCouple> listAllSubscriptions();
|
||||
|
||||
/**
|
||||
* @param couple
|
||||
* the subscription descriptor.
|
||||
* @return the subscription stored by clientID and topicFilter, if any else null;
|
||||
*/
|
||||
Subscription getSubscription(ClientTopicCouple couple);
|
||||
|
||||
/*
|
||||
* @return all subscriptions stored.
|
||||
*/
|
||||
List<Subscription> getSubscriptions();
|
||||
|
||||
/**
|
||||
* @param clientID
|
||||
* the session client ID.
|
||||
@@ -132,23 +51,23 @@ public interface ISessionsStore {
|
||||
/**
|
||||
* Returns all the sessions
|
||||
*
|
||||
* @return
|
||||
* @return the collection of all stored client sessions.
|
||||
*/
|
||||
Collection<ClientSession> getAllSessions();
|
||||
|
||||
void inFlightAck(String clientID, int messageID);
|
||||
StoredMessage inFlightAck(String clientID, int messageID);
|
||||
|
||||
/**
|
||||
* Save the binding messageID, clientID - guid
|
||||
* Save the message msg with messageID, clientID as in flight
|
||||
*
|
||||
* @param clientID
|
||||
* the client ID
|
||||
* @param messageID
|
||||
* the message ID
|
||||
* @param guid
|
||||
* the uuid of the message to mark as inflight.
|
||||
* @param msg
|
||||
* the message to put in flight zone
|
||||
*/
|
||||
void inFlight(String clientID, int messageID, MessageGUID guid);
|
||||
void inFlight(String clientID, int messageID, StoredMessage msg);
|
||||
|
||||
/**
|
||||
* Return the next valid packetIdentifier for the given client session.
|
||||
@@ -170,7 +89,7 @@ public interface ISessionsStore {
|
||||
|
||||
void dropQueue(String clientID);
|
||||
|
||||
void moveInFlightToSecondPhaseAckWaiting(String clientID, int messageID);
|
||||
void moveInFlightToSecondPhaseAckWaiting(String clientID, int messageID, StoredMessage msg);
|
||||
|
||||
/**
|
||||
* @param clientID
|
||||
@@ -179,9 +98,7 @@ public interface ISessionsStore {
|
||||
* the message ID that reached the second phase.
|
||||
* @return the guid of message just acked.
|
||||
*/
|
||||
MessageGUID secondPhaseAcknowledged(String clientID, int messageID);
|
||||
|
||||
StoredMessage getInflightMessage(String clientID, int messageID);
|
||||
StoredMessage secondPhaseAcknowledged(String clientID, int messageID);
|
||||
|
||||
/**
|
||||
* Returns the number of inflight messages for the given client ID
|
||||
@@ -196,7 +113,7 @@ public interface ISessionsStore {
|
||||
* */
|
||||
IMessagesStore.StoredMessage inboundInflight(String clientID, int messageID);
|
||||
|
||||
void markAsInboundInflight(String clientID, int messageID, MessageGUID guid);
|
||||
void markAsInboundInflight(String clientID, int messageID, StoredMessage msg);
|
||||
|
||||
/**
|
||||
* Returns the size of the session queue for the given client ID
|
||||
@@ -214,5 +131,5 @@ public interface ISessionsStore {
|
||||
*/
|
||||
int getSecondPhaseAckPendingMessages(String clientID);
|
||||
|
||||
Collection<MessageGUID> pendingAck(String clientID);
|
||||
void dropInFlightMessagesInSession(String clientID);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user