2014-06-11 23:40:19 +02:00
|
|
|
/*
|
2017-03-19 22:01:23 +01:00
|
|
|
* Copyright (c) 2012-2017 The original author or authors
|
2014-06-11 23:40:19 +02:00
|
|
|
* ------------------------------------------------------
|
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
|
|
|
* and Apache License v2.0 which accompanies this distribution.
|
|
|
|
|
*
|
|
|
|
|
* The Eclipse Public License is available at
|
|
|
|
|
* http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
|
*
|
|
|
|
|
* The Apache License v2.0 is available at
|
|
|
|
|
* http://www.opensource.org/licenses/apache2.0.php
|
|
|
|
|
*
|
|
|
|
|
* You may elect to redistribute this code under either of these licenses.
|
|
|
|
|
*/
|
2017-02-01 15:22:29 +01:00
|
|
|
|
2015-11-20 20:54:27 +01:00
|
|
|
package io.moquette.server;
|
2013-09-19 20:10:18 +02:00
|
|
|
|
2016-06-28 17:27:35 +02:00
|
|
|
import com.hazelcast.config.ClasspathXmlConfig;
|
|
|
|
|
import com.hazelcast.config.Config;
|
|
|
|
|
import com.hazelcast.config.FileSystemXmlConfig;
|
|
|
|
|
import com.hazelcast.core.Hazelcast;
|
|
|
|
|
import com.hazelcast.core.HazelcastInstance;
|
|
|
|
|
import com.hazelcast.core.HazelcastInstanceNotActiveException;
|
|
|
|
|
import com.hazelcast.core.ITopic;
|
2015-12-08 14:04:35 +01:00
|
|
|
import io.moquette.BrokerConstants;
|
2017-01-12 17:00:18 +01:00
|
|
|
import io.moquette.connections.IConnectionsManager;
|
2016-06-28 17:27:35 +02:00
|
|
|
import io.moquette.interception.HazelcastInterceptHandler;
|
|
|
|
|
import io.moquette.interception.HazelcastMsg;
|
2015-12-08 12:06:31 +01:00
|
|
|
import io.moquette.interception.InterceptHandler;
|
2016-12-31 19:21:12 +01:00
|
|
|
import io.moquette.server.config.*;
|
2015-11-20 20:54:27 +01:00
|
|
|
import io.moquette.server.netty.NettyAcceptor;
|
|
|
|
|
import io.moquette.spi.impl.ProtocolProcessor;
|
2017-01-28 10:06:30 +01:00
|
|
|
import io.moquette.spi.impl.ProtocolProcessorBootstrapper;
|
2016-09-16 10:08:02 +09:00
|
|
|
import io.moquette.spi.impl.subscriptions.Subscription;
|
2015-12-13 17:01:23 +01:00
|
|
|
import io.moquette.spi.security.IAuthenticator;
|
|
|
|
|
import io.moquette.spi.security.IAuthorizator;
|
2015-12-13 16:42:04 +01:00
|
|
|
import io.moquette.spi.security.ISslContextCreator;
|
2017-01-28 10:06:30 +01:00
|
|
|
import io.netty.handler.codec.mqtt.MqttPublishMessage;
|
2015-03-15 16:45:11 +01:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
2013-09-19 20:10:18 +02:00
|
|
|
import java.io.File;
|
2016-07-22 13:08:48 +02:00
|
|
|
import java.io.FileNotFoundException;
|
2013-09-19 20:10:18 +02:00
|
|
|
import java.io.IOException;
|
2015-12-08 12:06:31 +01:00
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.List;
|
2014-03-02 18:16:50 +01:00
|
|
|
import java.util.Properties;
|
2017-03-03 16:31:43 +01:00
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
|
|
|
|
2017-01-11 15:56:24 +01:00
|
|
|
import static io.moquette.logging.LoggingUtils.getInterceptorIds;
|
|
|
|
|
|
2013-09-19 20:10:18 +02:00
|
|
|
/**
|
2017-02-01 15:22:29 +01:00
|
|
|
* Launch a configured version of the server.
|
|
|
|
|
*
|
2013-09-19 20:10:18 +02:00
|
|
|
* @author andrea
|
|
|
|
|
*/
|
|
|
|
|
public class Server {
|
2017-02-01 15:22:29 +01:00
|
|
|
|
2013-09-19 20:10:18 +02:00
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(Server.class);
|
2016-07-22 13:08:48 +02:00
|
|
|
|
|
|
|
|
private static final String HZ_INTERCEPT_HANDLER = HazelcastInterceptHandler.class.getCanonicalName();
|
2017-02-01 15:22:29 +01:00
|
|
|
|
2013-09-19 20:10:18 +02:00
|
|
|
private ServerAcceptor m_acceptor;
|
2015-08-22 15:35:11 +02:00
|
|
|
|
2015-12-08 18:12:00 +01:00
|
|
|
private volatile boolean m_initialized;
|
|
|
|
|
|
|
|
|
|
private ProtocolProcessor m_processor;
|
|
|
|
|
|
2016-06-28 17:27:35 +02:00
|
|
|
private HazelcastInstance hazelcastInstance;
|
|
|
|
|
|
2016-07-22 13:32:25 +02:00
|
|
|
private ProtocolProcessorBootstrapper m_processorBootstrapper;
|
2016-07-22 12:09:10 +02:00
|
|
|
|
2017-03-03 16:31:43 +01:00
|
|
|
private ScheduledExecutorService scheduler;
|
|
|
|
|
|
2013-09-19 20:10:18 +02:00
|
|
|
public static void main(String[] args) throws IOException {
|
|
|
|
|
final Server server = new Server();
|
2013-11-24 11:51:15 +01:00
|
|
|
server.startServer();
|
2017-01-11 22:21:03 +01:00
|
|
|
System.out.println("Server started, version 0.10-SNAPSHOT");
|
2017-02-01 15:22:29 +01:00
|
|
|
// Bind a shutdown hook
|
2013-09-19 20:10:18 +02:00
|
|
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
2017-02-01 15:22:29 +01:00
|
|
|
|
2013-09-19 20:10:18 +02:00
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
server.stopServer();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2017-02-01 15:22:29 +01:00
|
|
|
|
2014-07-12 12:56:38 +02:00
|
|
|
/**
|
2017-02-01 15:22:29 +01:00
|
|
|
* Starts Moquette bringing the configuration from the file located at m_config/moquette.conf
|
|
|
|
|
*
|
|
|
|
|
* @throws IOException
|
|
|
|
|
* in case of any IO error.
|
2014-07-12 12:56:38 +02:00
|
|
|
*/
|
2013-09-19 20:10:18 +02:00
|
|
|
public void startServer() throws IOException {
|
2017-02-01 15:22:29 +01:00
|
|
|
File defaultConfigurationFile = defaultConfigFile();
|
2017-01-11 15:56:24 +01:00
|
|
|
LOG.info("Starting Moquette server. Configuration file path = {}.", defaultConfigurationFile.getAbsolutePath());
|
|
|
|
|
IResourceLoader filesystemLoader = new FileResourceLoader(defaultConfigurationFile);
|
2016-12-31 19:21:12 +01:00
|
|
|
final IConfig config = new ResourceLoaderConfig(filesystemLoader);
|
2015-08-22 15:35:11 +02:00
|
|
|
startServer(config);
|
2014-07-12 12:56:38 +02:00
|
|
|
}
|
|
|
|
|
|
2016-12-31 19:21:12 +01:00
|
|
|
private static File defaultConfigFile() {
|
|
|
|
|
String configPath = System.getProperty("moquette.path", null);
|
|
|
|
|
return new File(configPath, IConfig.DEFAULT_CONFIG);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-12 12:56:38 +02:00
|
|
|
/**
|
|
|
|
|
* Starts Moquette bringing the configuration from the given file
|
2017-02-01 15:22:29 +01:00
|
|
|
*
|
|
|
|
|
* @param configFile
|
|
|
|
|
* text file that contains the configuration.
|
|
|
|
|
* @throws IOException
|
|
|
|
|
* in case of any IO Error.
|
2014-07-12 12:56:38 +02:00
|
|
|
*/
|
|
|
|
|
public void startServer(File configFile) throws IOException {
|
2017-01-11 15:56:24 +01:00
|
|
|
LOG.info("Starting Moquette server. Configuration file path = {}.", configFile.getAbsolutePath());
|
2016-12-31 19:21:12 +01:00
|
|
|
IResourceLoader filesystemLoader = new FileResourceLoader(configFile);
|
|
|
|
|
final IConfig config = new ResourceLoaderConfig(filesystemLoader);
|
2015-08-22 15:35:11 +02:00
|
|
|
startServer(config);
|
2014-07-12 12:56:38 +02:00
|
|
|
}
|
2017-02-01 15:22:29 +01:00
|
|
|
|
2014-07-12 12:56:38 +02:00
|
|
|
/**
|
|
|
|
|
* Starts the server with the given properties.
|
2017-02-01 15:22:29 +01:00
|
|
|
*
|
2015-03-11 10:44:00 -04:00
|
|
|
* Its suggested to at least have the following properties:
|
2014-07-12 12:56:38 +02:00
|
|
|
* <ul>
|
2017-02-01 15:22:29 +01:00
|
|
|
* <li>port</li>
|
|
|
|
|
* <li>password_file</li>
|
2014-07-12 12:56:38 +02:00
|
|
|
* </ul>
|
2017-01-04 12:52:42 +01:00
|
|
|
*
|
2017-02-01 15:22:29 +01:00
|
|
|
* @param configProps
|
|
|
|
|
* the properties map to use as configuration.
|
|
|
|
|
* @throws IOException
|
|
|
|
|
* in case of any IO Error.
|
2014-07-12 12:56:38 +02:00
|
|
|
*/
|
|
|
|
|
public void startServer(Properties configProps) throws IOException {
|
2017-02-01 15:22:29 +01:00
|
|
|
LOG.info("Starting Moquette server using properties object...");
|
2015-08-22 15:35:11 +02:00
|
|
|
final IConfig config = new MemoryConfig(configProps);
|
|
|
|
|
startServer(config);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Starts Moquette bringing the configuration files from the given Config implementation.
|
2017-02-01 15:22:29 +01:00
|
|
|
*
|
|
|
|
|
* @param config
|
|
|
|
|
* the configuration to use to start the broker.
|
|
|
|
|
* @throws IOException
|
|
|
|
|
* in case of any IO Error.
|
2015-08-22 15:35:11 +02:00
|
|
|
*/
|
|
|
|
|
public void startServer(IConfig config) throws IOException {
|
2017-02-01 15:22:29 +01:00
|
|
|
LOG.info("Starting Moquette server using IConfig instance...");
|
2015-12-08 12:06:31 +01:00
|
|
|
startServer(config, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2017-02-01 15:22:29 +01:00
|
|
|
* Starts Moquette with config provided by an implementation of IConfig class and with the set
|
|
|
|
|
* of InterceptHandler.
|
|
|
|
|
*
|
|
|
|
|
* @param config
|
|
|
|
|
* the configuration to use to start the broker.
|
|
|
|
|
* @param handlers
|
|
|
|
|
* the handlers to install in the broker.
|
|
|
|
|
* @throws IOException
|
|
|
|
|
* in case of any IO Error.
|
|
|
|
|
*/
|
2015-12-08 12:06:31 +01:00
|
|
|
public void startServer(IConfig config, List<? extends InterceptHandler> handlers) throws IOException {
|
2017-02-01 15:22:29 +01:00
|
|
|
LOG.info("Starting moquette server using IConfig instance and intercept handlers...");
|
2015-12-13 17:01:23 +01:00
|
|
|
startServer(config, handlers, null, null, null);
|
2015-12-13 16:26:12 +01:00
|
|
|
}
|
|
|
|
|
|
2017-02-01 15:22:29 +01:00
|
|
|
public void startServer(IConfig config, List<? extends InterceptHandler> handlers, ISslContextCreator sslCtxCreator,
|
|
|
|
|
IAuthenticator authenticator, IAuthorizator authorizator) throws IOException {
|
2015-12-08 12:06:31 +01:00
|
|
|
if (handlers == null) {
|
|
|
|
|
handlers = Collections.emptyList();
|
|
|
|
|
}
|
2017-01-11 15:56:24 +01:00
|
|
|
LOG.info("Starting Moquette Server. MQTT message interceptors = {}.", getInterceptorIds(handlers));
|
2015-12-08 12:06:31 +01:00
|
|
|
|
2017-03-03 16:31:43 +01:00
|
|
|
scheduler = Executors.newScheduledThreadPool(1);
|
|
|
|
|
|
2016-07-22 12:09:10 +02:00
|
|
|
final String handlerProp = System.getProperty(BrokerConstants.INTERCEPT_HANDLER_PROPERTY_NAME);
|
2015-07-24 01:15:09 -03:00
|
|
|
if (handlerProp != null) {
|
2016-07-22 12:09:10 +02:00
|
|
|
config.setProperty(BrokerConstants.INTERCEPT_HANDLER_PROPERTY_NAME, handlerProp);
|
2015-07-24 01:15:09 -03:00
|
|
|
}
|
2016-07-22 13:08:48 +02:00
|
|
|
configureCluster(config);
|
2017-02-01 15:22:29 +01:00
|
|
|
LOG.info(
|
|
|
|
|
"Configuring Using persistent store file. Path = {}.",
|
|
|
|
|
config.getProperty(BrokerConstants.PERSISTENT_STORE_PROPERTY_NAME));
|
2016-07-22 13:32:25 +02:00
|
|
|
m_processorBootstrapper = new ProtocolProcessorBootstrapper();
|
2017-01-11 15:56:24 +01:00
|
|
|
LOG.info("Initializing MQTT protocol processor...");
|
2017-02-01 15:22:29 +01:00
|
|
|
final ProtocolProcessor processor = m_processorBootstrapper
|
|
|
|
|
.init(config, handlers, authenticator, authorizator, this);
|
2015-08-22 15:35:11 +02:00
|
|
|
|
2015-12-13 16:26:12 +01:00
|
|
|
if (sslCtxCreator == null) {
|
2017-01-11 15:56:24 +01:00
|
|
|
LOG.warn("Using default SSL context creator...");
|
2015-12-13 16:26:12 +01:00
|
|
|
sslCtxCreator = new DefaultMoquetteSslContextCreator(config);
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-11 15:56:24 +01:00
|
|
|
LOG.info("Binding server to the configured ports...");
|
2013-11-24 11:51:15 +01:00
|
|
|
m_acceptor = new NettyAcceptor();
|
2015-12-13 16:26:12 +01:00
|
|
|
m_acceptor.initialize(processor, config, sslCtxCreator);
|
2015-12-08 18:12:00 +01:00
|
|
|
m_processor = processor;
|
2017-01-11 15:56:24 +01:00
|
|
|
|
|
|
|
|
LOG.info("The Moquette server has been initialized successfully.");
|
2015-12-08 18:12:00 +01:00
|
|
|
m_initialized = true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-22 13:08:48 +02:00
|
|
|
private void configureCluster(IConfig config) throws FileNotFoundException {
|
2017-02-01 15:22:29 +01:00
|
|
|
LOG.info("Configuring embedded Hazelcast instance...");
|
2016-07-22 13:08:48 +02:00
|
|
|
String interceptHandlerClassname = config.getProperty(BrokerConstants.INTERCEPT_HANDLER_PROPERTY_NAME);
|
|
|
|
|
if (interceptHandlerClassname == null || !HZ_INTERCEPT_HANDLER.equals(interceptHandlerClassname)) {
|
2017-02-01 15:22:29 +01:00
|
|
|
LOG.info("There are no Hazelcast intercept handlers. The server won't start a Hazelcast instance.");
|
2016-07-22 13:08:48 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
String hzConfigPath = config.getProperty(BrokerConstants.HAZELCAST_CONFIGURATION);
|
|
|
|
|
if (hzConfigPath != null) {
|
|
|
|
|
boolean isHzConfigOnClasspath = this.getClass().getClassLoader().getResource(hzConfigPath) != null;
|
2017-02-01 15:22:29 +01:00
|
|
|
Config hzconfig = isHzConfigOnClasspath
|
|
|
|
|
? new ClasspathXmlConfig(hzConfigPath)
|
|
|
|
|
: new FileSystemXmlConfig(hzConfigPath);
|
|
|
|
|
LOG.info("Starting Hazelcast instance. ConfigurationFile = {}.", hzconfig);
|
2016-07-22 13:08:48 +02:00
|
|
|
hazelcastInstance = Hazelcast.newHazelcastInstance(hzconfig);
|
|
|
|
|
} else {
|
2017-01-11 15:56:24 +01:00
|
|
|
LOG.info("Starting Hazelcast instance with default configuration.");
|
2016-07-22 13:08:48 +02:00
|
|
|
hazelcastInstance = Hazelcast.newHazelcastInstance();
|
|
|
|
|
}
|
|
|
|
|
listenOnHazelCastMsg();
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-28 17:27:35 +02:00
|
|
|
private void listenOnHazelCastMsg() {
|
2017-02-01 15:22:29 +01:00
|
|
|
LOG.info("Subscribing to Hazelcast topic. TopicName = {}.", "moquette");
|
2016-06-28 17:27:35 +02:00
|
|
|
HazelcastInstance hz = getHazelcastInstance();
|
|
|
|
|
ITopic<HazelcastMsg> topic = hz.getTopic("moquette");
|
|
|
|
|
topic.addMessageListener(new HazelcastListener(this));
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-01 15:22:29 +01:00
|
|
|
public HazelcastInstance getHazelcastInstance() {
|
2016-06-28 17:27:35 +02:00
|
|
|
return hazelcastInstance;
|
2015-12-08 18:12:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2017-02-01 15:22:29 +01:00
|
|
|
* Use the broker to publish a message. It's intended for embedding applications. It can be used
|
|
|
|
|
* only after the server is correctly started with startServer.
|
2015-12-08 18:12:00 +01:00
|
|
|
*
|
2017-02-01 15:22:29 +01:00
|
|
|
* @param msg
|
|
|
|
|
* the message to forward.
|
|
|
|
|
* @param clientId
|
|
|
|
|
* the id of the sending server.
|
|
|
|
|
* @throws IllegalStateException
|
|
|
|
|
* if the server is not yet started
|
|
|
|
|
*/
|
2017-01-28 10:06:30 +01:00
|
|
|
public void internalPublish(MqttPublishMessage msg, final String clientId) {
|
|
|
|
|
final int messageID = msg.variableHeader().messageId();
|
2015-12-08 18:12:00 +01:00
|
|
|
if (!m_initialized) {
|
2017-02-01 15:22:29 +01:00
|
|
|
LOG.error(
|
|
|
|
|
"The server is not started. The message cannot be published. MqttClientId = {}, messageId = {}",
|
|
|
|
|
clientId,
|
|
|
|
|
messageID);
|
2017-01-18 23:27:02 +01:00
|
|
|
throw new IllegalStateException("Can't publish on a server is not yet started");
|
2015-12-08 18:12:00 +01:00
|
|
|
}
|
2017-01-28 10:06:30 +01:00
|
|
|
LOG.debug("Publishing message. MqttClientId = {}, messageId = {}", clientId, messageID);
|
|
|
|
|
m_processor.internalPublish(msg, clientId);
|
2013-09-19 20:10:18 +02:00
|
|
|
}
|
2017-02-01 15:22:29 +01:00
|
|
|
|
2013-09-19 20:10:18 +02:00
|
|
|
public void stopServer() {
|
2017-02-01 15:22:29 +01:00
|
|
|
LOG.info("Unbinding server from the configured ports...");
|
2013-09-19 20:10:18 +02:00
|
|
|
m_acceptor.close();
|
2017-01-11 15:56:24 +01:00
|
|
|
LOG.info("Stopping MQTT protocol processor...");
|
2016-07-22 13:32:25 +02:00
|
|
|
m_processorBootstrapper.shutdown();
|
2015-12-08 18:12:00 +01:00
|
|
|
m_initialized = false;
|
2016-07-22 12:09:10 +02:00
|
|
|
if (hazelcastInstance != null) {
|
2017-02-01 15:22:29 +01:00
|
|
|
LOG.info("Stopping embedded Hazelcast instance...");
|
2016-06-28 17:27:35 +02:00
|
|
|
try {
|
|
|
|
|
hazelcastInstance.shutdown();
|
2016-07-22 12:09:10 +02:00
|
|
|
} catch (HazelcastInstanceNotActiveException e) {
|
2017-01-11 15:56:24 +01:00
|
|
|
LOG.warn("The embedded Hazelcast instance is already shut down.");
|
2016-06-28 17:27:35 +02:00
|
|
|
}
|
|
|
|
|
}
|
2017-03-03 16:31:43 +01:00
|
|
|
|
|
|
|
|
scheduler.shutdown();
|
|
|
|
|
|
2017-01-11 15:56:24 +01:00
|
|
|
LOG.info("The Moquette server has been stopped.");
|
2013-09-19 20:10:18 +02:00
|
|
|
}
|
2016-07-09 09:09:57 +02:00
|
|
|
|
2016-09-16 10:08:02 +09:00
|
|
|
/**
|
2017-02-01 15:22:29 +01:00
|
|
|
* SPI method used by Broker embedded applications to get list of subscribers. Returns null if
|
|
|
|
|
* the broker is not started.
|
2017-01-04 12:52:42 +01:00
|
|
|
*
|
|
|
|
|
* @return list of subscriptions.
|
2016-09-16 10:08:02 +09:00
|
|
|
*/
|
|
|
|
|
public List<Subscription> getSubscriptions() {
|
|
|
|
|
if (m_processorBootstrapper == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return m_processorBootstrapper.getSubscriptions();
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-22 13:08:48 +02:00
|
|
|
/**
|
|
|
|
|
* SPI method used by Broker embedded applications to add intercept handlers.
|
2017-02-01 15:22:29 +01:00
|
|
|
*
|
|
|
|
|
* @param interceptHandler
|
|
|
|
|
* the handler to add.
|
|
|
|
|
*/
|
2017-01-10 17:06:13 +01:00
|
|
|
public void addInterceptHandler(InterceptHandler interceptHandler) {
|
2016-07-09 09:09:57 +02:00
|
|
|
if (!m_initialized) {
|
2017-02-01 15:22:29 +01:00
|
|
|
LOG.error(
|
|
|
|
|
"The server is not started. The MQTT message interceptor cannot be added. InterceptorId = {}.",
|
|
|
|
|
interceptHandler.getID());
|
2016-07-09 09:09:57 +02:00
|
|
|
throw new IllegalStateException("Can't register interceptors on a server that is not yet started");
|
|
|
|
|
}
|
2017-01-11 15:56:24 +01:00
|
|
|
LOG.info("Adding MQTT message interceptor. InterceptorId = {}.", interceptHandler.getID());
|
2017-01-10 17:06:13 +01:00
|
|
|
m_processor.addInterceptHandler(interceptHandler);
|
2016-07-09 09:09:57 +02:00
|
|
|
}
|
|
|
|
|
|
2016-07-22 13:08:48 +02:00
|
|
|
/**
|
|
|
|
|
* SPI method used by Broker embedded applications to remove intercept handlers.
|
2017-02-01 15:22:29 +01:00
|
|
|
*
|
|
|
|
|
* @param interceptHandler
|
|
|
|
|
* the handler to remove.
|
|
|
|
|
*/
|
2017-01-10 17:06:13 +01:00
|
|
|
public void removeInterceptHandler(InterceptHandler interceptHandler) {
|
2016-07-09 09:09:57 +02:00
|
|
|
if (!m_initialized) {
|
2017-02-01 15:22:29 +01:00
|
|
|
LOG.error(
|
|
|
|
|
"The server is not started. The MQTT message interceptor cannot be removed. InterceptorId = {}.",
|
|
|
|
|
interceptHandler.getID());
|
2016-07-09 09:09:57 +02:00
|
|
|
throw new IllegalStateException("Can't deregister interceptors from a server that is not yet started");
|
|
|
|
|
}
|
2017-01-11 15:56:24 +01:00
|
|
|
LOG.info("Removing MQTT message interceptor. InterceptorId = {}.", interceptHandler.getID());
|
2017-01-10 17:06:13 +01:00
|
|
|
m_processor.removeInterceptHandler(interceptHandler);
|
2016-07-09 09:09:57 +02:00
|
|
|
}
|
|
|
|
|
|
2017-01-12 17:00:18 +01:00
|
|
|
/**
|
|
|
|
|
* Returns the connections manager of this broker.
|
2017-02-01 15:22:29 +01:00
|
|
|
*
|
2017-01-28 10:06:30 +01:00
|
|
|
* @return IConnectionsManager the instance used bt the broker.
|
2017-01-12 17:00:18 +01:00
|
|
|
*/
|
|
|
|
|
public IConnectionsManager getConnectionsManager() {
|
|
|
|
|
return m_processorBootstrapper.getConnectionDescriptors();
|
2016-07-09 09:09:57 +02:00
|
|
|
}
|
|
|
|
|
|
2017-01-31 18:06:03 +01:00
|
|
|
public ProtocolProcessor getProcessor() {
|
|
|
|
|
return m_processor;
|
|
|
|
|
}
|
2017-03-03 16:31:43 +01:00
|
|
|
|
|
|
|
|
public ScheduledExecutorService getScheduler() {
|
|
|
|
|
return scheduler;
|
|
|
|
|
}
|
2013-09-19 20:10:18 +02:00
|
|
|
}
|