Class QueryHandler
- 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,QueryRequest>
-
- com.couchbase.client.core.endpoint.query.QueryHandler
-
- All Implemented Interfaces:
ChannelHandler
,ChannelInboundHandler
,ChannelOutboundHandler
public class QueryHandler extends AbstractGenericHandler<HttpObject,HttpRequest,QueryRequest>
TheQueryHandler
is responsible for encodingQueryRequest
s into lower levelHttpRequest
s as well as decodingHttpObject
s intoCouchbaseResponse
s.- Since:
- 1.0
- Author:
- Michael Nitschinger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
QueryHandler.KeepAliveRequest
protected static class
QueryHandler.KeepAliveResponse
-
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
Fields Modifier and Type Field Description static int
MINIMUM_WINDOW_FOR_CLIENTID_TOKEN
This is a window of characters allowing to detect the clientContextID token (including room for JSON separators, etc...).protected static byte
QUERY_STATE_DONE
protected static byte
QUERY_STATE_ERROR
protected static byte
QUERY_STATE_INFO
protected static byte
QUERY_STATE_INITIAL
protected static byte
QUERY_STATE_NO_INFO
protected static byte
QUERY_STATE_ROWS
protected static byte
QUERY_STATE_ROWS_DECIDE
protected static byte
QUERY_STATE_ROWS_RAW
protected static byte
QUERY_STATE_SIGNATURE
protected static byte
QUERY_STATE_STATUS
protected static byte
QUERY_STATE_WARNING
-
Fields inherited from class com.couchbase.client.core.endpoint.AbstractGenericHandler
CHARSET, EMPTY_BYTES
-
-
Constructor Summary
Constructors Constructor Description QueryHandler(AbstractEndpoint endpoint, com.lmax.disruptor.RingBuffer<ResponseEvent> responseBuffer, boolean isTransient, boolean pipeline)
Creates a newQueryHandler
with the default queue for requests.
-
Method Summary
All Methods Instance Methods Concrete Methods 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, QueryRequest msg)
Encode the outgoing request and return it in encoded format.int
getQueryParsingState()
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, finishedDecoding, 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
-
-
-
-
Field Detail
-
QUERY_STATE_INITIAL
protected static final byte QUERY_STATE_INITIAL
- See Also:
- Constant Field Values
-
QUERY_STATE_SIGNATURE
protected static final byte QUERY_STATE_SIGNATURE
- See Also:
- Constant Field Values
-
QUERY_STATE_ROWS
protected static final byte QUERY_STATE_ROWS
- See Also:
- Constant Field Values
-
QUERY_STATE_ROWS_RAW
protected static final byte QUERY_STATE_ROWS_RAW
- See Also:
- Constant Field Values
-
QUERY_STATE_ROWS_DECIDE
protected static final byte QUERY_STATE_ROWS_DECIDE
- See Also:
- Constant Field Values
-
QUERY_STATE_ERROR
protected static final byte QUERY_STATE_ERROR
- See Also:
- Constant Field Values
-
QUERY_STATE_WARNING
protected static final byte QUERY_STATE_WARNING
- See Also:
- Constant Field Values
-
QUERY_STATE_STATUS
protected static final byte QUERY_STATE_STATUS
- See Also:
- Constant Field Values
-
QUERY_STATE_INFO
protected static final byte QUERY_STATE_INFO
- See Also:
- Constant Field Values
-
QUERY_STATE_NO_INFO
protected static final byte QUERY_STATE_NO_INFO
- See Also:
- Constant Field Values
-
QUERY_STATE_DONE
protected static final byte QUERY_STATE_DONE
- See Also:
- Constant Field Values
-
MINIMUM_WINDOW_FOR_CLIENTID_TOKEN
public static final int MINIMUM_WINDOW_FOR_CLIENTID_TOKEN
This is a window of characters allowing to detect the clientContextID token (including room for JSON separators, etc...).- See Also:
- Constant Field Values
-
-
Constructor Detail
-
QueryHandler
public QueryHandler(AbstractEndpoint endpoint, com.lmax.disruptor.RingBuffer<ResponseEvent> responseBuffer, boolean isTransient, boolean pipeline)
Creates a newQueryHandler
with the default queue for requests.- Parameters:
endpoint
- theAbstractEndpoint
to coordinate with.responseBuffer
- theRingBuffer
to push responses into.
-
-
Method Detail
-
encodeRequest
protected HttpRequest encodeRequest(ChannelHandlerContext ctx, QueryRequest msg) throws Exception
Description 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,QueryRequest>
- 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 Exception
Description 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,QueryRequest>
- 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.
-
handlerRemoved
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception
- Specified by:
handlerRemoved
in interfaceChannelHandler
- Overrides:
handlerRemoved
in classAbstractGenericHandler<HttpObject,HttpRequest,QueryRequest>
- Throws:
Exception
-
createKeepAliveRequest
protected CouchbaseRequest 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,QueryRequest>
- Returns:
- a CouchbaseRequest to be fired in case of keep alive (null by default).
-
serviceType
protected ServiceType serviceType()
Description copied from class:AbstractGenericHandler
Returns theServiceType
associated with this handler.- Specified by:
serviceType
in classAbstractGenericHandler<HttpObject,HttpRequest,QueryRequest>
- Returns:
- the service type.
-
getQueryParsingState
public int getQueryParsingState()
-
-