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 TypeMethodDescriptionvoidchannelActive(io.netty.channel.ChannelHandlerContext ctx) voidchannelInactive(io.netty.channel.ChannelHandlerContext ctx) voidchannelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg) voidwrite(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, readMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
writein interfaceio.netty.channel.ChannelOutboundHandler- Overrides:
writein classio.netty.channel.ChannelDuplexHandler
-
channelRead
- Specified by:
channelReadin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelReadin classio.netty.channel.ChannelInboundHandlerAdapter
-
channelActive
public void channelActive(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
channelActivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classio.netty.channel.ChannelInboundHandlerAdapter
-
channelInactive
public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classio.netty.channel.ChannelInboundHandlerAdapter
-