public class ChunkedHandlerSwitcher
extends com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler
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.
Modifier and Type | Field and Description |
---|---|
static String |
SWITCHER_IDENTIFIER |
Modifier | Constructor and Description |
---|---|
protected |
ChunkedHandlerSwitcher(com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler chunkedHandler,
NonChunkedHttpMessageHandler nonChunkedHandler,
Class<? extends Request> chunkedClass)
Creates a new chunked handler switcher.
|
Modifier and Type | Method and Description |
---|---|
void |
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.
|
bind, close, connect, deregister, disconnect, flush, read
channelInactive, channelRead, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
public static final String SWITCHER_IDENTIFIER
protected ChunkedHandlerSwitcher(com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler chunkedHandler, NonChunkedHttpMessageHandler nonChunkedHandler, Class<? extends Request> chunkedClass)
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.public void channelActive(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx) throws Exception
channelActive
in interface com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler
channelActive
in class com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter
Exception
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
write
in interface com.couchbase.client.core.deps.io.netty.channel.ChannelOutboundHandler
write
in class com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler
ctx
- the channel handler context.msg
- the incoming message type that should be written.promise
- the channel promise, will just be passed through.Exception
Copyright © 2024 Couchbase, Inc.. All rights reserved.