Added tracking of closed session time and expired session cleaner for clients that never reconnects but had clean session flag = false
This commit is contained in:
@@ -41,7 +41,7 @@ public class ClientSessionTest {
|
||||
subscriptionsDirectory = new CTrieSubscriptionDirectory();
|
||||
MemoryStorageService storageService = new MemoryStorageService(null, null);
|
||||
ISessionsStore sessionsStore = storageService.sessionsStore();
|
||||
sessionsRepository = new SessionsRepository(sessionsStore);
|
||||
sessionsRepository = new SessionsRepository(sessionsStore, null);
|
||||
subscriptionsDirectory.init(sessionsRepository);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ abstract class AbstractProtocolProcessorCommonUtils {
|
||||
m_sessionStore = memStorage.sessionsStore();
|
||||
// m_messagesStore.initStore();
|
||||
|
||||
sessionsRepository = new SessionsRepository(m_sessionStore);
|
||||
sessionsRepository = new SessionsRepository(m_sessionStore, null);
|
||||
|
||||
Set<String> clientIds = new HashSet<>();
|
||||
clientIds.add(FAKE_CLIENT_ID);
|
||||
|
||||
@@ -86,7 +86,7 @@ public class ProtocolProcessorTest extends AbstractProtocolProcessorCommonUtils
|
||||
|
||||
// simulate a connect that register a clientID to an IoSession
|
||||
MemoryStorageService storageService = new MemoryStorageService(null, null);
|
||||
SessionsRepository sessionsRepository = new SessionsRepository(storageService.sessionsStore());
|
||||
SessionsRepository sessionsRepository = new SessionsRepository(storageService.sessionsStore(), null);
|
||||
subs.init(sessionsRepository);
|
||||
m_processor.init(subs, m_messagesStore, m_sessionStore, null, true, new PermitAllAuthorizator(),
|
||||
NO_OBSERVERS_INTERCEPTOR, this.sessionsRepository);
|
||||
@@ -123,7 +123,7 @@ public class ProtocolProcessorTest extends AbstractProtocolProcessorCommonUtils
|
||||
|
||||
// simulate a connect that register a clientID to an IoSession
|
||||
MemoryStorageService storageService = new MemoryStorageService(null, null);
|
||||
SessionsRepository sessionsRepository = new SessionsRepository(storageService.sessionsStore());
|
||||
SessionsRepository sessionsRepository = new SessionsRepository(storageService.sessionsStore(), null);
|
||||
subs.init(sessionsRepository);
|
||||
m_processor.init(subs, m_messagesStore, m_sessionStore, null, true, new PermitAllAuthorizator(),
|
||||
NO_OBSERVERS_INTERCEPTOR, this.sessionsRepository);
|
||||
@@ -246,7 +246,7 @@ public class ProtocolProcessorTest extends AbstractProtocolProcessorCommonUtils
|
||||
}
|
||||
};
|
||||
MemoryStorageService storageService = new MemoryStorageService(null, null);
|
||||
SessionsRepository sessionsRepository = new SessionsRepository(storageService.sessionsStore());
|
||||
SessionsRepository sessionsRepository = new SessionsRepository(storageService.sessionsStore(), null);
|
||||
subs.init(sessionsRepository);
|
||||
|
||||
// simulate a connect that register a clientID to an IoSession
|
||||
|
||||
@@ -65,11 +65,11 @@ public class ProtocolProcessor_CONNECT_Test {
|
||||
m_mockAuthenticator = new MockAuthenticator(singleton(FAKE_CLIENT_ID), singletonMap(TEST_USER, TEST_PWD));
|
||||
|
||||
subscriptions = new CTrieSubscriptionDirectory();
|
||||
SessionsRepository sessionsRepository = new SessionsRepository(m_sessionStore);
|
||||
SessionsRepository sessionsRepository = new SessionsRepository(m_sessionStore, null);
|
||||
subscriptions.init(sessionsRepository);
|
||||
m_processor = new ProtocolProcessor();
|
||||
m_processor.init(subscriptions, m_messagesStore, m_sessionStore, m_mockAuthenticator, true,
|
||||
new PermitAllAuthorizator(), NO_OBSERVERS_INTERCEPTOR, new SessionsRepository(this.m_sessionStore));
|
||||
new PermitAllAuthorizator(), NO_OBSERVERS_INTERCEPTOR, new SessionsRepository(this.m_sessionStore, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -159,7 +159,7 @@ public class ProtocolProcessor_CONNECT_Test {
|
||||
|
||||
protected void reinitProcessorProhibitingAnonymousClients() {
|
||||
m_processor.init(subscriptions, m_messagesStore, m_sessionStore, m_mockAuthenticator, false,
|
||||
new PermitAllAuthorizator(), NO_OBSERVERS_INTERCEPTOR, new SessionsRepository(this.m_sessionStore));
|
||||
new PermitAllAuthorizator(), NO_OBSERVERS_INTERCEPTOR, new SessionsRepository(this.m_sessionStore, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -324,7 +324,7 @@ public class ProtocolProcessor_CONNECT_Test {
|
||||
|
||||
protected void reinitProtocolProcessorWithZeroLengthClientIdAndAnonymousClients() {
|
||||
m_processor.init(subscriptions, m_messagesStore, m_sessionStore, m_mockAuthenticator, true, true,
|
||||
new PermitAllAuthorizator(), NO_OBSERVERS_INTERCEPTOR, new SessionsRepository(this.m_sessionStore));
|
||||
new PermitAllAuthorizator(), NO_OBSERVERS_INTERCEPTOR, new SessionsRepository(this.m_sessionStore, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+5
-4
@@ -12,7 +12,8 @@
|
||||
* http://www.opensource.org/licenses/apache2.0.php
|
||||
*
|
||||
* You may elect to redistribute this code under either of these licenses.
|
||||
*/package io.moquette.spi.impl.subscriptions;
|
||||
*/
|
||||
package io.moquette.spi.impl.subscriptions;
|
||||
|
||||
import io.moquette.persistence.MemoryStorageService;
|
||||
import io.moquette.spi.ClientSession;
|
||||
@@ -45,7 +46,7 @@ public class CTrieSubscriptionDirectoryMatchingTest {
|
||||
MemoryStorageService storageService = new MemoryStorageService(null, null);
|
||||
ISessionsStore sessionsStore = storageService.sessionsStore();
|
||||
this.subscriptionsStore = sessionsStore.subscriptionStore();
|
||||
this.sessionsRepository = new SessionsRepository(sessionsStore);
|
||||
this.sessionsRepository = new SessionsRepository(sessionsStore, null);
|
||||
sut.init(this.sessionsRepository);
|
||||
}
|
||||
|
||||
@@ -178,7 +179,7 @@ public class CTrieSubscriptionDirectoryMatchingTest {
|
||||
sut = new CTrieSubscriptionDirectory();
|
||||
MemoryStorageService memStore = new MemoryStorageService(null, null);
|
||||
ISessionsStore aSessionsStore = memStore.sessionsStore();
|
||||
SessionsRepository sessionsRepository = new SessionsRepository(aSessionsStore);
|
||||
SessionsRepository sessionsRepository = new SessionsRepository(aSessionsStore, null);
|
||||
sut.init(sessionsRepository);
|
||||
|
||||
Subscription sub = clientSubOnTopic("AnySensor1", s);
|
||||
@@ -191,7 +192,7 @@ public class CTrieSubscriptionDirectoryMatchingTest {
|
||||
sut = new CTrieSubscriptionDirectory();
|
||||
MemoryStorageService memStore = new MemoryStorageService(null, null);
|
||||
ISessionsStore aSessionsStore = memStore.sessionsStore();
|
||||
SessionsRepository sessionsRepository = new SessionsRepository(aSessionsStore);
|
||||
SessionsRepository sessionsRepository = new SessionsRepository(aSessionsStore, null);
|
||||
sut.init(sessionsRepository);
|
||||
|
||||
Subscription sub = clientSubOnTopic("AnySensor1", subscription);
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ public class CTrieSubscriptionDirectoryTest {
|
||||
sut = new CTrieSubscriptionDirectory();
|
||||
MemoryStorageService memStore = new MemoryStorageService(null, null);
|
||||
ISessionsStore aSessionsStore = memStore.sessionsStore();
|
||||
SessionsRepository sessionsRepository = new SessionsRepository(aSessionsStore);
|
||||
SessionsRepository sessionsRepository = new SessionsRepository(aSessionsStore, null);
|
||||
sut.init(sessionsRepository);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user