Changed the way of create MapDB's messages and session stores, it's now more coupled (they are the same stuff at the end)
This commit is contained in:
@@ -75,7 +75,7 @@ public class ProtocolProcessorBootstrapper {
|
|||||||
m_mapStorage = new MapDBPersistentStore(props);
|
m_mapStorage = new MapDBPersistentStore(props);
|
||||||
m_mapStorage.initStore();
|
m_mapStorage.initStore();
|
||||||
IMessagesStore messagesStore = m_mapStorage.messagesStore();
|
IMessagesStore messagesStore = m_mapStorage.messagesStore();
|
||||||
ISessionsStore sessionsStore = m_mapStorage.sessionsStore(messagesStore);
|
ISessionsStore sessionsStore = m_mapStorage.sessionsStore();
|
||||||
|
|
||||||
List<InterceptHandler> observers = new ArrayList<>(embeddedObservers);
|
List<InterceptHandler> observers = new ArrayList<>(embeddedObservers);
|
||||||
String interceptorClassName = props.getProperty(BrokerConstants.INTERCEPT_HANDLER_PROPERTY_NAME);
|
String interceptorClassName = props.getProperty(BrokerConstants.INTERCEPT_HANDLER_PROPERTY_NAME);
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ public class MapDBPersistentStore {
|
|||||||
private final int m_autosaveInterval; // in seconds
|
private final int m_autosaveInterval; // in seconds
|
||||||
|
|
||||||
protected final ScheduledExecutorService m_scheduler = Executors.newScheduledThreadPool(1);
|
protected final ScheduledExecutorService m_scheduler = Executors.newScheduledThreadPool(1);
|
||||||
|
private MapDBMessagesStore m_messageStore;
|
||||||
|
private MapDBSessionsStore m_sessionsStore;
|
||||||
|
|
||||||
public MapDBPersistentStore(IConfig props) {
|
public MapDBPersistentStore(IConfig props) {
|
||||||
this.m_storePath = props.getProperty(PERSISTENT_STORE_PROPERTY_NAME, "");
|
this.m_storePath = props.getProperty(PERSISTENT_STORE_PROPERTY_NAME, "");
|
||||||
@@ -69,16 +71,11 @@ public class MapDBPersistentStore {
|
|||||||
* Factory method to create message store backed by MapDB
|
* Factory method to create message store backed by MapDB
|
||||||
* */
|
* */
|
||||||
public IMessagesStore messagesStore() {
|
public IMessagesStore messagesStore() {
|
||||||
//TODO check m_db is valid and
|
return m_messageStore;
|
||||||
IMessagesStore msgStore = new MapDBMessagesStore(m_db);
|
|
||||||
msgStore.initStore();
|
|
||||||
return msgStore;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISessionsStore sessionsStore(IMessagesStore msgStore) {
|
public ISessionsStore sessionsStore() {
|
||||||
ISessionsStore sessionsStore = new MapDBSessionsStore(m_db, msgStore);
|
return m_sessionsStore;
|
||||||
sessionsStore.initStore();
|
|
||||||
return sessionsStore;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initStore() {
|
public void initStore() {
|
||||||
@@ -102,6 +99,13 @@ public class MapDBPersistentStore {
|
|||||||
m_db.commit();
|
m_db.commit();
|
||||||
}
|
}
|
||||||
}, this.m_autosaveInterval, this.m_autosaveInterval, TimeUnit.SECONDS);
|
}, this.m_autosaveInterval, this.m_autosaveInterval, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
//TODO check m_db is valid and
|
||||||
|
m_messageStore = new MapDBMessagesStore(m_db);
|
||||||
|
m_messageStore.initStore();
|
||||||
|
|
||||||
|
m_sessionsStore = new MapDBSessionsStore(m_db, m_messageStore);
|
||||||
|
m_sessionsStore.initStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ class MapDBSessionsStore implements ISessionsStore {
|
|||||||
private ConcurrentMap<String, Map<Integer, String>> m_secondPhaseStore;
|
private ConcurrentMap<String, Map<Integer, String>> m_secondPhaseStore;
|
||||||
|
|
||||||
private final DB m_db;
|
private final DB m_db;
|
||||||
private final IMessagesStore m_messagesStore;
|
private final MapDBMessagesStore m_messagesStore;
|
||||||
|
|
||||||
MapDBSessionsStore(DB db, IMessagesStore messagesStore) {
|
MapDBSessionsStore(DB db, MapDBMessagesStore messagesStore) {
|
||||||
m_db = db;
|
m_db = db;
|
||||||
m_messagesStore = messagesStore;
|
m_messagesStore = messagesStore;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class MapDBPersistentStoreTest {
|
|||||||
m_storageService = new MapDBPersistentStore(conf);
|
m_storageService = new MapDBPersistentStore(conf);
|
||||||
m_storageService.initStore();
|
m_storageService.initStore();
|
||||||
m_messagesStore = m_storageService.messagesStore();
|
m_messagesStore = m_storageService.messagesStore();
|
||||||
m_sessionsStore = m_storageService.sessionsStore(m_messagesStore);
|
m_sessionsStore = m_storageService.sessionsStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
|||||||
Reference in New Issue
Block a user