Class ChunkedHandlerSwitcher
- java.lang.Object
-
- com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerAdapter
-
- com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter
-
- com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler
-
- com.couchbase.client.core.io.netty.ChunkedHandlerSwitcher
-
- All Implemented Interfaces:
com.couchbase.client.core.deps.io.netty.channel.ChannelHandler,com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler,com.couchbase.client.core.deps.io.netty.channel.ChannelOutboundHandler
- Direct Known Subclasses:
AnalyticsHandlerSwitcher,ManagerHandlerSwitcher,QueryHandlerSwitcher,SearchHandlerSwitcher,ViewHandlerSwitcher
public class ChunkedHandlerSwitcher extends com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandlerParent class for all pipelines which need to switch between a chunked and a non-chunked handler structure.The basic idea is that this handler is added to the pipeline always in the endpoint and it will decide based on the chunkedClass on construction when to add the chunked handler and when to add the non-chunked counterpart. Note that it will only change the handler structure if the "wrong" one is already in place.
This switcher will also always put in the chunked one by default since this is the most likely and perf critical variant of the two.
- Since:
- 2.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static StringSWITCHER_IDENTIFIER
-
Constructor Summary
Constructors Modifier Constructor Description protectedChunkedHandlerSwitcher(com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler chunkedHandler, NonChunkedHttpMessageHandler nonChunkedHandler, Class<? extends Request> chunkedClass)Creates a new chunked handler switcher.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchannelActive(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx)When the channel becomes active, make sure that the chunked handler is added since that is the most likely needed one upfront (and the most perf critical one).voidwrite(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx, Object msg, com.couchbase.client.core.deps.io.netty.channel.ChannelPromise promise)When a request comes along, this code decides if and how to switch out the handlers.-
Methods inherited from class com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler
bind, close, connect, deregister, disconnect, flush, read
-
Methods inherited from class com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter
channelInactive, channelRead, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
-
Methods inherited from class com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
-
-
-
-
Field Detail
-
SWITCHER_IDENTIFIER
public static final String SWITCHER_IDENTIFIER
-
-
Constructor Detail
-
ChunkedHandlerSwitcher
protected ChunkedHandlerSwitcher(com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler chunkedHandler, NonChunkedHttpMessageHandler nonChunkedHandler, Class<? extends Request> chunkedClass)Creates a new chunked handler switcher.- Parameters:
chunkedHandler- the handler which does the chunking.nonChunkedHandler- the handler which handles all the other msgs.chunkedClass- the class of request representing the chunked request.
-
-
Method Detail
-
channelActive
public void channelActive(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx) throws ExceptionWhen the channel becomes active, make sure that the chunked handler is added since that is the most likely needed one upfront (and the most perf critical one).- Specified by:
channelActivein interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classcom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
write
public void write(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx, Object msg, com.couchbase.client.core.deps.io.netty.channel.ChannelPromise promise) throws ExceptionWhen a request comes along, this code decides if and how to switch out the handlers.- Specified by:
writein interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelOutboundHandler- Overrides:
writein classcom.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler- Parameters:
ctx- the channel handler context.msg- the incoming message type that should be written.promise- the channel promise, will just be passed through.- Throws:
Exception
-
-