Class KeyValueHandler
- 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<FullBinaryMemcacheResponse,BinaryMemcacheRequest,BinaryRequest>
-
- com.couchbase.client.core.endpoint.kv.KeyValueHandler
-
- All Implemented Interfaces:
ChannelHandler
,ChannelInboundHandler
,ChannelOutboundHandler
public class KeyValueHandler extends AbstractGenericHandler<FullBinaryMemcacheResponse,BinaryMemcacheRequest,BinaryRequest>
TheKeyValueHandler
is responsible for encodingBinaryRequest
s into lower levelBinaryMemcacheRequest
s as well as decodingFullBinaryMemcacheResponse
s intoCouchbaseResponse
s.- Since:
- 1.0
- Author:
- Michael Nitschinger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
KeyValueHandler.KeepAliveRequest
protected static class
KeyValueHandler.KeepAliveResponse
-
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
Fields Modifier and Type Field Description static byte
DATATYPE_SNAPPY
The datatype byte used to signal snappy.static byte
FRAMING_EXTRAS_TRACING
The byte used to signal this is a tracing extras frame.static byte
OP_APPEND
static byte
OP_COUNTER_DECR
static byte
OP_COUNTER_INCR
static byte
OP_GET
static byte
OP_GET_ALL_MUTATION_TOKENS
static byte
OP_GET_AND_LOCK
static byte
OP_GET_AND_TOUCH
static byte
OP_GET_BUCKET_CONFIG
static byte
OP_GET_REPLICA
static byte
OP_INSERT
static byte
OP_NOOP
static byte
OP_OBSERVE
static byte
OP_OBSERVE_SEQ
static byte
OP_PREPEND
static byte
OP_REMOVE
static byte
OP_REPLACE
static byte
OP_STAT
static byte
OP_SUB_ARRAY_ADD_UNIQUE
static byte
OP_SUB_ARRAY_INSERT
static byte
OP_SUB_ARRAY_PUSH_FIRST
static byte
OP_SUB_ARRAY_PUSH_LAST
static byte
OP_SUB_COUNTER
static byte
OP_SUB_DELETE
static byte
OP_SUB_DICT_ADD
static byte
OP_SUB_DICT_UPSERT
static byte
OP_SUB_EXIST
static byte
OP_SUB_GET
static byte
OP_SUB_GET_COUNT
static byte
OP_SUB_MULTI_LOOKUP
static byte
OP_SUB_MULTI_MUTATION
static byte
OP_SUB_REPLACE
static byte
OP_TOUCH
static byte
OP_UNLOCK
static byte
OP_UPSERT
static byte
SUBDOC_BITMASK_MKDIR_P
The bitmask for sub-document extras "command" section (third byte of the extras) that activates the creation of missing intermediate nodes in the JSON path.static byte
SUBDOC_DOCFLAG_ACCESS_DELETED
The bitmask for sub-document access deletedstatic byte
SUBDOC_DOCFLAG_INSERT
The bitmask for sub-document insert documentstatic byte
SUBDOC_DOCFLAG_MKDOC
The bitmask for sub-document create documentstatic byte
SUBDOC_FLAG_EXPAND_MACROS
The bitmask for sub-document expansion of fields such as ${Mutation.CAS}static byte
SUBDOC_FLAG_XATTR_PATH
The bitmask for sub-document xattr/hidden section of the document-
Fields inherited from class com.couchbase.client.core.endpoint.AbstractGenericHandler
CHARSET, EMPTY_BYTES
-
-
Constructor Summary
Constructors Constructor Description KeyValueHandler(AbstractEndpoint endpoint, com.lmax.disruptor.EventSink<ResponseEvent> responseBuffer, boolean isTransient, boolean pipeline)
Creates a newKeyValueHandler
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, FullBinaryMemcacheResponse msg)
Decodes the incoming response and transforms it into aCouchbaseResponse
.protected BinaryMemcacheRequest
encodeRequest(ChannelHandlerContext ctx, BinaryRequest msg)
Encode the outgoing request and return it in encoded format.protected ServiceType
serviceType()
Returns theServiceType
associated with this handler.protected void
sideEffectRequestToCancel(BinaryRequest request)
Releasing the content of requests that are to be cancelled.void
userEventTriggered(ChannelHandlerContext ctx, Object evt)
-
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, handlerRemoved, logIdent, onKeepAliveFired, onKeepAliveResponse, publishResponse, remoteHostname, remoteHttpHost, shouldSendKeepAlive, 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
-
OP_GET_BUCKET_CONFIG
public static final byte OP_GET_BUCKET_CONFIG
- See Also:
- Constant Field Values
-
OP_GET
public static final byte OP_GET
- See Also:
- Constant Field Values
-
OP_GET_AND_LOCK
public static final byte OP_GET_AND_LOCK
- See Also:
- Constant Field Values
-
OP_GET_AND_TOUCH
public static final byte OP_GET_AND_TOUCH
- See Also:
- Constant Field Values
-
OP_GET_REPLICA
public static final byte OP_GET_REPLICA
- See Also:
- Constant Field Values
-
OP_INSERT
public static final byte OP_INSERT
- See Also:
- Constant Field Values
-
OP_UPSERT
public static final byte OP_UPSERT
- See Also:
- Constant Field Values
-
OP_REPLACE
public static final byte OP_REPLACE
- See Also:
- Constant Field Values
-
OP_REMOVE
public static final byte OP_REMOVE
- See Also:
- Constant Field Values
-
OP_COUNTER_INCR
public static final byte OP_COUNTER_INCR
- See Also:
- Constant Field Values
-
OP_COUNTER_DECR
public static final byte OP_COUNTER_DECR
- See Also:
- Constant Field Values
-
OP_UNLOCK
public static final byte OP_UNLOCK
- See Also:
- Constant Field Values
-
OP_OBSERVE
public static final byte OP_OBSERVE
- See Also:
- Constant Field Values
-
OP_OBSERVE_SEQ
public static final byte OP_OBSERVE_SEQ
- See Also:
- Constant Field Values
-
OP_TOUCH
public static final byte OP_TOUCH
- See Also:
- Constant Field Values
-
OP_APPEND
public static final byte OP_APPEND
- See Also:
- Constant Field Values
-
OP_PREPEND
public static final byte OP_PREPEND
- See Also:
- Constant Field Values
-
OP_NOOP
public static final byte OP_NOOP
- See Also:
- Constant Field Values
-
OP_STAT
public static final byte OP_STAT
- See Also:
- Constant Field Values
-
OP_GET_ALL_MUTATION_TOKENS
public static final byte OP_GET_ALL_MUTATION_TOKENS
- See Also:
- Constant Field Values
-
OP_SUB_GET
public static final byte OP_SUB_GET
- See Also:
- Constant Field Values
-
OP_SUB_EXIST
public static final byte OP_SUB_EXIST
- See Also:
- Constant Field Values
-
OP_SUB_DICT_ADD
public static final byte OP_SUB_DICT_ADD
- See Also:
- Constant Field Values
-
OP_SUB_DICT_UPSERT
public static final byte OP_SUB_DICT_UPSERT
- See Also:
- Constant Field Values
-
OP_SUB_DELETE
public static final byte OP_SUB_DELETE
- See Also:
- Constant Field Values
-
OP_SUB_REPLACE
public static final byte OP_SUB_REPLACE
- See Also:
- Constant Field Values
-
OP_SUB_ARRAY_PUSH_LAST
public static final byte OP_SUB_ARRAY_PUSH_LAST
- See Also:
- Constant Field Values
-
OP_SUB_ARRAY_PUSH_FIRST
public static final byte OP_SUB_ARRAY_PUSH_FIRST
- See Also:
- Constant Field Values
-
OP_SUB_ARRAY_INSERT
public static final byte OP_SUB_ARRAY_INSERT
- See Also:
- Constant Field Values
-
OP_SUB_ARRAY_ADD_UNIQUE
public static final byte OP_SUB_ARRAY_ADD_UNIQUE
- See Also:
- Constant Field Values
-
OP_SUB_COUNTER
public static final byte OP_SUB_COUNTER
- See Also:
- Constant Field Values
-
OP_SUB_MULTI_LOOKUP
public static final byte OP_SUB_MULTI_LOOKUP
- See Also:
- Constant Field Values
-
OP_SUB_MULTI_MUTATION
public static final byte OP_SUB_MULTI_MUTATION
- See Also:
- Constant Field Values
-
OP_SUB_GET_COUNT
public static final byte OP_SUB_GET_COUNT
- See Also:
- Constant Field Values
-
FRAMING_EXTRAS_TRACING
public static final byte FRAMING_EXTRAS_TRACING
The byte used to signal this is a tracing extras frame.- See Also:
- Constant Field Values
-
SUBDOC_BITMASK_MKDIR_P
public static final byte SUBDOC_BITMASK_MKDIR_P
The bitmask for sub-document extras "command" section (third byte of the extras) that activates the creation of missing intermediate nodes in the JSON path.- See Also:
- Constant Field Values
-
SUBDOC_FLAG_XATTR_PATH
public static final byte SUBDOC_FLAG_XATTR_PATH
The bitmask for sub-document xattr/hidden section of the document- See Also:
- Constant Field Values
-
SUBDOC_FLAG_EXPAND_MACROS
public static final byte SUBDOC_FLAG_EXPAND_MACROS
The bitmask for sub-document expansion of fields such as ${Mutation.CAS}- See Also:
- Constant Field Values
-
SUBDOC_DOCFLAG_MKDOC
public static final byte SUBDOC_DOCFLAG_MKDOC
The bitmask for sub-document create document- See Also:
- Constant Field Values
-
SUBDOC_DOCFLAG_INSERT
public static final byte SUBDOC_DOCFLAG_INSERT
The bitmask for sub-document insert document- See Also:
- Constant Field Values
-
SUBDOC_DOCFLAG_ACCESS_DELETED
public static final byte SUBDOC_DOCFLAG_ACCESS_DELETED
The bitmask for sub-document access deleted- See Also:
- Constant Field Values
-
DATATYPE_SNAPPY
public static final byte DATATYPE_SNAPPY
The datatype byte used to signal snappy.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
KeyValueHandler
public KeyValueHandler(AbstractEndpoint endpoint, com.lmax.disruptor.EventSink<ResponseEvent> responseBuffer, boolean isTransient, boolean pipeline)
Creates a newKeyValueHandler
with the default queue for requests.- Parameters:
endpoint
- theAbstractEndpoint
to coordinate with.responseBuffer
- theRingBuffer
to push responses into.
-
-
Method Detail
-
encodeRequest
protected BinaryMemcacheRequest encodeRequest(ChannelHandlerContext ctx, BinaryRequest 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<FullBinaryMemcacheResponse,BinaryMemcacheRequest,BinaryRequest>
- 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, FullBinaryMemcacheResponse 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<FullBinaryMemcacheResponse,BinaryMemcacheRequest,BinaryRequest>
- 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.
-
sideEffectRequestToCancel
protected void sideEffectRequestToCancel(BinaryRequest request)
Releasing the content of requests that are to be cancelled.- Overrides:
sideEffectRequestToCancel
in classAbstractGenericHandler<FullBinaryMemcacheResponse,BinaryMemcacheRequest,BinaryRequest>
- Parameters:
request
- the request to side effect on.
-
userEventTriggered
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception
- Specified by:
userEventTriggered
in interfaceChannelInboundHandler
- Overrides:
userEventTriggered
in classAbstractGenericHandler<FullBinaryMemcacheResponse,BinaryMemcacheRequest,BinaryRequest>
- 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<FullBinaryMemcacheResponse,BinaryMemcacheRequest,BinaryRequest>
- 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<FullBinaryMemcacheResponse,BinaryMemcacheRequest,BinaryRequest>
- Returns:
- the service type.
-
-