Commit 005c886cc59d6f7a6fd7862459bc1942eb1df628
Committed by
GitHub
Merge pull request #36 from thingsboard/feature/TB-34
TB-34: Implementation
Showing
2 changed files
with
17 additions
and
3 deletions
... | ... | @@ -75,6 +75,10 @@ mqtt: |
75 | 75 | bind_port: "${MQTT_BIND_PORT:1883}" |
76 | 76 | adaptor: "${MQTT_ADAPTOR_NAME:JsonMqttAdaptor}" |
77 | 77 | timeout: "${MQTT_TIMEOUT:10000}" |
78 | + netty: | |
79 | + leak_detector_level: "${NETTY_LEASK_DETECTOR_LVL:DISABLED}" | |
80 | + boss_group_thread_count: "${NETTY_BOSS_GROUP_THREADS:1}" | |
81 | + worker_group_thread_count: "${NETTY_WORKER_GROUP_THREADS:12}" | |
78 | 82 | # Uncomment the following lines to enable ssl for MQTT |
79 | 83 | ssl: |
80 | 84 | key_store: keystore/mqttserver.jks | ... | ... |
... | ... | @@ -68,6 +68,14 @@ public class MqttTransportService { |
68 | 68 | @Value("${mqtt.adaptor}") |
69 | 69 | private String adaptorName; |
70 | 70 | |
71 | + @Value("${mqtt.netty.leak_detector_level}") | |
72 | + private String leakDetectorLevel; | |
73 | + @Value("${mqtt.netty.boss_group_thread_count}") | |
74 | + private Integer bossGroupThreadCount; | |
75 | + @Value("${mqtt.netty.worker_group_thread_count}") | |
76 | + private Integer workerGroupThreadCount; | |
77 | + | |
78 | + | |
71 | 79 | private MqttTransportAdaptor adaptor; |
72 | 80 | |
73 | 81 | private Channel serverChannel; |
... | ... | @@ -76,17 +84,19 @@ public class MqttTransportService { |
76 | 84 | |
77 | 85 | @PostConstruct |
78 | 86 | public void init() throws Exception { |
87 | + log.info("Setting resource leak detector level to {}", leakDetectorLevel); | |
88 | + ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.valueOf(leakDetectorLevel.toUpperCase())); | |
89 | + | |
79 | 90 | log.info("Starting MQTT transport..."); |
80 | 91 | log.info("Lookup MQTT transport adaptor {}", adaptorName); |
81 | 92 | this.adaptor = (MqttTransportAdaptor) appContext.getBean(adaptorName); |
82 | 93 | |
83 | 94 | log.info("Starting MQTT transport server"); |
84 | - bossGroup = new NioEventLoopGroup(1); | |
85 | - workerGroup = new NioEventLoopGroup(); | |
95 | + bossGroup = new NioEventLoopGroup(bossGroupThreadCount); | |
96 | + workerGroup = new NioEventLoopGroup(workerGroupThreadCount); | |
86 | 97 | ServerBootstrap b = new ServerBootstrap(); |
87 | 98 | b.group(bossGroup, workerGroup) |
88 | 99 | .channel(NioServerSocketChannel.class) |
89 | - .handler(new LoggingHandler(LogLevel.TRACE)) | |
90 | 100 | .childHandler(new MqttTransportServerInitializer(processor, authService, adaptor, sslHandlerProvider)); |
91 | 101 | |
92 | 102 | serverChannel = b.bind(host, port).sync().channel(); | ... | ... |