broker/MapDBPersistentStore: code formatter used
This commit is contained in:
@@ -23,14 +23,12 @@ import org.mapdb.DB;
|
||||
import org.mapdb.DBMaker;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static io.moquette.BrokerConstants.AUTOSAVE_INTERVAL_PROPERTY_NAME;
|
||||
import static io.moquette.BrokerConstants.PERSISTENT_STORE_PROPERTY_NAME;
|
||||
|
||||
@@ -40,10 +38,11 @@ import static io.moquette.BrokerConstants.PERSISTENT_STORE_PROPERTY_NAME;
|
||||
public class MapDBPersistentStore {
|
||||
|
||||
/**
|
||||
* This is a DTO used to persist minimal status (clean session and activation status) of
|
||||
* a session.
|
||||
* */
|
||||
* This is a DTO used to persist minimal status (clean session and activation status) of a
|
||||
* session.
|
||||
*/
|
||||
public static class PersistentSession implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 5052054783220481854L;
|
||||
public final boolean cleanSession;
|
||||
|
||||
@@ -69,8 +68,9 @@ public class MapDBPersistentStore {
|
||||
|
||||
/**
|
||||
* Factory method to create message store backed by MapDB
|
||||
*
|
||||
* @return the message store instance.
|
||||
* */
|
||||
*/
|
||||
public IMessagesStore messagesStore() {
|
||||
return m_messageStore;
|
||||
}
|
||||
@@ -92,13 +92,20 @@ public class MapDBPersistentStore {
|
||||
boolean fileNewlyCreated = tmpFile.createNewFile();
|
||||
LOG.warn("Using {} MapDB store file. Path = {}.", fileNewlyCreated ? "fresh" : "existing", m_storePath);
|
||||
} catch (IOException ex) {
|
||||
LOG.error("Unable to open MapDB store file. Path = {}, cause = {}, errorMessage = {}.", m_storePath, ex.getCause(), ex.getMessage());
|
||||
throw new RuntimeException("Can't create temp file for subscriptions storage [" + m_storePath + "]", ex);
|
||||
LOG.error(
|
||||
"Unable to open MapDB store file. Path = {}, cause = {}, errorMessage = {}.",
|
||||
m_storePath,
|
||||
ex.getCause(),
|
||||
ex.getMessage());
|
||||
throw new RuntimeException(
|
||||
"Can't create temp file for subscriptions storage [" + m_storePath + "]",
|
||||
ex);
|
||||
}
|
||||
m_db = DBMaker.newFileDB(tmpFile).make();
|
||||
}
|
||||
LOG.info("Scheduling MapDB commit task...");
|
||||
m_scheduler.scheduleWithFixedDelay(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
LOG.debug("Committing to MapDB...");
|
||||
@@ -106,7 +113,7 @@ public class MapDBPersistentStore {
|
||||
}
|
||||
}, this.m_autosaveInterval, this.m_autosaveInterval, TimeUnit.SECONDS);
|
||||
|
||||
//TODO check m_db is valid and
|
||||
// TODO check m_db is valid and
|
||||
m_messageStore = new MapDBMessagesStore(m_db);
|
||||
m_messageStore.initStore();
|
||||
|
||||
@@ -127,7 +134,8 @@ public class MapDBPersistentStore {
|
||||
this.m_scheduler.shutdown();
|
||||
try {
|
||||
m_scheduler.awaitTermination(10L, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {}
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
if (!m_scheduler.isTerminated()) {
|
||||
LOG.warn("Forcing shutdown of MapDB commit tasks...");
|
||||
m_scheduler.shutdown();
|
||||
|
||||
Reference in New Issue
Block a user