Package com.couchbase.client.core.msg.kv
Class BaseKeyValueRequest<R extends Response>
java.lang.Object
com.couchbase.client.core.msg.BaseRequest<R>
com.couchbase.client.core.msg.kv.BaseKeyValueRequest<R>
- All Implemented Interfaces:
KeyValueRequest<R>
,Request<R>
,ScopedRequest
- Direct Known Subclasses:
AppendRequest
,CarrierBucketConfigRequest
,CarrierGlobalConfigRequest
,DecrementRequest
,GetAndLockRequest
,GetAndTouchRequest
,GetCollectionIdRequest
,GetCollectionManifestRequest
,GetMetaRequest
,GetRequest
,IncrementRequest
,InsertRequest
,MultiObserveViaCasRequest
,NoopRequest
,ObserveViaCasRequest
,ObserveViaSeqnoRequest
,PredeterminedPartitionRequest
,PrependRequest
,RemoveRequest
,ReplaceRequest
,SubdocGetRequest
,SubdocMutateRequest
,TouchRequest
,UnlockRequest
,UpsertRequest
public abstract class BaseKeyValueRequest<R extends Response>
extends BaseRequest<R>
implements KeyValueRequest<R>
The
BaseKeyValueRequest
should be subclassed by all KeyValue requests since it
provides common ground for all of them (i.e. adding the kv partition needed).- Since:
- 2.0.0
-
Constructor Summary
ModifierConstructorDescriptionprotected
BaseKeyValueRequest
(Duration timeout, CoreContext ctx, RetryStrategy retryStrategy, String key, CollectionIdentifier collectionIdentifier) protected
BaseKeyValueRequest
(Duration timeout, CoreContext ctx, RetryStrategy retryStrategy, String key, CollectionIdentifier collectionIdentifier, RequestSpan span) -
Method Summary
Modifier and TypeMethodDescriptionbucket()
Returns the name of the bucket this request is scoped to, or null if not scoped to a bucket.protected com.couchbase.client.core.deps.io.netty.buffer.ByteBuf
encodedExternalKeyWithCollection
(com.couchbase.client.core.deps.io.netty.buffer.ByteBufAllocator alloc, KeyValueChannelContext ctx, byte[] key) Encodes a given key with the collection prefix if needed.protected com.couchbase.client.core.deps.io.netty.buffer.ByteBuf
encodedKeyWithCollection
(com.couchbase.client.core.deps.io.netty.buffer.ByteBufAllocator alloc, KeyValueChannelContext ctx) This method returns an encoded key with or without the collection prefix, depending on the context provided.void
errorCode
(ErrorMap.ErrorCode errorCode) Sets the error code on the request for debugging purposes.void
Increments the counter indicating that this request has been rejected with a not my vbucket response.byte[]
key()
The key of the kv request.static int
int
opaque()
Returns a potentially non-unique identifier that is useful for tracing output.short
Reads the currently set partition this request is targeted against.void
partition
(short partition) Allows to set the partition used for this request.int
Returns the number of times this request has been rejected with a not my vbucket response before.Returns contextual information for each individual service.The service type of this request.Methods inherited from class com.couchbase.client.core.msg.BaseRequest
absoluteTimeout, cancel, cancellationReason, cancelled, completed, context, createdAt, fail, failed, id, requestSpan, response, retryStrategy, succeed, succeeded, timeout, timeoutElapsed, timeoutRegistration
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.couchbase.client.core.msg.kv.KeyValueRequest
decode, encode
Methods inherited from interface com.couchbase.client.core.msg.Request
absoluteTimeout, cancel, cancel, cancellationReason, cancelled, completed, context, createdAt, fail, failed, id, idempotent, name, requestSpan, response, retryStrategy, succeed, succeeded, target, timeout, timeoutElapsed, timeoutRegistration
-
Constructor Details
-
BaseKeyValueRequest
protected BaseKeyValueRequest(Duration timeout, CoreContext ctx, RetryStrategy retryStrategy, String key, CollectionIdentifier collectionIdentifier) -
BaseKeyValueRequest
protected BaseKeyValueRequest(Duration timeout, CoreContext ctx, RetryStrategy retryStrategy, String key, CollectionIdentifier collectionIdentifier, RequestSpan span)
-
-
Method Details
-
nextOpaque
public static int nextOpaque() -
partition
public short partition()Description copied from interface:KeyValueRequest
Reads the currently set partition this request is targeted against.- Specified by:
partition
in interfaceKeyValueRequest<R extends Response>
-
partition
public void partition(short partition) Description copied from interface:KeyValueRequest
Allows to set the partition used for this request.- Specified by:
partition
in interfaceKeyValueRequest<R extends Response>
- Parameters:
partition
- the partition to set.
-
encodedKeyWithCollection
protected com.couchbase.client.core.deps.io.netty.buffer.ByteBuf encodedKeyWithCollection(com.couchbase.client.core.deps.io.netty.buffer.ByteBufAllocator alloc, KeyValueChannelContext ctx) This method returns an encoded key with or without the collection prefix, depending on the context provided.Note that it uses the key set during construction, if you want to encode a different key use the
encodedExternalKeyWithCollection(ByteBufAllocator, KeyValueChannelContext, byte[])
method instead.- Parameters:
alloc
- the buffer allocator to use.ctx
- the channel context.- Returns:
- the encoded ID, maybe with the collection prefix in place.
-
encodedExternalKeyWithCollection
protected com.couchbase.client.core.deps.io.netty.buffer.ByteBuf encodedExternalKeyWithCollection(com.couchbase.client.core.deps.io.netty.buffer.ByteBufAllocator alloc, KeyValueChannelContext ctx, byte[] key) Encodes a given key with the collection prefix if needed.- Parameters:
alloc
- the buffer allocator to use.ctx
- the channel context.key
- the key to encode with collection id.- Returns:
- the encoded ID, maybe with the collection prefix in place.
-
serviceType
Description copied from interface:Request
The service type of this request.Can be null if this is a 'virtual service' (e.g. transactions), which don't map 1:1 to a particular cluster service, but need to integrate into various codepaths that are built around ServiceType such as ThresholdLoggingTracer. Virtual requests must not be sent into core at present, as there is limited support for them.
- Specified by:
serviceType
in interfaceRequest<R extends Response>
- Returns:
- the service type for this request.
-
opaque
public int opaque()- Specified by:
opaque
in interfaceKeyValueRequest<R extends Response>
-
serviceContext
Description copied from interface:Request
Returns contextual information for each individual service.- Specified by:
serviceContext
in interfaceRequest<R extends Response>
- Overrides:
serviceContext
in classBaseRequest<R extends Response>
- Returns:
- the service context.
-
key
public byte[] key()Description copied from interface:KeyValueRequest
The key of the kv request.- Specified by:
key
in interfaceKeyValueRequest<R extends Response>
- Returns:
- the key of the request.
-
bucket
Description copied from interface:Request
Returns the name of the bucket this request is scoped to, or null if not scoped to a bucket. -
collectionIdentifier
- Specified by:
collectionIdentifier
in interfaceKeyValueRequest<R extends Response>
-
operationId
Description copied from interface:Request
Returns a potentially non-unique identifier that is useful for tracing output.Note: might be null! It depends on the type of operation. It is also different from the unqiue operation ID that increments to provide additional context (i.e in query the context uuid, in kv the opaque value).
- Specified by:
operationId
in interfaceRequest<R extends Response>
- Returns:
- if present, the operation id. Null otherwise.
-
rejectedWithNotMyVbucket
public int rejectedWithNotMyVbucket()Description copied from interface:KeyValueRequest
Returns the number of times this request has been rejected with a not my vbucket response before.- Specified by:
rejectedWithNotMyVbucket
in interfaceKeyValueRequest<R extends Response>
-
indicateRejectedWithNotMyVbucket
public void indicateRejectedWithNotMyVbucket()Description copied from interface:KeyValueRequest
Increments the counter indicating that this request has been rejected with a not my vbucket response.- Specified by:
indicateRejectedWithNotMyVbucket
in interfaceKeyValueRequest<R extends Response>
-
errorCode
Description copied from interface:KeyValueRequest
Sets the error code on the request for debugging purposes.- Specified by:
errorCode
in interfaceKeyValueRequest<R extends Response>
- Parameters:
errorCode
- the error code to set for the request.
-