public abstract class BaseKeyValueRequest<R extends Response> extends BaseRequest<R> implements KeyValueRequest<R>
BaseKeyValueRequest should be subclassed by all KeyValue requests since it
provides common ground for all of them (i.e. adding the kv partition needed).| Modifier | Constructor and Description |
|---|---|
protected |
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) |
| Modifier and Type | Method and Description |
|---|---|
String |
bucket()
Returns the name of the bucket this request is scoped to, or null if not scoped to a bucket.
|
CollectionIdentifier |
collectionIdentifier() |
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 |
indicateRejectedWithNotMyVbucket()
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 |
nextOpaque() |
int |
opaque() |
String |
operationId()
Returns a potentially non-unique identifier that is useful for tracing output.
|
short |
partition()
Reads the currently set partition this request is targeted against.
|
void |
partition(short partition)
Allows to set the partition used for this request.
|
int |
rejectedWithNotMyVbucket()
Returns the number of times this request has been rejected with a not my vbucket response before.
|
Map<String,Object> |
serviceContext()
Returns contextual information for each individual service.
|
ServiceType |
serviceType()
The service type of this request.
|
absoluteTimeout, cancel, cancellationReason, cancelled, completed, context, createdAt, fail, failed, id, requestSpan, response, retryStrategy, succeed, succeeded, timeout, timeoutElapsed, timeoutRegistrationclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdecode, encodeabsoluteTimeout, cancel, cancel, cancellationReason, cancelled, completed, context, createdAt, fail, failed, id, idempotent, name, requestSpan, response, retryStrategy, succeed, succeeded, target, timeout, timeoutElapsed, timeoutRegistrationprotected 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)
public static int nextOpaque()
public short partition()
KeyValueRequestpartition in interface KeyValueRequest<R extends Response>public void partition(short partition)
KeyValueRequestpartition in interface KeyValueRequest<R extends Response>partition - the partition to set.protected com.couchbase.client.core.deps.io.netty.buffer.ByteBuf encodedKeyWithCollection(com.couchbase.client.core.deps.io.netty.buffer.ByteBufAllocator alloc,
KeyValueChannelContext ctx)
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.
alloc - the buffer allocator to use.ctx - the channel context.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)
alloc - the buffer allocator to use.ctx - the channel context.key - the key to encode with collection id.public ServiceType serviceType()
RequestCan 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.
serviceType in interface Request<R extends Response>public int opaque()
opaque in interface KeyValueRequest<R extends Response>public Map<String,Object> serviceContext()
RequestserviceContext in interface Request<R extends Response>serviceContext in class BaseRequest<R extends Response>public byte[] key()
KeyValueRequestkey in interface KeyValueRequest<R extends Response>public String bucket()
Requestpublic CollectionIdentifier collectionIdentifier()
collectionIdentifier in interface KeyValueRequest<R extends Response>public String operationId()
RequestNote: 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).
operationId in interface Request<R extends Response>public int rejectedWithNotMyVbucket()
KeyValueRequestrejectedWithNotMyVbucket in interface KeyValueRequest<R extends Response>public void indicateRejectedWithNotMyVbucket()
KeyValueRequestindicateRejectedWithNotMyVbucket in interface KeyValueRequest<R extends Response>public void errorCode(ErrorMap.ErrorCode errorCode)
KeyValueRequesterrorCode in interface KeyValueRequest<R extends Response>errorCode - the error code to set for the request.Copyright © 2024 Couchbase, Inc.. All rights reserved.