Add debug log traces to AutoFlushHandler
This commit is contained in:
@@ -19,6 +19,9 @@ import io.netty.channel.ChannelDuplexHandler;
|
|||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.util.concurrent.EventExecutor;
|
import io.netty.util.concurrent.EventExecutor;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@@ -30,6 +33,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*/
|
*/
|
||||||
public class AutoFlushHandler extends ChannelDuplexHandler {
|
public class AutoFlushHandler extends ChannelDuplexHandler {
|
||||||
|
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(AutoFlushHandler.class);
|
||||||
private static final long MIN_TIMEOUT_NANOS = TimeUnit.MILLISECONDS.toNanos(1);
|
private static final long MIN_TIMEOUT_NANOS = TimeUnit.MILLISECONDS.toNanos(1);
|
||||||
|
|
||||||
private final long writerIdleTimeNanos;
|
private final long writerIdleTimeNanos;
|
||||||
@@ -108,6 +112,9 @@ public class AutoFlushHandler extends ChannelDuplexHandler {
|
|||||||
private void initialize(ChannelHandlerContext ctx) {
|
private void initialize(ChannelHandlerContext ctx) {
|
||||||
// Avoid the case where destroy() is called before scheduling timeouts.
|
// Avoid the case where destroy() is called before scheduling timeouts.
|
||||||
// See: https://github.com/netty/netty/issues/143
|
// See: https://github.com/netty/netty/issues/143
|
||||||
|
if (LOG.isDebugEnabled()) {
|
||||||
|
LOG.debug("Initializing autoflush handler. MqttClientId = {}.", NettyUtils.clientID(ctx.channel()));
|
||||||
|
}
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
@@ -141,6 +148,9 @@ public class AutoFlushHandler extends ChannelDuplexHandler {
|
|||||||
*/
|
*/
|
||||||
protected void channelIdle(ChannelHandlerContext ctx/*, IdleStateEvent evt*/) throws Exception {
|
protected void channelIdle(ChannelHandlerContext ctx/*, IdleStateEvent evt*/) throws Exception {
|
||||||
// ctx.fireUserEventTriggered(evt);
|
// ctx.fireUserEventTriggered(evt);
|
||||||
|
if (LOG.isDebugEnabled()) {
|
||||||
|
LOG.debug("Flushing idle Netty channel. MqttClientId = {}.", NettyUtils.clientID(ctx.channel()));
|
||||||
|
}
|
||||||
ctx.channel().flush();
|
ctx.channel().flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user