Package org.drasyl.handler.logging
Class MessagesThroughputHandler
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
org.drasyl.handler.logging.MessagesThroughputHandler
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
,io.netty.channel.ChannelOutboundHandler
public class MessagesThroughputHandler
extends io.netty.channel.ChannelDuplexHandler
Helper class to visualize the number of inbound and outbound messages per second. Can be added to
any position in a
ChannelPipeline
.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new handler which visualizes the number of inbound and outbound messages per second.MessagesThroughputHandler
(BiPredicate<SocketAddress, Object> consumeOutbound, BiPredicate<SocketAddress, Object> consumeInbound) Creates a new handler which visualizes the number of inbound and outbound messages per second, consumes outbound message matchingconsumeOutbound
, and inbound messages matchingconsumeInbound
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
channelActive
(io.netty.channel.ChannelHandlerContext ctx) void
channelInactive
(io.netty.channel.ChannelHandlerContext ctx) void
channelRead
(io.netty.channel.ChannelHandlerContext ctx, Object msg) void
write
(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) Methods inherited from class io.netty.channel.ChannelDuplexHandler
bind, close, connect, deregister, disconnect, flush, read
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Field Details
-
INTERVAL
-
-
Constructor Details
-
MessagesThroughputHandler
public MessagesThroughputHandler(BiPredicate<SocketAddress, Object> consumeOutbound, BiPredicate<SocketAddress, Object> consumeInbound) Creates a new handler which visualizes the number of inbound and outbound messages per second, consumes outbound message matchingconsumeOutbound
, and inbound messages matchingconsumeInbound
.- Parameters:
consumeOutbound
- predicate that consumes outbound messages on matchconsumeInbound
- predicate that consumes inbound messages on match
-
MessagesThroughputHandler
public MessagesThroughputHandler()Creates a new handler which visualizes the number of inbound and outbound messages per second.
-
-
Method Details
-
write
public void write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) - Specified by:
write
in interfaceio.netty.channel.ChannelOutboundHandler
- Overrides:
write
in classio.netty.channel.ChannelDuplexHandler
-
channelRead
- Specified by:
channelRead
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelRead
in classio.netty.channel.ChannelInboundHandlerAdapter
-
channelActive
public void channelActive(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
channelActive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelActive
in classio.netty.channel.ChannelInboundHandlerAdapter
-
channelInactive
public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
channelInactive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelInactive
in classio.netty.channel.ChannelInboundHandlerAdapter
-