本文整理汇总了Java中io.moquette.server.config.IConfig类的典型用法代码示例。如果您正苦于以下问题:Java IConfig类的具体用法?Java IConfig怎么用?Java IConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IConfig类属于io.moquette.server.config包,在下文中一共展示了IConfig类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: init
import io.moquette.server.config.IConfig; //导入依赖的package包/类
public void init(IConfig props) {
this.metrics = new MetricRegistry();
this.publishesMetrics = metrics.meter("publish.requests");
this.subscribeMetrics = metrics.meter("subscribe.requests");
this.connectedClientsMetrics = metrics.counter("connect.num_clients");
// ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics)
// .convertRatesTo(TimeUnit.SECONDS)
// .convertDurationsTo(TimeUnit.MILLISECONDS)
// .build();
// reporter.start(1, TimeUnit.MINUTES);
final String email = props.getProperty(METRICS_LIBRATO_EMAIL_PROPERTY_NAME);
final String token = props.getProperty(METRICS_LIBRATO_TOKEN_PROPERTY_NAME);
final String source = props.getProperty(METRICS_LIBRATO_SOURCE_PROPERTY_NAME);
Librato.reporter(this.metrics, email, token)
.setSource(source)
.start(10, TimeUnit.SECONDS);
}
开发者ID:andsel,项目名称:moquette,代码行数:19,代码来源:DropWizardMetricsHandler.java
示例2: startBroker
import io.moquette.server.config.IConfig; //导入依赖的package包/类
private Server startBroker(Server server, IConfig memoryConfig) {
try {
server.startServer(memoryConfig);
return server;
} catch (final IOException e) {
throw propagate(e);
}
}
开发者ID:Ardulink,项目名称:Ardulink-2,代码行数:9,代码来源:MqttBroker.java
示例3: main
import io.moquette.server.config.IConfig; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException, IOException {
IResourceLoader classpathLoader = new ClasspathResourceLoader();
final IConfig classPathConfig = new ResourceLoaderConfig(classpathLoader);
final Server mqttBroker = new Server();
List<? extends InterceptHandler> userHandlers = Collections.singletonList(new PublisherListener());
mqttBroker.startServer(classPathConfig, userHandlers);
System.out.println("Broker started press [CTRL+C] to stop");
//Bind a shutdown hook
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
System.out.println("Stopping broker");
mqttBroker.stopServer();
System.out.println("Broker stopped");
}));
Thread.sleep(20000);
System.out.println("Before self publish");
MqttPublishMessage message = MqttMessageBuilders.publish()
.topicName("/exit")
.retained(true)
// qos(MqttQoS.AT_MOST_ONCE);
// qQos(MqttQoS.AT_LEAST_ONCE);
.qos(MqttQoS.EXACTLY_ONCE)
.payload(Unpooled.copiedBuffer("Hello World!!".getBytes()))
.build();
mqttBroker.internalPublish(message, "INTRLPUB");
System.out.println("After self publish");
}
开发者ID:andsel,项目名称:moquette,代码行数:31,代码来源:EmbeddedLauncher.java
示例4: instantiateConfiguredStore
import io.moquette.server.config.IConfig; //导入依赖的package包/类
private IStore instantiateConfiguredStore(String storageClassName, IConfig props,
ScheduledExecutorService scheduledExecutor) {
LOG.info("Loading storage class {}", storageClassName);
Class<? extends IStore> storageClass;
try {
storageClass = this.getClass().getClassLoader()
.loadClass(storageClassName)
.asSubclass(IStore.class);
} catch (ClassNotFoundException cnfex) {
LOG.error("Cannot find storage class " + storageClassName + " in classpath", cnfex);
return null;
}
final Constructor<? extends IStore> constructor;
try {
constructor = storageClass
.getConstructor(IConfig.class, ScheduledExecutorService.class);
} catch (NoSuchMethodException nsmex) {
LOG.error("Cannot find constructor with required params IConfig, ScheduledExecutorService ", nsmex);
return null;
}
try {
return constructor.newInstance(props, scheduledExecutor);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException ex) {
LOG.error("Cannot instantiate the " + storageClassName + " instance", ex);
}
return null;
}
开发者ID:andsel,项目名称:moquette,代码行数:30,代码来源:ProtocolProcessorBootstrapper.java
示例5: initializePlainTCPTransport
import io.moquette.server.config.IConfig; //导入依赖的package包/类
private void initializePlainTCPTransport(final NettyMQTTHandler handler,
IConfig props) throws IOException {
LOG.info("Configuring TCP MQTT transport");
final MoquetteIdleTimeoutHandler timeoutHandler = new MoquetteIdleTimeoutHandler();
String host = props.getProperty(BrokerConstants.HOST_PROPERTY_NAME);
String tcpPortProp = props.getProperty(PORT_PROPERTY_NAME, DISABLED_PORT_BIND);
if (DISABLED_PORT_BIND.equals(tcpPortProp)) {
LOG.info("Property {} has been set to {}. TCP MQTT will be disabled", BrokerConstants.PORT_PROPERTY_NAME,
DISABLED_PORT_BIND);
return;
}
int port = Integer.parseInt(tcpPortProp);
initFactory(host, port, "TCP MQTT", new PipelineInitializer() {
@Override
void init(ChannelPipeline pipeline) {
pipeline.addFirst("idleStateHandler", new IdleStateHandler(nettyChannelTimeoutSeconds, 0, 0));
pipeline.addAfter("idleStateHandler", "idleEventHandler", timeoutHandler);
// pipeline.addLast("logger", new LoggingHandler("Netty", LogLevel.ERROR));
if (errorsCather.isPresent()) {
pipeline.addLast("bugsnagCatcher", errorsCather.get());
}
pipeline.addFirst("bytemetrics", new BytesMetricsHandler(m_bytesMetricsCollector));
pipeline.addLast("decoder", new MqttDecoder());
pipeline.addLast("encoder", MqttEncoder.INSTANCE);
pipeline.addLast("metrics", new MessageMetricsHandler(m_metricsCollector));
pipeline.addLast("messageLogger", new MQTTMessageLogger());
if (metrics.isPresent()) {
pipeline.addLast("wizardMetrics", metrics.get());
}
pipeline.addLast("handler", handler);
}
});
}
开发者ID:andsel,项目名称:moquette,代码行数:35,代码来源:NettyAcceptor.java
示例6: initializeWebSocketTransport
import io.moquette.server.config.IConfig; //导入依赖的package包/类
private void initializeWebSocketTransport(final NettyMQTTHandler handler, IConfig props) throws IOException {
LOG.info("Configuring Websocket MQTT transport");
String webSocketPortProp = props.getProperty(WEB_SOCKET_PORT_PROPERTY_NAME, DISABLED_PORT_BIND);
if (DISABLED_PORT_BIND.equals(webSocketPortProp)) {
// Do nothing no WebSocket configured
LOG.info("Property {} has been setted to {}. Websocket MQTT will be disabled",
BrokerConstants.WEB_SOCKET_PORT_PROPERTY_NAME, DISABLED_PORT_BIND);
return;
}
int port = Integer.parseInt(webSocketPortProp);
final MoquetteIdleTimeoutHandler timeoutHandler = new MoquetteIdleTimeoutHandler();
String host = props.getProperty(BrokerConstants.HOST_PROPERTY_NAME);
initFactory(host, port, "Websocket MQTT", new PipelineInitializer() {
@Override
void init(ChannelPipeline pipeline) {
pipeline.addLast(new HttpServerCodec());
pipeline.addLast("aggregator", new HttpObjectAggregator(65536));
pipeline.addLast("webSocketHandler",
new WebSocketServerProtocolHandler("/mqtt", MQTT_SUBPROTOCOL_CSV_LIST));
pipeline.addLast("ws2bytebufDecoder", new WebSocketFrameToByteBufDecoder());
pipeline.addLast("bytebuf2wsEncoder", new ByteBufToWebSocketFrameEncoder());
pipeline.addFirst("idleStateHandler", new IdleStateHandler(nettyChannelTimeoutSeconds, 0, 0));
pipeline.addAfter("idleStateHandler", "idleEventHandler", timeoutHandler);
pipeline.addFirst("bytemetrics", new BytesMetricsHandler(m_bytesMetricsCollector));
pipeline.addLast("decoder", new MqttDecoder());
pipeline.addLast("encoder", MqttEncoder.INSTANCE);
pipeline.addLast("metrics", new MessageMetricsHandler(m_metricsCollector));
pipeline.addLast("messageLogger", new MQTTMessageLogger());
pipeline.addLast("handler", handler);
}
});
}
开发者ID:andsel,项目名称:moquette,代码行数:36,代码来源:NettyAcceptor.java
示例7: initializeSSLTCPTransport
import io.moquette.server.config.IConfig; //导入依赖的package包/类
private void initializeSSLTCPTransport(final NettyMQTTHandler handler, IConfig props, final SSLContext sslContext)
throws IOException {
LOG.info("Configuring SSL MQTT transport");
String sslPortProp = props.getProperty(SSL_PORT_PROPERTY_NAME, DISABLED_PORT_BIND);
if (DISABLED_PORT_BIND.equals(sslPortProp)) {
// Do nothing no SSL configured
LOG.info("Property {} has been set to {}. SSL MQTT will be disabled",
BrokerConstants.SSL_PORT_PROPERTY_NAME, DISABLED_PORT_BIND);
return;
}
int sslPort = Integer.parseInt(sslPortProp);
LOG.info("Starting SSL on port {}", sslPort);
final MoquetteIdleTimeoutHandler timeoutHandler = new MoquetteIdleTimeoutHandler();
String host = props.getProperty(BrokerConstants.HOST_PROPERTY_NAME);
String sNeedsClientAuth = props.getProperty(BrokerConstants.NEED_CLIENT_AUTH, "false");
final boolean needsClientAuth = Boolean.valueOf(sNeedsClientAuth);
initFactory(host, sslPort, "SSL MQTT", new PipelineInitializer() {
@Override
void init(ChannelPipeline pipeline) throws Exception {
pipeline.addLast("ssl", createSslHandler(sslContext, needsClientAuth));
pipeline.addFirst("idleStateHandler", new IdleStateHandler(nettyChannelTimeoutSeconds, 0, 0));
pipeline.addAfter("idleStateHandler", "idleEventHandler", timeoutHandler);
// pipeline.addLast("logger", new LoggingHandler("Netty", LogLevel.ERROR));
pipeline.addFirst("bytemetrics", new BytesMetricsHandler(m_bytesMetricsCollector));
pipeline.addLast("decoder", new MqttDecoder());
pipeline.addLast("encoder", MqttEncoder.INSTANCE);
pipeline.addLast("metrics", new MessageMetricsHandler(m_metricsCollector));
pipeline.addLast("messageLogger", new MQTTMessageLogger());
pipeline.addLast("handler", handler);
}
});
}
开发者ID:andsel,项目名称:moquette,代码行数:36,代码来源:NettyAcceptor.java
示例8: initializeWSSTransport
import io.moquette.server.config.IConfig; //导入依赖的package包/类
private void initializeWSSTransport(final NettyMQTTHandler handler, IConfig props, final SSLContext sslContext)
throws IOException {
LOG.info("Configuring secure websocket MQTT transport");
String sslPortProp = props.getProperty(WSS_PORT_PROPERTY_NAME, DISABLED_PORT_BIND);
if (DISABLED_PORT_BIND.equals(sslPortProp)) {
// Do nothing no SSL configured
LOG.info("Property {} has been set to {}. Secure websocket MQTT will be disabled",
BrokerConstants.WSS_PORT_PROPERTY_NAME, DISABLED_PORT_BIND);
return;
}
int sslPort = Integer.parseInt(sslPortProp);
final MoquetteIdleTimeoutHandler timeoutHandler = new MoquetteIdleTimeoutHandler();
String host = props.getProperty(BrokerConstants.HOST_PROPERTY_NAME);
String sNeedsClientAuth = props.getProperty(BrokerConstants.NEED_CLIENT_AUTH, "false");
final boolean needsClientAuth = Boolean.valueOf(sNeedsClientAuth);
initFactory(host, sslPort, "Secure websocket", new PipelineInitializer() {
@Override
void init(ChannelPipeline pipeline) throws Exception {
pipeline.addLast("ssl", createSslHandler(sslContext, needsClientAuth));
pipeline.addLast("httpEncoder", new HttpResponseEncoder());
pipeline.addLast("httpDecoder", new HttpRequestDecoder());
pipeline.addLast("aggregator", new HttpObjectAggregator(65536));
pipeline.addLast("webSocketHandler",
new WebSocketServerProtocolHandler("/mqtt", MQTT_SUBPROTOCOL_CSV_LIST));
pipeline.addLast("ws2bytebufDecoder", new WebSocketFrameToByteBufDecoder());
pipeline.addLast("bytebuf2wsEncoder", new ByteBufToWebSocketFrameEncoder());
pipeline.addFirst("idleStateHandler", new IdleStateHandler(nettyChannelTimeoutSeconds, 0, 0));
pipeline.addAfter("idleStateHandler", "idleEventHandler", timeoutHandler);
pipeline.addFirst("bytemetrics", new BytesMetricsHandler(m_bytesMetricsCollector));
pipeline.addLast("decoder", new MqttDecoder());
pipeline.addLast("encoder", MqttEncoder.INSTANCE);
pipeline.addLast("metrics", new MessageMetricsHandler(m_metricsCollector));
pipeline.addLast("messageLogger", new MQTTMessageLogger());
pipeline.addLast("handler", handler);
}
});
}
开发者ID:andsel,项目名称:moquette,代码行数:39,代码来源:NettyAcceptor.java
示例9: setUp
import io.moquette.server.config.IConfig; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
scheduler = Executors.newScheduledThreadPool(1);
cleanPersistenceFile(BrokerConstants.DEFAULT_PERSISTENT_PATH);
Properties props = new Properties();
props.setProperty(BrokerConstants.PERSISTENT_STORE_PROPERTY_NAME, BrokerConstants.DEFAULT_PERSISTENT_PATH);
IConfig conf = new MemoryConfig(props);
m_storageService = new MapDBPersistentStore(conf, scheduler);
m_storageService.initStore();
messagesStore = m_storageService.messagesStore();
sessionsStore = m_storageService.sessionsStore();
this.sessionsRepository = new SessionsRepository(sessionsStore, null);
}
开发者ID:andsel,项目名称:moquette,代码行数:15,代码来源:MapDBPersistentStoreTest.java
示例10: setUp
import io.moquette.server.config.IConfig; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
scheduler = Executors.newScheduledThreadPool(1);
cleanPersistenceFile(BrokerConstants.DEFAULT_PERSISTENT_PATH);
Properties props = new Properties();
props.setProperty(BrokerConstants.PERSISTENT_STORE_PROPERTY_NAME, BrokerConstants.DEFAULT_PERSISTENT_PATH);
IConfig conf = new MemoryConfig(props);
storageService = new MapDBPersistentStore(conf, scheduler);
storageService.initStore();
}
开发者ID:andsel,项目名称:moquette,代码行数:12,代码来源:MapDBSessionsStoreTest.java
示例11: setUp
import io.moquette.server.config.IConfig; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
scheduler = Executors.newScheduledThreadPool(1);
cleanPersistenceFile(BrokerConstants.DEFAULT_PERSISTENT_PATH);
Properties props = new Properties();
props.setProperty(BrokerConstants.PERSISTENT_STORE_PROPERTY_NAME, BrokerConstants.DEFAULT_PERSISTENT_PATH);
IConfig conf = new MemoryConfig(props);
storageService = new H2PersistentStore(conf, scheduler);
storageService.initStore();
}
开发者ID:andsel,项目名称:moquette,代码行数:12,代码来源:H2SessionsStoreTest.java
示例12: setUp
import io.moquette.server.config.IConfig; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
scheduler = Executors.newScheduledThreadPool(1);
cleanPersistenceFile(BrokerConstants.DEFAULT_PERSISTENT_PATH);
Properties props = new Properties();
props.setProperty(BrokerConstants.PERSISTENT_STORE_PROPERTY_NAME, BrokerConstants.DEFAULT_PERSISTENT_PATH);
IConfig conf = new MemoryConfig(props);
storageService = new H2PersistentStore(conf, scheduler);
storageService.initStore();
messagesStore = storageService.messagesStore();
sessionsStore = storageService.sessionsStore();
this.sessionsRepository = new SessionsRepository(sessionsStore, null);
}
开发者ID:andsel,项目名称:moquette,代码行数:15,代码来源:H2MessagesStoreTest.java
示例13: MemoryStorageService
import io.moquette.server.config.IConfig; //导入依赖的package包/类
public MemoryStorageService(IConfig props, ScheduledExecutorService scheduler) {
m_messagesStore = new MemoryMessagesStore();
m_sessionsStore = new MemorySessionStore();
m_messagesStore.initStore();
m_sessionsStore.initStore();
}
开发者ID:andsel,项目名称:moquette,代码行数:7,代码来源:MemoryStorageService.java
示例14: DBAuthenticator
import io.moquette.server.config.IConfig; //导入依赖的package包/类
public DBAuthenticator(IConfig conf) {
this(conf.getProperty(BrokerConstants.DB_AUTHENTICATOR_DRIVER, ""),
conf.getProperty(BrokerConstants.DB_AUTHENTICATOR_URL, ""),
conf.getProperty(BrokerConstants.DB_AUTHENTICATOR_QUERY, ""),
conf.getProperty(BrokerConstants.DB_AUTHENTICATOR_DIGEST, ""));
}
开发者ID:andsel,项目名称:moquette,代码行数:7,代码来源:DBAuthenticator.java
示例15: BrokerInterceptor
import io.moquette.server.config.IConfig; //导入依赖的package包/类
/**
* Configures a broker interceptor using the pool size specified in the IConfig argument.
*/
BrokerInterceptor(IConfig props, List<InterceptHandler> handlers) {
this(Integer.parseInt(props.getProperty(BrokerConstants.BROKER_INTERCEPTOR_THREAD_POOL_SIZE, "1")), handlers);
}
开发者ID:andsel,项目名称:moquette,代码行数:7,代码来源:BrokerInterceptor.java
示例16: init
import io.moquette.server.config.IConfig; //导入依赖的package包/类
public void init(IConfig props) {
final String token = props.getProperty(BUGSNAG_TOKEN_PROPERTY_NAME);
this.bugsnag = new Bugsnag(token);
}
开发者ID:andsel,项目名称:moquette,代码行数:5,代码来源:BugSnagErrorsHandler.java
示例17: initialize
import io.moquette.server.config.IConfig; //导入依赖的package包/类
@Override
public void initialize(ProtocolProcessor processor, IConfig props, ISslContextCreator sslCtxCreator)
throws IOException {
LOG.info("Initializing Netty acceptor...");
nettySoBacklog = Integer.parseInt(props.getProperty(BrokerConstants.NETTY_SO_BACKLOG_PROPERTY_NAME, "128"));
nettySoReuseaddr = Boolean
.parseBoolean(props.getProperty(BrokerConstants.NETTY_SO_REUSEADDR_PROPERTY_NAME, "true"));
nettyTcpNodelay = Boolean
.parseBoolean(props.getProperty(BrokerConstants.NETTY_TCP_NODELAY_PROPERTY_NAME, "true"));
nettySoKeepalive = Boolean
.parseBoolean(props.getProperty(BrokerConstants.NETTY_SO_KEEPALIVE_PROPERTY_NAME, "true"));
nettyChannelTimeoutSeconds = Integer
.parseInt(props.getProperty(BrokerConstants.NETTY_CHANNEL_TIMEOUT_SECONDS_PROPERTY_NAME, "10"));
boolean epoll = Boolean.parseBoolean(props.getProperty(BrokerConstants.NETTY_EPOLL_PROPERTY_NAME, "false"));
if (epoll) {
LOG.info("Netty is using Epoll");
m_bossGroup = new EpollEventLoopGroup();
m_workerGroup = new EpollEventLoopGroup();
channelClass = EpollServerSocketChannel.class;
} else {
LOG.info("Netty is using NIO");
m_bossGroup = new NioEventLoopGroup();
m_workerGroup = new NioEventLoopGroup();
channelClass = NioServerSocketChannel.class;
}
final NettyMQTTHandler mqttHandler = new NettyMQTTHandler(processor);
final boolean useFineMetrics = Boolean.parseBoolean(props.getProperty(METRICS_ENABLE_PROPERTY_NAME, "false"));
if (useFineMetrics) {
DropWizardMetricsHandler metricsHandler = new DropWizardMetricsHandler();
metricsHandler.init(props);
this.metrics = Optional.of(metricsHandler);
} else {
this.metrics = Optional.empty();
}
final boolean useBugSnag = Boolean.parseBoolean(props.getProperty(BUGSNAG_ENABLE_PROPERTY_NAME, "false"));
if (useBugSnag) {
BugSnagErrorsHandler bugSnagHandler = new BugSnagErrorsHandler();
bugSnagHandler.init(props);
this.errorsCather = Optional.of(bugSnagHandler);
} else {
this.errorsCather = Optional.empty();
}
initializePlainTCPTransport(mqttHandler, props);
initializeWebSocketTransport(mqttHandler, props);
String sslTcpPortProp = props.getProperty(BrokerConstants.SSL_PORT_PROPERTY_NAME);
String wssPortProp = props.getProperty(BrokerConstants.WSS_PORT_PROPERTY_NAME);
if (sslTcpPortProp != null || wssPortProp != null) {
SSLContext sslContext = sslCtxCreator.initSSLContext();
if (sslContext == null) {
LOG.error("Can't initialize SSLHandler layer! Exiting, check your configuration of jks");
return;
}
initializeSSLTCPTransport(mqttHandler, props, sslContext);
initializeWSSTransport(mqttHandler, props, sslContext);
}
}
开发者ID:andsel,项目名称:moquette,代码行数:62,代码来源:NettyAcceptor.java
示例18: DefaultMoquetteSslContextCreator
import io.moquette.server.config.IConfig; //导入依赖的package包/类
DefaultMoquetteSslContextCreator(IConfig props) {
this.props = props;
}
开发者ID:andsel,项目名称:moquette,代码行数:4,代码来源:DefaultMoquetteSslContextCreator.java
示例19: startServer
import io.moquette.server.config.IConfig; //导入依赖的package包/类
protected Server startServer(int port, IConfig m_config) throws IOException {
Server m_server = new Server();
m_config.setProperty(PORT_PROPERTY_NAME, Integer.toString(port));
m_server.startServer(m_config);
return m_server;
}
开发者ID:andsel,项目名称:moquette,代码行数:7,代码来源:ServerIntegrationHazelcastHandlerInterceptorTest.java
示例20: MapDBPersistentStore
import io.moquette.server.config.IConfig; //导入依赖的package包/类
public MapDBPersistentStore(IConfig props, ScheduledExecutorService scheduler) {
this.m_storePath = props.getProperty(BrokerConstants.PERSISTENT_STORE_PROPERTY_NAME, "");
this.m_autosaveInterval = Integer
.parseInt(props.getProperty(BrokerConstants.AUTOSAVE_INTERVAL_PROPERTY_NAME, "30"));
this.m_scheduler = scheduler;
}
开发者ID:andsel,项目名称:moquette,代码行数:7,代码来源:MapDBPersistentStore.java
注:本文中的io.moquette.server.config.IConfig类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论