Class HttpServerStatisticsHandler
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
com.linkedin.alpini.netty4.handlers.ChannelInitializer<C>
com.linkedin.alpini.netty4.handlers.SimpleChannelInitializer<io.netty.channel.Channel>
com.linkedin.alpini.netty4.handlers.HttpServerStatisticsHandler
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
@Sharable
public abstract class HttpServerStatisticsHandler
extends SimpleChannelInitializer<io.netty.channel.Channel>
An abstract handler which may be used to examine latencies in the Netty4 HTTP request processing.
It is intended to be placed immediately after HttpServerCodec
or
BasicHttpServerCodec
handlers. When the BasicHttpServerCodec is used, the request
start time is the time when the first line of the request containing the URI was received.
Extend this class, overriding the complete(Stats)
method to process
the HttpServerStatisticsHandler.Stats
objects. The instance is sharable.
final HttpServerStatisticsHandler _stats = new HttpServerStatisticsHandler() { &at;Override protected void complete(Stats stats) { ... } }; final ChannelHandler _initialization = new ChannelInitializer<Channel>() { &at;Override protected void initChannel(Channel ch) { ChannelPipeline p = ch.pipeline(); ... p.addLast("http-server-codec", new HttpServerCodec()); p.addLast("http-server-stats", _stats); ... } }Created by acurtis on 5/1/18.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
This method is invoked for every completeHttpServerStatisticsHandler.Stats
object.protected void
initChannel
(io.netty.channel.Channel ch) This method will be called once theChannel
was registered.Methods inherited from class com.linkedin.alpini.netty4.handlers.SimpleChannelInitializer
addAfter, addAfter, addAfter, addAfter, addAfter, addAfter, addAfter
Methods inherited from class com.linkedin.alpini.netty4.handlers.ChannelInitializer
channelRegistered, currentContext, exceptionCaught, handlerAdded, handlerRemoved
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelRead, channelReadComplete, channelUnregistered, channelWritabilityChanged, userEventTriggered
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharable
-
Constructor Details
-
HttpServerStatisticsHandler
public HttpServerStatisticsHandler()
-
-
Method Details
-
initChannel
Description copied from class:ChannelInitializer
This method will be called once theChannel
was registered. After the method returns this instance will be removed from theChannelPipeline
of theChannel
.- Specified by:
initChannel
in classChannelInitializer<io.netty.channel.Channel>
- Parameters:
ch
- theChannel
which was registered.- Throws:
Exception
- is thrown if an error occurs. In that case it will be handled byChannelInitializer.exceptionCaught(ChannelHandlerContext, Throwable)
which will by default close theChannel
.
-
complete
This method is invoked for every completeHttpServerStatisticsHandler.Stats
object.- Parameters:
stats
- statistics
-