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.ChannelDuplexHandler
Parent 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
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.couchbase.client.core.deps.io.netty.channel.ChannelHandler
com.couchbase.client.core.deps.io.netty.channel.ChannelHandler.Sharable
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
ChunkedHandlerSwitcher
(com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler chunkedHandler, NonChunkedHttpMessageHandler nonChunkedHandler, Class<? extends Request> chunkedClass) Creates a new chunked handler switcher. -
Method Summary
Modifier and TypeMethodDescriptionvoid
channelActive
(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).void
write
(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
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.couchbase.client.core.deps.io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Field Details
-
SWITCHER_IDENTIFIER
-
-
Constructor Details
-
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 Details
-
channelActive
public void channelActive(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx) throws Exception 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).- Specified by:
channelActive
in interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler
- Overrides:
channelActive
in 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 Exception When a request comes along, this code decides if and how to switch out the handlers.- Specified by:
write
in interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelOutboundHandler
- Overrides:
write
in 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
-