Fixed failing tests after moving to H2 as default store

This commit is contained in:
andsel
2018-11-18 10:58:25 +01:00
parent cfa478067e
commit 1141e9f7a1
20 changed files with 48 additions and 824 deletions
@@ -27,9 +27,9 @@ public final class BrokerConstants {
public static final String PASSWORD_FILE_PROPERTY_NAME = "password_file";
public static final String PORT_PROPERTY_NAME = "port";
public static final String HOST_PROPERTY_NAME = "host";
public static final String DEFAULT_MOQUETTE_STORE_MAP_DB_FILENAME = "moquette_store.mapdb";
public static final String DEFAULT_MOQUETTE_STORE_H2_DB_FILENAME = "moquette_store.h2";
public static final String DEFAULT_PERSISTENT_PATH = System.getProperty("user.dir") + File.separator
+ DEFAULT_MOQUETTE_STORE_MAP_DB_FILENAME;
+ DEFAULT_MOQUETTE_STORE_H2_DB_FILENAME;
public static final String WEB_SOCKET_PORT_PROPERTY_NAME = "websocket_port";
public static final String WSS_PORT_PROPERTY_NAME = "secure_websocket_port";
@@ -52,6 +52,7 @@ public class Server {
private volatile boolean initialized;
private PostOffice dispatcher;
private BrokerInterceptor interceptor;
private H2Builder h2Builder;
public static void main(String[] args) throws IOException {
final Server server = new Server();
@@ -162,7 +163,8 @@ public class Server {
final ISubscriptionsRepository subscriptionsRepository;
if (persistencePath != null && !persistencePath.isEmpty()) {
LOG.trace("Configuring H2 subscriptions store to {}", persistencePath);
subscriptionsRepository = new H2Builder(config, scheduler).initStore().subscriptionsRepository();
h2Builder = new H2Builder(config, scheduler);
subscriptionsRepository = h2Builder.initStore().subscriptionsRepository();
} else {
LOG.trace("Configuring in-memory subscriptions store");
subscriptionsRepository = new MemorySubscriptionsRepository();
@@ -324,6 +326,11 @@ public class Server {
// and SessionsRepository does not stop its tasks. Thus shutdownNow().
scheduler.shutdownNow();
if (h2Builder != null) {
LOG.trace("Shutting down H2 persistence {}");
h2Builder.closeStore();
}
LOG.info("Moquette integration has been stopped.");
}
@@ -160,7 +160,7 @@ public final class BrokerInterceptor implements Interceptor {
public void notifyMessageAcknowledged(final InterceptAcknowledgedMessage msg) {
for (final InterceptHandler handler : this.handlers.get(InterceptAcknowledgedMessage.class)) {
LOG.debug("Notifying MQTT ACK message to interceptor. CId={}, messageId={}, topic={}, interceptorId={}",
msg.getMsg().getClientID(), msg.getPacketID(), msg.getTopic(), handler.getID());
msg.getMsg()/*.getClientID()*/, msg.getPacketID(), msg.getTopic(), handler.getID());
executor.execute(() -> handler.onMessageAcknowledged(msg));
}
}
@@ -48,4 +48,8 @@ public class H2Builder {
public ISubscriptionsRepository subscriptionsRepository() {
return new H2SubscriptionsRepository(mvStore);
}
public void closeStore() {
mvStore.close();
}
}