From 24282fe0ab82a3e02ac8c186b745d184655b41a9 Mon Sep 17 00:00:00 2001 From: "selva.andre" Date: Tue, 9 Sep 2014 17:06:13 +0200 Subject: [PATCH] Minor, removed MapDB shutdown hook because it's responsibility of the Moquette shutdown hook to teardown the storage --- .../mqtt/moquette/messaging/spi/impl/SimpleMessaging.java | 6 ++++-- .../messaging/spi/persistence/MapDBPersistentStore.java | 5 ++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/SimpleMessaging.java b/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/SimpleMessaging.java index 7d322bcc..a0e44b1f 100644 --- a/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/SimpleMessaging.java +++ b/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/SimpleMessaging.java @@ -124,7 +124,10 @@ public class SimpleMessaging implements IMessaging, EventHandler { disruptorPublish(new StopEvent()); try { //wait the callback notification from the protocol processor thread + LOG.debug("waiting 10 sec to m_stopLatch"); boolean elapsed = !m_stopLatch.await(10, TimeUnit.SECONDS); + LOG.debug("after m_stopLatch"); + m_executor.shutdown(); if (elapsed) { LOG.error("Can't stop the server in 10 seconds"); } @@ -181,9 +184,8 @@ public class SimpleMessaging implements IMessaging, EventHandler { private void processStop() { LOG.debug("processStop invoked"); m_storageService.close(); - // m_eventProcessor.halt(); - m_executor.shutdown(); +// m_executor.shutdown(); subscriptions = null; m_stopLatch.countDown(); diff --git a/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/persistence/MapDBPersistentStore.java b/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/persistence/MapDBPersistentStore.java index a0d7a37f..a8123028 100644 --- a/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/persistence/MapDBPersistentStore.java +++ b/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/persistence/MapDBPersistentStore.java @@ -65,7 +65,6 @@ public class MapDBPersistentStore implements IMessagesStore, ISessionsStore { throw new MQTTException("Can't create temp file for subscriptions storage [" + STORAGE_FILE_PATH + "]", ex); } m_db = DBMaker.newFileDB(tmpFile) - .closeOnJvmShutdown() .make(); m_retainedStore = m_db.getHashMap("retained"); m_persistentMessageStore = m_db.getHashMap("persistedMessages"); @@ -219,9 +218,9 @@ public class MapDBPersistentStore implements IMessagesStore, ISessionsStore { } public void close() { - LOG.debug("closing disk storage"); this.m_db.commit(); -// this.m_db.close(); this is done by the Shutdown hook into MapDB + this.m_db.close(); + LOG.debug("closed disk storage"); } /*-------- QoS 2 storage management --------------*/