public class ViewHandler extends AbstractGenericHandler<HttpObject,HttpRequest,ViewRequest>
The ViewHandler
is responsible for encoding ViewRequest
s into lower level HttpRequest
s as well as decoding HttpObject
s into CouchbaseResponse
s.
Modifier and Type | Class and Description |
---|---|
protected static class |
ViewHandler.KeepAliveRequest |
protected static class |
ViewHandler.KeepAliveResponse |
ChannelHandler.Sharable
CHARSET
Constructor and Description |
---|
ViewHandler(AbstractEndpoint endpoint,
com.lmax.disruptor.RingBuffer<ResponseEvent> responseBuffer,
boolean isTransient)
Creates a new
ViewHandler with the default queue for requests. |
Modifier and Type | Method and 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 a
CouchbaseResponse . |
protected HttpRequest |
encodeRequest(ChannelHandlerContext ctx,
ViewRequest msg)
Encode the outgoing request and return it in encoded format.
|
protected Tuple2<String,String> |
extractKeysFromQueryString(String queryString,
int splitThreshold)
A utility method to split a GET-like query String into a
Tuple2 of Strings if size of the original gets above a threshold. |
void |
handlerRemoved(ChannelHandlerContext ctx) |
channelActive, channelInactive, channelWritabilityChanged, currentRequest, currentRequest, decode, encode, env, exceptionCaught, finishedDecoding, logIdent, onKeepAliveFired, onKeepAliveResponse, publishResponse, sideEffectRequestToCancel, userEventTriggered
acceptInboundMessage, acceptOutboundMessage, channelRead, write
bind, close, connect, deregister, disconnect, flush, read
channelReadComplete, channelRegistered, channelUnregistered
handlerAdded, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
handlerAdded
public ViewHandler(AbstractEndpoint endpoint, com.lmax.disruptor.RingBuffer<ResponseEvent> responseBuffer, boolean isTransient)
Creates a new ViewHandler
with the default queue for requests.
endpoint
- the AbstractEndpoint
to coordinate with.responseBuffer
- the RingBuffer
to push responses into.protected Tuple2<String,String> extractKeysFromQueryString(String queryString, int splitThreshold)
A utility method to split a GET-like query String into a Tuple2
of Strings if size of the original gets above a threshold. If not, the original String is returned as value1 of the tuple, and value2 is null. Otherwise, value1 is the original query string minus a “keys” parameter, and value2 is a json representation of the keys parameter.
queryString
- the GET-like query string to process if length is above threshold.splitThreshold
- the size processing threshold.Tuple2
with keys parameter isolated in value2 as a JSON object.protected HttpRequest encodeRequest(ChannelHandlerContext ctx, ViewRequest msg) throws Exception
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.
encodeRequest
in class AbstractGenericHandler<HttpObject,HttpRequest,ViewRequest>
ctx
- the context passed in.msg
- the outgoing message.Exception
- as a generic error.protected CouchbaseResponse decodeResponse(ChannelHandlerContext ctx, HttpObject msg) throws Exception
AbstractGenericHandler
Decodes the incoming response and transforms it into a CouchbaseResponse
.
Note that the actual notification is handled by this generic handler, the implementing class only is concerned about the conversion itself.
decodeResponse
in class AbstractGenericHandler<HttpObject,HttpRequest,ViewRequest>
ctx
- the context passed in.msg
- the incoming message.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.public void handlerRemoved(ChannelHandlerContext ctx) throws Exception
handlerRemoved
in interface ChannelHandler
handlerRemoved
in class AbstractGenericHandler<HttpObject,HttpRequest,ViewRequest>
Exception
protected CouchbaseRequest createKeepAliveRequest()
AbstractGenericHandler
Override to return a non-null request to be fired in the pipeline in case a keep alive is triggered.
createKeepAliveRequest
in class AbstractGenericHandler<HttpObject,HttpRequest,ViewRequest>
Copyright © 2014 Couchbase, Inc.