Package com.couchbase.client.core.msg
Class RequestContext
- java.lang.Object
-
- com.couchbase.client.core.cnc.AbstractContext
-
- com.couchbase.client.core.CoreContext
-
- com.couchbase.client.core.msg.RequestContext
-
- All Implemented Interfaces:
Context
public class RequestContext extends CoreContext
Additional context which might be attached to an individualRequest.- Since:
- 2.0.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.couchbase.client.core.cnc.Context
Context.ExportFormat
-
-
Constructor Summary
Constructors Constructor Description RequestContext(CoreContext ctx, Request<? extends Response> request)Creates a newRequestContext.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RequestContextcancel()Allows to cancel the attachedRequestfrom anywhere in the code.Map<String,Object>clientContext()Returns the custom user payload of this request.RequestContextclientContext(Map<String,Object> clientContext)Allows to set a custom payload for this request.longdispatchLatency()Returns the duration of the dispatch phase if set.RequestContextdispatchLatency(long dispatchLatency)Allows to set the dispatch duration of the request.longencodeLatency()RequestContextencodeLatency(long encodeLatency)RequestContextincrementRetryAttempts(Duration lastRetryDuration, RetryReason reason)voidinjectExportableParams(Map<String,Object> input)This method needs to be implemented by the actual context implementations to inject the params they need for exporting.StringlastChannelId()RequestContextlastChannelId(String lastChannelId)HostAndPortlastDispatchedFrom()RequestContextlastDispatchedFrom(HostAndPort lastDispatchedFrom)HostAndPortlastDispatchedTo()RequestContextlastDispatchedTo(HostAndPort lastDispatchedTo)NodeIdentifierlastDispatchedToNode()RequestContextlastDispatchedToNode(NodeIdentifier lastDispatchedToNode)DurationlastRetryDuration()RequestContextlogicallyComplete()RequestContextlogicallyComplete(Throwable err)Signals that this request is completed fully, including streaming sections or logical sub-requests also being completed (i.e.longlogicallyCompletedAt()Returns the absolute nano time when the request got logically completed.longlogicalRequestLatency()Returns the request latency once logically completed (includes potential "inner" operations like observe calls).Request<? extends Response>request()intretryAttempts()Set<RetryReason>retryReasons()longserverLatency()RequestContextserverLatency(long serverLatency)longtotalDispatchLatency()longtotalServerLatency()-
Methods inherited from class com.couchbase.client.core.CoreContext
alternateAddress, alternateAddress, authenticator, core, environment, id
-
Methods inherited from class com.couchbase.client.core.cnc.AbstractContext
exportAsMap, exportAsString, toString
-
-
-
-
Constructor Detail
-
RequestContext
@Internal public RequestContext(CoreContext ctx, Request<? extends Response> request)
Creates a newRequestContext.- Parameters:
ctx- the core context.request- the linked request.
-
-
Method Detail
-
dispatchLatency
@Volatile public long dispatchLatency()
Returns the duration of the dispatch phase if set.- Returns:
- the duration of the dispatch phase.
-
dispatchLatency
@Internal public RequestContext dispatchLatency(long dispatchLatency)
Allows to set the dispatch duration of the request.- Parameters:
dispatchLatency- the duration.
-
totalDispatchLatency
public long totalDispatchLatency()
-
totalServerLatency
public long totalServerLatency()
-
encodeLatency
@Volatile public long encodeLatency()
-
encodeLatency
@Internal public RequestContext encodeLatency(long encodeLatency)
-
lastChannelId
@Internal public RequestContext lastChannelId(String lastChannelId)
-
serverLatency
@Volatile public long serverLatency()
-
serverLatency
@Internal public RequestContext serverLatency(long serverLatency)
-
logicallyComplete
@Internal public RequestContext logicallyComplete(@Nullable Throwable err)
Signals that this request is completed fully, including streaming sections or logical sub-requests also being completed (i.e. observe polling).- Parameters:
err- if non-null, will be recorded onto the span (if present).
-
logicallyComplete
@Internal public RequestContext logicallyComplete()
-
retryAttempts
public int retryAttempts()
-
retryReasons
public Set<RetryReason> retryReasons()
-
lastRetryDuration
public Duration lastRetryDuration()
-
logicallyCompletedAt
public long logicallyCompletedAt()
Returns the absolute nano time when the request got logically completed.
-
logicalRequestLatency
public long logicalRequestLatency()
Returns the request latency once logically completed (includes potential "inner" operations like observe calls).
-
incrementRetryAttempts
@Internal public RequestContext incrementRetryAttempts(Duration lastRetryDuration, RetryReason reason)
-
lastDispatchedTo
public HostAndPort lastDispatchedTo()
-
lastDispatchedToNode
@Internal public NodeIdentifier lastDispatchedToNode()
-
lastDispatchedTo
@Internal public RequestContext lastDispatchedTo(HostAndPort lastDispatchedTo)
-
lastDispatchedToNode
@Internal public RequestContext lastDispatchedToNode(NodeIdentifier lastDispatchedToNode)
-
lastDispatchedFrom
public HostAndPort lastDispatchedFrom()
-
lastDispatchedFrom
@Internal public RequestContext lastDispatchedFrom(HostAndPort lastDispatchedFrom)
-
clientContext
public Map<String,Object> clientContext()
Returns the custom user payload of this request.- Returns:
- the payload if set.
-
clientContext
@Internal public RequestContext clientContext(Map<String,Object> clientContext)
Allows to set a custom payload for this request.- Parameters:
clientContext- the payload to set.
-
injectExportableParams
public void injectExportableParams(Map<String,Object> input)
Description copied from class:AbstractContextThis method needs to be implemented by the actual context implementations to inject the params they need for exporting.- Overrides:
injectExportableParamsin classCoreContext- Parameters:
input- pass exportable params in here.
-
cancel
@Uncommitted public RequestContext cancel()
Allows to cancel the attachedRequestfrom anywhere in the code.If the operation is already completed (either successfully or failed) this is an operation without side-effect.
-
-