Class ElideDuplicateHeadersHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.channel.ChannelDuplexHandler
-
- com.linkedin.alpini.netty4.handlers.ElideDuplicateHeadersHandler
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
,io.netty.channel.ChannelOutboundHandler
@Sharable public class ElideDuplicateHeadersHandler extends io.netty.channel.ChannelDuplexHandler
A simple cache to reduce the number of duplicate CharSequences held by the HttpHeaders instances. The reason is that the HttpObjectDecoder will instantiate a new String for every part of the header that it encountered we want to facilitate the garbage collector in reaping short life objects. The implementation uses a queue of maps per thread instead of maintaining a LRU structure where initially two maps are added to the queue and at each expire interval, a new empty map is added at the start and an old map is removed from the end. This effectively makes the lifetime of every map to be 2x the expire interval and entries referenced would be inserted into only the map at the head of the queue.
-
-
Field Summary
Fields Modifier and Type Field Description static io.netty.channel.ChannelDuplexHandler
INSTANCE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
channelRead(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object msg)
void
write(io.netty.channel.ChannelHandlerContext ctx, java.lang.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
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
-
-
-
-
Method Detail
-
write
public void write(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object msg, io.netty.channel.ChannelPromise promise) throws java.lang.Exception
- Specified by:
write
in interfaceio.netty.channel.ChannelOutboundHandler
- Overrides:
write
in classio.netty.channel.ChannelDuplexHandler
- Throws:
java.lang.Exception
-
channelRead
public void channelRead(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object msg) throws java.lang.Exception
- Specified by:
channelRead
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelRead
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
java.lang.Exception
-
-