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 orBasicHttpServerCodec
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 thecomplete(Stats)
method to process theHttpServerStatisticsHandler.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 Modifier and Type Class Description static class
HttpServerStatisticsHandler.Stats
-
Constructor Summary
Constructors Constructor Description HttpServerStatisticsHandler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
complete(HttpServerStatisticsHandler.Stats stats)
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
-
-
-
-
Method Detail
-
initChannel
protected void initChannel(io.netty.channel.Channel ch) throws java.lang.Exception
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:
java.lang.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
protected abstract void complete(HttpServerStatisticsHandler.Stats stats)
This method is invoked for every completeHttpServerStatisticsHandler.Stats
object.- Parameters:
stats
- statistics
-
-