Added shutdown sequence of the disruptor used in the output part (from ProtocolProcessor down to the cable)
This commit is contained in:
@@ -4,6 +4,7 @@ Version 0.8:
|
|||||||
Fixed bug, does not check for zero length topic (filters) in PUBLISH, SUBSCRIBE, and UNSUBSCRIBE, issue #67
|
Fixed bug, does not check for zero length topic (filters) in PUBLISH, SUBSCRIBE, and UNSUBSCRIBE, issue #67
|
||||||
Fixed issue #69
|
Fixed issue #69
|
||||||
Fixed bug #68, UNSUBSCRIBE has to fail on bad topicFilter names
|
Fixed bug #68, UNSUBSCRIBE has to fail on bad topicFilter names
|
||||||
|
Fixed bug #81, on stop of moquette broker it doesn't shutdown due to no shutdown of ringbuffer used on the back of ProtocolProcessor
|
||||||
|
|
||||||
Version 0.7:
|
Version 0.7:
|
||||||
Fix issue #38, added aligned to MQTT 3.1.1
|
Fix issue #38, added aligned to MQTT 3.1.1
|
||||||
|
|||||||
@@ -103,8 +103,8 @@ public class Server {
|
|||||||
|
|
||||||
public void stopServer() {
|
public void stopServer() {
|
||||||
LOG.info("Server stopping...");
|
LOG.info("Server stopping...");
|
||||||
messaging.stop();
|
|
||||||
m_acceptor.close();
|
m_acceptor.close();
|
||||||
|
messaging.stop();
|
||||||
LOG.info("Server stopped");
|
LOG.info("Server stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ import java.util.Properties;
|
|||||||
import javax.net.ssl.KeyManagerFactory;
|
import javax.net.ssl.KeyManagerFactory;
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.SSLEngine;
|
import javax.net.ssl.SSLEngine;
|
||||||
|
|
||||||
|
import io.netty.util.concurrent.EventExecutor;
|
||||||
|
import io.netty.util.concurrent.Future;
|
||||||
import org.eclipse.moquette.commons.Constants;
|
import org.eclipse.moquette.commons.Constants;
|
||||||
import org.eclipse.moquette.spi.IMessaging;
|
import org.eclipse.moquette.spi.IMessaging;
|
||||||
import org.eclipse.moquette.parser.netty.MQTTDecoder;
|
import org.eclipse.moquette.parser.netty.MQTTDecoder;
|
||||||
@@ -270,8 +273,20 @@ public class NettyAcceptor implements ServerAcceptor {
|
|||||||
if (m_bossGroup == null) {
|
if (m_bossGroup == null) {
|
||||||
throw new IllegalStateException("Invoked close on an Acceptor that wasn't initialized");
|
throw new IllegalStateException("Invoked close on an Acceptor that wasn't initialized");
|
||||||
}
|
}
|
||||||
m_workerGroup.shutdownGracefully();
|
Future workerWaiter = m_workerGroup.shutdownGracefully();
|
||||||
m_bossGroup.shutdownGracefully();
|
Future bossWaiter = m_bossGroup.shutdownGracefully();
|
||||||
|
|
||||||
|
try {
|
||||||
|
workerWaiter.await(100);
|
||||||
|
} catch (InterruptedException iex) {
|
||||||
|
throw new IllegalStateException(iex);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
bossWaiter.await(100);
|
||||||
|
} catch (InterruptedException iex) {
|
||||||
|
throw new IllegalStateException(iex);
|
||||||
|
}
|
||||||
|
|
||||||
MessageMetrics metrics = m_metricsCollector.computeMetrics();
|
MessageMetrics metrics = m_metricsCollector.computeMetrics();
|
||||||
LOG.info("Msg read: {}, msg wrote: {}", metrics.messagesRead(), metrics.messagesWrote());
|
LOG.info("Msg read: {}, msg wrote: {}", metrics.messagesRead(), metrics.messagesWrote());
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import com.lmax.disruptor.EventHandler;
|
|||||||
import com.lmax.disruptor.RingBuffer;
|
import com.lmax.disruptor.RingBuffer;
|
||||||
import com.lmax.disruptor.dsl.Disruptor;
|
import com.lmax.disruptor.dsl.Disruptor;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
@@ -111,6 +110,7 @@ class ProtocolProcessor implements EventHandler<ValueEvent> {
|
|||||||
|
|
||||||
private ExecutorService m_executor;
|
private ExecutorService m_executor;
|
||||||
private RingBuffer<ValueEvent> m_ringBuffer;
|
private RingBuffer<ValueEvent> m_ringBuffer;
|
||||||
|
private Disruptor<ValueEvent> m_disruptor;
|
||||||
|
|
||||||
ProtocolProcessor() {}
|
ProtocolProcessor() {}
|
||||||
|
|
||||||
@@ -142,12 +142,17 @@ class ProtocolProcessor implements EventHandler<ValueEvent> {
|
|||||||
//init the output ringbuffer
|
//init the output ringbuffer
|
||||||
m_executor = Executors.newFixedThreadPool(1);
|
m_executor = Executors.newFixedThreadPool(1);
|
||||||
|
|
||||||
Disruptor<ValueEvent> disruptor = new Disruptor<>(ValueEvent.EVENT_FACTORY, 1024 * 32, m_executor);
|
/*Disruptor<ValueEvent>*/ m_disruptor = new Disruptor<>(ValueEvent.EVENT_FACTORY, 1024 * 32, m_executor);
|
||||||
disruptor.handleEventsWith(this);
|
m_disruptor.handleEventsWith(this);
|
||||||
disruptor.start();
|
m_disruptor.start();
|
||||||
|
|
||||||
// Get the ring buffer from the Disruptor to be used for publishing.
|
// Get the ring buffer from the Disruptor to be used for publishing.
|
||||||
m_ringBuffer = disruptor.getRingBuffer();
|
m_ringBuffer = m_disruptor.getRingBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
void stop() {
|
||||||
|
m_executor.shutdown();
|
||||||
|
m_disruptor.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@MQTTMessage(message = ConnectMessage.class)
|
@MQTTMessage(message = ConnectMessage.class)
|
||||||
|
|||||||
@@ -297,13 +297,14 @@ public class SimpleMessaging implements IMessaging, EventHandler<ValueEvent> {
|
|||||||
|
|
||||||
private void processStop() {
|
private void processStop() {
|
||||||
LOG.debug("processStop invoked");
|
LOG.debug("processStop invoked");
|
||||||
|
m_processor.stop();
|
||||||
|
|
||||||
if (m_interceptor != null) {
|
if (m_interceptor != null) {
|
||||||
this.m_interceptor.stop();
|
this.m_interceptor.stop();
|
||||||
|
LOG.debug("interceptor firer stopped");
|
||||||
}
|
}
|
||||||
m_storageService.close();
|
m_storageService.close();
|
||||||
LOG.debug("subscription tree {}", subscriptions.dumpTree());
|
LOG.debug("subscription tree {}", subscriptions.dumpTree());
|
||||||
// m_eventProcessor.halt();
|
|
||||||
// m_executor.shutdown();
|
|
||||||
|
|
||||||
subscriptions = null;
|
subscriptions = null;
|
||||||
m_stopLatch.countDown();
|
m_stopLatch.countDown();
|
||||||
|
|||||||
Reference in New Issue
Block a user