Class AnalyticsHandlerV2
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
io.netty.handler.codec.MessageToMessageCodec<RESPONSE,REQUEST>
com.couchbase.client.core.endpoint.AbstractGenericHandler<HttpObject,HttpRequest,AnalyticsRequest>
com.couchbase.client.core.endpoint.analytics.AnalyticsHandlerV2
- All Implemented Interfaces:
ChannelHandler
,ChannelInboundHandler
,ChannelOutboundHandler
public class AnalyticsHandlerV2 extends AbstractGenericHandler<HttpObject,HttpRequest,AnalyticsRequest>
The
AnalyticsHandlerV2
is responsible for encoding AnalyticsRequest
s into lower level
HttpRequest
s as well as decoding HttpObject
s into
CouchbaseResponse
s. The query response parser uses YasjlAnalyticsResponseParser
- Author:
- Subhashni Balakrishnan
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AnalyticsHandlerV2.KeepAliveRequest
protected static class
AnalyticsHandlerV2.KeepAliveResponse
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
Field Summary
Fields inherited from class com.couchbase.client.core.endpoint.AbstractGenericHandler
CHARSET, EMPTY_BYTES
-
Constructor Summary
Constructors Constructor Description AnalyticsHandlerV2(AbstractEndpoint endpoint, com.lmax.disruptor.RingBuffer<ResponseEvent> responseBuffer, boolean isTransient, boolean pipeline)
Creates a newAnalyticsHandlerV2
with the default queue for requests. -
Method Summary
Modifier and Type Method Description protected CouchbaseRequest
createKeepAliveRequest()
Override to return a non-null request to be fired in the pipeline in case a keep alive is triggered.protected CouchbaseResponse
decodeResponse(ChannelHandlerContext ctx, HttpObject msg)
Decodes the incoming response and transforms it into aCouchbaseResponse
.protected HttpRequest
encodeRequest(ChannelHandlerContext ctx, AnalyticsRequest msg)
Encode the outgoing request and return it in encoded format.protected void
finishedDecoding()
Notify that decoding is finished.ByteBuf
getResponseContent()
void
handlerRemoved(ChannelHandlerContext ctx)
protected ServiceType
serviceType()
Returns theServiceType
associated with this handler.Methods inherited from class com.couchbase.client.core.endpoint.AbstractGenericHandler
addHttpBasicAuth, channelActive, channelInactive, channelWritabilityChanged, completeRequestSpan, connect, currentDispatchSpan, currentRequest, decode, encode, endpoint, env, exceptionCaught, getDecodingState, logIdent, onKeepAliveFired, onKeepAliveResponse, publishResponse, remoteHostname, remoteHttpHost, shouldSendKeepAlive, sideEffectRequestToCancel, userEventTriggered, write
Methods inherited from class io.netty.handler.codec.MessageToMessageCodec
acceptInboundMessage, acceptOutboundMessage, channelRead
Methods inherited from class io.netty.channel.ChannelDuplexHandler
bind, close, deregister, disconnect, flush, read
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelReadComplete, channelRegistered, channelUnregistered
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, isSharable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.netty.channel.ChannelHandler
handlerAdded
-
Constructor Details
-
AnalyticsHandlerV2
public AnalyticsHandlerV2(AbstractEndpoint endpoint, com.lmax.disruptor.RingBuffer<ResponseEvent> responseBuffer, boolean isTransient, boolean pipeline)Creates a newAnalyticsHandlerV2
with the default queue for requests.- Parameters:
endpoint
- theAbstractEndpoint
to coordinate with.responseBuffer
- theRingBuffer
to push responses into.
-
-
Method Details
-
encodeRequest
protected HttpRequest encodeRequest(ChannelHandlerContext ctx, AnalyticsRequest msg) throws ExceptionDescription copied from class:AbstractGenericHandler
Encode the outgoing request and return it in encoded format. This method needs to be implemented by the child handler and is responsible for the actual conversion.- Specified by:
encodeRequest
in classAbstractGenericHandler<HttpObject,HttpRequest,AnalyticsRequest>
- Parameters:
ctx
- the context passed in.msg
- the outgoing message.- Returns:
- the encoded request.
- Throws:
Exception
- as a generic error.
-
decodeResponse
protected CouchbaseResponse decodeResponse(ChannelHandlerContext ctx, HttpObject msg) throws ExceptionDescription copied from class:AbstractGenericHandler
Decodes the incoming response and transforms it into aCouchbaseResponse
. Note that the actual notification is handled by this generic handler, the implementing class only is concerned about the conversion itself.- Specified by:
decodeResponse
in classAbstractGenericHandler<HttpObject,HttpRequest,AnalyticsRequest>
- Parameters:
ctx
- the context passed in.msg
- the incoming message.- Returns:
- a response or null if nothing should be returned.
- Throws:
Exception
- as a generic error. It will be bubbled up to the user (wrapped in a CouchbaseException) in the onError of the request's Observable.
-
finishedDecoding
protected void finishedDecoding()Description copied from class:AbstractGenericHandler
Notify that decoding is finished. This needs to be called by the child handlers in order to signal that operations are done.- Overrides:
finishedDecoding
in classAbstractGenericHandler<HttpObject,HttpRequest,AnalyticsRequest>
-
handlerRemoved
- Specified by:
handlerRemoved
in interfaceChannelHandler
- Overrides:
handlerRemoved
in classAbstractGenericHandler<HttpObject,HttpRequest,AnalyticsRequest>
- Throws:
Exception
-
createKeepAliveRequest
Description copied from class:AbstractGenericHandler
Override to return a non-null request to be fired in the pipeline in case a keep alive is triggered.- Overrides:
createKeepAliveRequest
in classAbstractGenericHandler<HttpObject,HttpRequest,AnalyticsRequest>
- Returns:
- a CouchbaseRequest to be fired in case of keep alive (null by default).
-
serviceType
Description copied from class:AbstractGenericHandler
Returns theServiceType
associated with this handler.- Specified by:
serviceType
in classAbstractGenericHandler<HttpObject,HttpRequest,AnalyticsRequest>
- Returns:
- the service type.
-
getResponseContent
-