Class AbstractCouchbaseRequest
java.lang.Object
com.couchbase.client.core.message.AbstractCouchbaseRequest
- All Implemented Interfaces:
CouchbaseMessage
,CouchbaseRequest
- Direct Known Subclasses:
AbstractKeyValueRequest
,AddNodeRequest
,AddServiceRequest
,AnalyticsHandler.KeepAliveRequest
,AnalyticsHandlerV2.KeepAliveRequest
,AnalyticsQueryResultRequest
,AnalyticsQueryStatusRequest
,BucketConfigRequest
,BucketsConfigRequest
,BucketStreamingRequest
,CloseBucketRequest
,ClusterConfigRequest
,DiagnosticsRequest
,DisconnectRequest
,FlushRequest
,GenericAnalyticsRequest
,GenericQueryRequest
,GetClusterConfigRequest
,GetConfigProviderRequest
,GetDesignDocumentRequest
,GetDesignDocumentsRequest
,GetSearchIndexRequest
,GetUsersRequest
,InsertBucketRequest
,OpenBucketRequest
,PingRequest
,PingRequest
,PingRequest
,PingRequest
,QueryHandler.KeepAliveRequest
,QueryHandlerV2.KeepAliveRequest
,RemoveBucketRequest
,RemoveDesignDocumentRequest
,RemoveNodeRequest
,RemoveSearchIndexRequest
,RemoveServiceRequest
,RemoveUserRequest
,RestApiRequest
,SearchHandler.KeepAliveRequest
,SearchQueryRequest
,SeedNodesRequest
,SignalConfigReload
,SignalFlush
,UpdateBucketRequest
,UpsertDesignDocumentRequest
,UpsertSearchIndexRequest
,UpsertUserRequest
,ViewHandler.KeepAliveRequest
,ViewQueryRequest
public abstract class AbstractCouchbaseRequest extends Object implements CouchbaseRequest
Default implementation for a
CouchbaseRequest
, should be extended by child messages.- Since:
- 1.0
- Author:
- Michael Nitschinger
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractCouchbaseRequest(String bucket, String password)
Create a newAbstractCouchbaseRequest
.protected
AbstractCouchbaseRequest(String bucket, String username, String password)
Create a newAbstractCouchbaseRequest
.protected
AbstractCouchbaseRequest(String bucket, String username, String password, rx.subjects.Subject<CouchbaseResponse,CouchbaseResponse> observable)
Create a newAbstractCouchbaseRequest
. -
Method Summary
Modifier and Type Method Description protected void
afterSpanSet(io.opentracing.Span span)
Use this method to add custom span values on insert.String
bucket()
The associated bucket name for this request.void
complete()
Completes the underlying state holder.long
creationTime()
Returns the time in nanoseconds when the message was created.String
dispatchHostname()
void
dispatchHostname(String hostname)
void
emit(CouchbaseResponse response)
Emits theCouchbaseResponse
into the underlying state holder (like a subject) without completing it as per contract.void
fail(Throwable throwable)
Fails theCouchbaseResponse
on the state holder as per contract.int
incrementRetryCount()
Returns the old retry count and increments it by one.boolean
isActive()
Checks if the request is unsubscribed on a timeoutString
lastLocalId()
void
lastLocalId(String localId)
String
lastLocalSocket()
void
lastLocalSocket(String local)
String
lastRemoteSocket()
void
lastRemoteSocket(String remote)
long
maxRetryDuration()
Returns the maximum retry duration for the request.void
maxRetryDuration(long maxRetryDuration)
Sets the maximum retry duration for the request.rx.subjects.Subject<CouchbaseResponse,CouchbaseResponse>
observable()
Get the underlyingObservable
.String
operationId()
Default implementation, sub requests need to override this.String
password()
The password associated with the bucket/ userlong
retryAfter()
Gets the initial retry after time for the request.void
retryAfter(long after)
Sets the initial retry after time for the request.int
retryCount()
Returns the current retry count.Delay
retryDelay()
Returns the retry delay configvoid
retryDelay(Delay retryDelay)
Sets the retry delay configio.opentracing.Span
span()
Returns theSpan
for this request if set.void
span(io.opentracing.Span span, CoreEnvironment env)
Allows to set a custom span that should be used.void
subscriber(rx.Subscriber subscriber)
Optionally add subscriber to check for the timeoutsvoid
succeed(CouchbaseResponse response)
Emits theCouchbaseResponse
into the underlying state holder (like a subject) and completes it as well per contract.String
toString()
String
username()
User authorized for bucket access
-
Constructor Details
-
AbstractCouchbaseRequest
Create a newAbstractCouchbaseRequest
. Depending on the type of operation, bucket and password may be null, this needs to be enforced properly by the child implementations. This constructor will create a AsyncSubject, which implies that the response for this request only emits one message. If you need to expose a streaming response, use the other constructor and feed it a ReplaySubject or something similar.- Parameters:
bucket
- the name of the bucket.password
- user password.
-
AbstractCouchbaseRequest
Create a newAbstractCouchbaseRequest
. Depending on the type of operation, bucket and password may be null, this needs to be enforced properly by the child implementations. This constructor will create a AsyncSubject, which implies that the response for this request only emits one message. If you need to expose a streaming response, use the other constructor and feed it a ReplaySubject or something similar.- Parameters:
bucket
- the name of the bucket.username
- user authorized to access the bucket.password
- user password.
-
AbstractCouchbaseRequest
protected AbstractCouchbaseRequest(String bucket, String username, String password, rx.subjects.Subject<CouchbaseResponse,CouchbaseResponse> observable)Create a newAbstractCouchbaseRequest
. Depending on the type of operation, bucket and password may be null, this needs to be enforced properly by the child implementations.- Parameters:
bucket
- the name of the bucket.username
- user authorized to access the bucket.password
- the password of the bucket.
-
-
Method Details
-
observable
Description copied from interface:CouchbaseRequest
Get the underlyingObservable
.- Specified by:
observable
in interfaceCouchbaseRequest
- Returns:
- the observable which will complete the response.
-
bucket
Description copied from interface:CouchbaseRequest
The associated bucket name for this request.- Specified by:
bucket
in interfaceCouchbaseRequest
- Returns:
- the bucket name.
-
username
Description copied from interface:CouchbaseRequest
User authorized for bucket access- Specified by:
username
in interfaceCouchbaseRequest
-
password
Description copied from interface:CouchbaseRequest
The password associated with the bucket/ user- Specified by:
password
in interfaceCouchbaseRequest
- Returns:
- the password.
-
creationTime
public long creationTime()Description copied from interface:CouchbaseMessage
Returns the time in nanoseconds when the message was created.- Specified by:
creationTime
in interfaceCouchbaseMessage
- Returns:
- the creation time in nanoseconds.
-
incrementRetryCount
public int incrementRetryCount()Description copied from interface:CouchbaseRequest
Returns the old retry count and increments it by one.- Specified by:
incrementRetryCount
in interfaceCouchbaseRequest
- Returns:
- the old retryCount.
-
retryCount
public int retryCount()Description copied from interface:CouchbaseRequest
Returns the current retry count.- Specified by:
retryCount
in interfaceCouchbaseRequest
- Returns:
- the current retry count.
-
retryAfter
public void retryAfter(long after)Description copied from interface:CouchbaseRequest
Sets the initial retry after time for the request.- Specified by:
retryAfter
in interfaceCouchbaseRequest
-
retryAfter
public long retryAfter()Description copied from interface:CouchbaseRequest
Gets the initial retry after time for the request.- Specified by:
retryAfter
in interfaceCouchbaseRequest
-
maxRetryDuration
public void maxRetryDuration(long maxRetryDuration)Description copied from interface:CouchbaseRequest
Sets the maximum retry duration for the request.- Specified by:
maxRetryDuration
in interfaceCouchbaseRequest
-
maxRetryDuration
public long maxRetryDuration()Description copied from interface:CouchbaseRequest
Returns the maximum retry duration for the request.- Specified by:
maxRetryDuration
in interfaceCouchbaseRequest
- Returns:
- duration
-
retryDelay
Description copied from interface:CouchbaseRequest
Sets the retry delay config- Specified by:
retryDelay
in interfaceCouchbaseRequest
-
retryDelay
Description copied from interface:CouchbaseRequest
Returns the retry delay config- Specified by:
retryDelay
in interfaceCouchbaseRequest
- Returns:
- delay
-
isActive
public boolean isActive()Description copied from interface:CouchbaseRequest
Checks if the request is unsubscribed on a timeout- Specified by:
isActive
in interfaceCouchbaseRequest
- Returns:
- false if timed out, else true
-
subscriber
public void subscriber(rx.Subscriber subscriber)Description copied from interface:CouchbaseRequest
Optionally add subscriber to check for the timeouts- Specified by:
subscriber
in interfaceCouchbaseRequest
-
dispatchHostname
- Specified by:
dispatchHostname
in interfaceCouchbaseRequest
-
dispatchHostname
- Specified by:
dispatchHostname
in interfaceCouchbaseRequest
-
emit
Description copied from interface:CouchbaseRequest
Emits theCouchbaseResponse
into the underlying state holder (like a subject) without completing it as per contract.- Specified by:
emit
in interfaceCouchbaseRequest
- Parameters:
response
- the response to emit.
-
complete
public void complete()Description copied from interface:CouchbaseRequest
Completes the underlying state holder.- Specified by:
complete
in interfaceCouchbaseRequest
-
succeed
Description copied from interface:CouchbaseRequest
Emits theCouchbaseResponse
into the underlying state holder (like a subject) and completes it as well per contract. Its basically a shortcut forCouchbaseRequest.emit(CouchbaseResponse)
followed byCouchbaseRequest.complete()
.- Specified by:
succeed
in interfaceCouchbaseRequest
- Parameters:
response
- the response to emit and complete.
-
fail
Description copied from interface:CouchbaseRequest
Fails theCouchbaseResponse
on the state holder as per contract.- Specified by:
fail
in interfaceCouchbaseRequest
- Parameters:
throwable
- the throwable to fail the response with.
-
span
public io.opentracing.Span span()Description copied from interface:CouchbaseRequest
Returns theSpan
for this request if set.- Specified by:
span
in interfaceCouchbaseRequest
- Returns:
- the span used.
-
span
Description copied from interface:CouchbaseRequest
Allows to set a custom span that should be used.- Specified by:
span
in interfaceCouchbaseRequest
- Parameters:
span
- the span to use.env
- the core env used for context-sensitive stuff, may be null.
-
lastLocalSocket
- Specified by:
lastLocalSocket
in interfaceCouchbaseRequest
-
lastRemoteSocket
- Specified by:
lastRemoteSocket
in interfaceCouchbaseRequest
-
lastLocalId
- Specified by:
lastLocalId
in interfaceCouchbaseRequest
-
lastLocalSocket
- Specified by:
lastLocalSocket
in interfaceCouchbaseRequest
-
lastRemoteSocket
- Specified by:
lastRemoteSocket
in interfaceCouchbaseRequest
-
lastLocalId
- Specified by:
lastLocalId
in interfaceCouchbaseRequest
-
afterSpanSet
protected void afterSpanSet(io.opentracing.Span span)Use this method to add custom span values on insert. -
operationId
Default implementation, sub requests need to override this.- Specified by:
operationId
in interfaceCouchbaseRequest
- Returns:
- the operation id or null.
-
toString
-